1 /*****************************************************************************
2 * osd.c - The OSD Menu core code.
3 *****************************************************************************
4 * Copyright (C) 2005-2008 M2X
7 * Authors: Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
32 #include <vlc_common.h>
35 #include <vlc_image.h>
41 /*****************************************************************************
43 *****************************************************************************/
45 static void osd_UpdateState( osd_menu_state_t *, int, int, int, int, picture_t * );
46 static inline osd_state_t *osd_VolumeStateChange( osd_state_t *, int );
47 static int osd_VolumeStep( vlc_object_t *, int, int );
48 static bool osd_isVisible( osd_menu_t *p_osd );
49 static bool osd_ParserLoad( osd_menu_t *, const char * );
50 static void osd_ParserUnload( osd_menu_t * );
52 static bool osd_isVisible( osd_menu_t *p_osd )
56 var_Get( p_osd, "osd-menu-visible", &val );
60 static vlc_mutex_t *osd_GetMutex( vlc_object_t *p_this )
64 var_Create( p_this->p_libvlc, "osd_mutex", VLC_VAR_MUTEX );
65 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
66 return lockval.p_address;
69 /*****************************************************************************
70 * Wrappers for loading and unloading osd parser modules.
71 *****************************************************************************/
72 static bool osd_ParserLoad( osd_menu_t *p_menu, const char *psz_file )
74 /* Stuff needed for Parser */
75 p_menu->psz_file = strdup( psz_file );
76 p_menu->p_image = image_HandlerCreate( p_menu );
77 if( !p_menu->p_image || !p_menu->psz_file )
79 msg_Err( p_menu, "unable to load images, aborting .." );
85 char *psz_ext = strrchr( p_menu->psz_file, '.' );
87 if( psz_ext && !strcmp( psz_ext, ".cfg") )
88 psz_type = (char*)"import-osd";
90 psz_type = (char*)"import-osd-xml";
92 p_menu->p_parser = module_need( p_menu, "osd parser",
94 if( !p_menu->p_parser )
102 static void osd_ParserUnload( osd_menu_t *p_menu )
104 if( p_menu->p_image )
105 image_HandlerDelete( p_menu->p_image );
107 if( p_menu->p_parser )
108 module_unneed( p_menu, p_menu->p_parser );
110 free( p_menu->psz_file );
114 * Change state on an osd_button_t.
116 * This function selects the specified state and returns a pointer vlc_custom_createto it. The
117 * following states are currently supported:
118 * \see OSD_BUTTON_UNSELECT
119 * \see OSD_BUTTON_SELECT
120 * \see OSD_BUTTON_PRESSED
122 static osd_state_t *osd_StateChange( osd_button_t *p_button, const int i_state )
124 osd_state_t *p_current = p_button->p_states;
125 osd_state_t *p_temp = NULL;
128 for( i=0; p_current != NULL; i++ )
130 if( p_current->i_state == i_state )
132 p_button->i_x = p_current->i_x;
133 p_button->i_y = p_current->i_y;
134 p_button->i_width = p_current->i_width;
135 p_button->i_height = p_current->i_height;
138 p_temp = p_current->p_next;
141 return p_button->p_states;
144 /*****************************************************************************
146 *****************************************************************************/
147 osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file )
149 osd_menu_t *p_osd = NULL;
155 /* to be sure to avoid multiple creation */
156 p_lock = osd_GetMutex( p_this );
157 vlc_mutex_lock( p_lock );
159 var_Create( p_this->p_libvlc, "osd", VLC_VAR_ADDRESS );
160 var_Get( p_this->p_libvlc, "osd", &val );
161 if( val.p_address == NULL )
163 static const char osdmenu_name[] = "osd menu";
165 p_osd = vlc_custom_create( p_this, sizeof( *p_osd ),
166 VLC_OBJECT_GENERIC, osdmenu_name );
170 p_osd->p_parser = NULL;
171 vlc_object_attach( p_osd, p_this->p_libvlc );
173 /* Parse configuration file */
174 if ( !osd_ParserLoad( p_osd, psz_file ) )
176 if( !p_osd->p_state )
179 /* Setup default button (first button) */
180 p_osd->p_state->p_visible = p_osd->p_button;
181 p_osd->p_state->p_visible->p_current_state =
182 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
183 p_osd->i_width = p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch;
184 p_osd->i_height = p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines;
186 if( p_osd->p_state->p_volume )
188 /* Update the volume state images to match the current volume */
189 i_volume = config_GetInt( p_this, "volume" );
190 i_steps = osd_VolumeStep( p_this, i_volume, p_osd->p_state->p_volume->i_ranges );
191 p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange(
192 p_osd->p_state->p_volume->p_states, i_steps );
194 /* Initialize OSD state */
195 osd_UpdateState( p_osd->p_state, p_osd->i_x, p_osd->i_y,
196 p_osd->i_width, p_osd->i_height, NULL );
198 /* Signal when an update of OSD menu is needed */
199 var_Create( p_osd, "osd-menu-update", VLC_VAR_BOOL );
200 var_Create( p_osd, "osd-menu-visible", VLC_VAR_BOOL );
202 var_SetBool( p_osd, "osd-menu-update", false );
203 var_SetBool( p_osd, "osd-menu-visible", false );
205 val.p_address = p_osd;
206 var_Set( p_this->p_libvlc, "osd", val );
209 p_osd = val.p_address;
210 vlc_object_hold( p_osd );
211 vlc_mutex_unlock( p_lock );
215 vlc_mutex_unlock( p_lock );
216 __osd_MenuDelete( p_this, p_osd );
220 void __osd_MenuDelete( vlc_object_t *p_this, osd_menu_t *p_osd )
224 if( !p_osd || !p_this ) return;
226 p_lock = osd_GetMutex( p_this );
227 vlc_mutex_lock( p_lock );
229 if( vlc_internals( VLC_OBJECT(p_osd) )->i_refcount == 1 )
233 var_Destroy( p_osd, "osd-menu-visible" );
234 var_Destroy( p_osd, "osd-menu-update" );
235 osd_ParserUnload( p_osd );
236 val.p_address = NULL;
237 var_Set( p_this->p_libvlc, "osd", val );
240 vlc_object_release( p_osd );
241 vlc_mutex_unlock( p_lock );
244 static osd_menu_t *osd_Find( vlc_object_t *p_this )
248 if( var_Get( p_this->p_libvlc, "osd", &val ) )
250 return val.p_address;
253 /* The volume can be modified in another interface while the OSD Menu
254 * has not been instantiated yet. This routines updates the "volume OSD menu item"
255 * to reflect the current state of the GUI.
257 static inline osd_state_t *osd_VolumeStateChange( osd_state_t *p_current, int i_steps )
259 osd_state_t *p_temp = NULL;
262 if( i_steps < 0 ) i_steps = 0;
264 for( i=0; (i < i_steps) && (p_current != NULL); i++ )
266 p_temp = p_current->p_next;
267 if( !p_temp ) return p_current;
270 return (!p_temp) ? p_current : p_temp;
273 /* Update the state of the OSD Menu */
274 static void osd_UpdateState( osd_menu_state_t *p_state, int i_x, int i_y,
275 int i_width, int i_height, picture_t *p_pic )
279 p_state->i_width = i_width;
280 p_state->i_height = i_height;
281 p_state->p_pic = p_pic;
284 void __osd_MenuShow( vlc_object_t *p_this )
287 osd_button_t *p_button = NULL;
288 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
290 vlc_mutex_lock( p_lock );
291 p_osd = osd_Find( p_this );
294 vlc_mutex_unlock( p_lock );
295 msg_Err( p_this, "osd_MenuShow failed" );
299 #if defined(OSD_MENU_DEBUG)
300 msg_Dbg( p_osd, "menu on" );
302 p_button = p_osd->p_state->p_visible;
305 if( !p_button->b_range )
306 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_UNSELECT );
307 p_osd->p_state->p_visible = p_osd->p_button;
309 if( !p_osd->p_state->p_visible->b_range )
310 p_osd->p_state->p_visible->p_current_state =
311 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
313 osd_UpdateState( p_osd->p_state,
314 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
315 p_osd->p_state->p_visible->p_current_state->i_width,
316 p_osd->p_state->p_visible->p_current_state->i_height,
317 p_osd->p_state->p_visible->p_current_state->p_pic );
318 osd_SetMenuUpdate( p_osd, true );
320 osd_SetMenuVisible( p_osd, true );
322 vlc_mutex_unlock( p_lock );
325 void __osd_MenuHide( vlc_object_t *p_this )
328 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
330 vlc_mutex_lock( p_lock );
332 p_osd = osd_Find( p_this );
335 vlc_mutex_unlock( p_lock );
336 msg_Err( p_this, "osd_MenuHide failed" );
340 #if defined(OSD_MENU_DEBUG)
341 msg_Dbg( p_osd, "menu off" );
343 osd_UpdateState( p_osd->p_state,
344 p_osd->p_state->i_x, p_osd->p_state->i_y,
346 osd_SetMenuUpdate( p_osd, true );
348 vlc_mutex_unlock( p_lock );
351 void __osd_MenuActivate( vlc_object_t *p_this )
354 osd_button_t *p_button = NULL;
355 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
357 vlc_mutex_lock( p_lock );
359 p_osd = osd_Find( p_this );
360 if( p_osd == NULL || !osd_isVisible( p_osd ) )
362 vlc_mutex_unlock( p_lock );
363 msg_Err( p_this, "osd_MenuActivate failed" );
367 #if defined(OSD_MENU_DEBUG)
368 msg_Dbg( p_osd, "select" );
370 p_button = p_osd->p_state->p_visible;
372 * Is there a menu item above or below? If so, then select it.
374 if( p_button && p_button->p_up )
376 vlc_mutex_unlock( p_lock );
377 __osd_MenuUp( p_this ); /* "menu select" means go to menu item above. */
380 if( p_button && p_button->p_down )
382 vlc_mutex_unlock( p_lock );
383 __osd_MenuDown( p_this ); /* "menu select" means go to menu item below. */
387 if( p_button && !p_button->b_range )
389 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_PRESSED );
390 osd_UpdateState( p_osd->p_state,
391 p_button->i_x, p_button->i_y,
392 p_osd->p_state->p_visible->p_current_state->i_width,
393 p_osd->p_state->p_visible->p_current_state->i_height,
394 p_button->p_current_state->p_pic );
395 osd_SetMenuUpdate( p_osd, true );
396 osd_SetMenuVisible( p_osd, true );
397 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), config_GetInt( p_osd, p_button->psz_action ) );
398 #if defined(OSD_MENU_DEBUG)
399 msg_Dbg( p_osd, "select (%d, %s)", config_GetInt( p_osd, p_button->psz_action ), p_button->psz_action );
402 vlc_mutex_unlock( p_lock );
405 void __osd_MenuNext( vlc_object_t *p_this )
408 osd_button_t *p_button = NULL;
409 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
411 vlc_mutex_lock( p_lock );
413 p_osd = osd_Find( p_this );
414 if( p_osd == NULL || !osd_isVisible( p_osd ) )
416 vlc_mutex_unlock( p_lock );
417 msg_Err( p_this, "osd_MenuNext failed" );
421 p_button = p_osd->p_state->p_visible;
424 if( !p_button->b_range )
425 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_UNSELECT );
426 if( p_button->p_next )
427 p_osd->p_state->p_visible = p_button->p_next;
429 p_osd->p_state->p_visible = p_osd->p_button;
431 if( !p_osd->p_state->p_visible->b_range )
432 p_osd->p_state->p_visible->p_current_state =
433 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
435 osd_UpdateState( p_osd->p_state,
436 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
437 p_osd->p_state->p_visible->p_current_state->i_width,
438 p_osd->p_state->p_visible->p_current_state->i_height,
439 p_osd->p_state->p_visible->p_current_state->p_pic );
440 osd_SetMenuUpdate( p_osd, true );
442 #if defined(OSD_MENU_DEBUG)
443 msg_Dbg( p_osd, "direction right [button %s]", p_osd->p_state->p_visible->psz_action );
446 vlc_mutex_unlock( p_lock );
449 void __osd_MenuPrev( vlc_object_t *p_this )
452 osd_button_t *p_button = NULL;
453 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
455 vlc_mutex_lock( p_lock );
456 p_osd = osd_Find( p_this );
457 if( p_osd == NULL || !osd_isVisible( p_osd ) )
459 vlc_mutex_unlock( p_lock );
460 msg_Err( p_this, "osd_MenuPrev failed" );
464 p_button = p_osd->p_state->p_visible;
467 if( !p_button->b_range )
468 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_UNSELECT );
469 if( p_button->p_prev )
470 p_osd->p_state->p_visible = p_button->p_prev;
472 p_osd->p_state->p_visible = p_osd->p_last_button;
474 if( !p_osd->p_state->p_visible->b_range )
475 p_osd->p_state->p_visible->p_current_state =
476 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
478 osd_UpdateState( p_osd->p_state,
479 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
480 p_osd->p_state->p_visible->p_current_state->i_width,
481 p_osd->p_state->p_visible->p_current_state->i_height,
482 p_osd->p_state->p_visible->p_current_state->p_pic );
483 osd_SetMenuUpdate( p_osd, true );
485 #if defined(OSD_MENU_DEBUG)
486 msg_Dbg( p_osd, "direction left [button %s]", p_osd->p_state->p_visible->psz_action );
489 vlc_mutex_unlock( p_lock );
492 void __osd_MenuUp( vlc_object_t *p_this )
495 osd_button_t *p_button = NULL;
496 #if defined(OSD_MENU_DEBUG)
499 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
501 vlc_mutex_lock( p_lock );
502 p_osd = osd_Find( p_this );
503 if( p_osd == NULL || !osd_isVisible( p_osd ) )
505 vlc_mutex_unlock( p_lock );
506 msg_Err( p_this, "osd_MenuActivate failed" );
510 p_button = p_osd->p_state->p_visible;
513 if( !p_button->b_range )
515 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_SELECT );
517 p_osd->p_state->p_visible = p_button->p_up;
520 if( p_button->b_range && p_osd->p_state->p_visible->b_range )
522 osd_state_t *p_temp = p_osd->p_state->p_visible->p_current_state;
523 if( p_temp && p_temp->p_next )
524 p_osd->p_state->p_visible->p_current_state = p_temp->p_next;
526 else if( !p_osd->p_state->p_visible->b_range )
528 p_osd->p_state->p_visible->p_current_state =
529 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
532 osd_UpdateState( p_osd->p_state,
533 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
534 p_osd->p_state->p_visible->p_current_state->i_width,
535 p_osd->p_state->p_visible->p_current_state->i_height,
536 p_osd->p_state->p_visible->p_current_state->p_pic );
537 osd_SetMenuUpdate( p_osd, true );
538 /* If this is a range style action with associated images of only one state,
539 * then perform "menu select" on every menu navigation
541 if( p_button->b_range )
543 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), config_GetInt(p_osd, p_button->psz_action) );
544 #if defined(OSD_MENU_DEBUG)
545 msg_Dbg( p_osd, "select (%d, %s)", val.i_int, p_button->psz_action );
549 #if defined(OSD_MENU_DEBUG)
550 msg_Dbg( p_osd, "direction up [button %s]", p_osd->p_state->p_visible->psz_action );
553 vlc_mutex_unlock( p_lock );
556 void __osd_MenuDown( vlc_object_t *p_this )
559 osd_button_t *p_button = NULL;
560 #if defined(OSD_MENU_DEBUG)
563 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
565 vlc_mutex_lock( p_lock );
567 p_osd = osd_Find( p_this );
568 if( p_osd == NULL || !osd_isVisible( p_osd ) )
570 vlc_mutex_unlock( p_lock );
571 msg_Err( p_this, "osd_MenuActivate failed" );
575 p_button = p_osd->p_state->p_visible;
578 if( !p_button->b_range )
580 p_button->p_current_state = osd_StateChange( p_button, OSD_BUTTON_SELECT );
581 if( p_button->p_down )
582 p_osd->p_state->p_visible = p_button->p_down;
585 if( p_button->b_range && p_osd->p_state->p_visible->b_range )
587 osd_state_t *p_temp = p_osd->p_state->p_visible->p_current_state;
588 if( p_temp && p_temp->p_prev )
589 p_osd->p_state->p_visible->p_current_state = p_temp->p_prev;
591 else if( !p_osd->p_state->p_visible->b_range )
593 p_osd->p_state->p_visible->p_current_state =
594 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
597 osd_UpdateState( p_osd->p_state,
598 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
599 p_osd->p_state->p_visible->p_current_state->i_width,
600 p_osd->p_state->p_visible->p_current_state->i_height,
601 p_osd->p_state->p_visible->p_current_state->p_pic );
602 osd_SetMenuUpdate( p_osd, true );
603 /* If this is a range style action with associated images of only one state,
604 * then perform "menu select" on every menu navigation
606 if( p_button->b_range )
608 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), config_GetInt(p_osd, p_button->psz_action_down) );
609 #if defined(OSD_MENU_DEBUG)
610 msg_Dbg( p_osd, "select (%d, %s)", val.i_int, p_button->psz_action_down );
614 #if defined(OSD_MENU_DEBUG)
615 msg_Dbg( p_osd, "direction down [button %s]", p_osd->p_state->p_visible->psz_action );
618 vlc_mutex_unlock( p_lock );
621 static int osd_VolumeStep( vlc_object_t *p_this, int i_volume, int i_steps )
623 int i_volume_step = 0;
626 i_volume_step = config_GetInt( p_this->p_libvlc, "volume-step" );
627 return (i_volume/i_volume_step);
631 * Display current audio volume bitmap
633 * The OSD Menu audio volume bar is updated to reflect the new audio volume. Call this function
634 * when the audio volume is updated outside the OSD menu command "menu up", "menu down" or "menu select".
636 void __osd_Volume( vlc_object_t *p_this )
639 osd_button_t *p_button = NULL;
640 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
644 vlc_mutex_lock( p_lock );
646 p_osd = osd_Find( p_this );
649 vlc_mutex_unlock( p_lock );
650 msg_Err( p_this, "OSD menu volume update failed" );
654 if( p_osd->p_state && p_osd->p_state->p_volume )
657 p_button = p_osd->p_state->p_volume;
658 if( p_osd->p_state->p_volume )
659 p_osd->p_state->p_visible = p_osd->p_state->p_volume;
660 if( p_button && p_button->b_range )
662 /* Update the volume state images to match the current volume */
663 i_volume = config_GetInt( p_this, "volume" );
664 i_steps = osd_VolumeStep( p_this, i_volume, p_button->i_ranges );
665 p_button->p_current_state = osd_VolumeStateChange( p_button->p_states, i_steps );
667 osd_UpdateState( p_osd->p_state,
668 p_button->i_x, p_button->i_y,
669 p_button->p_current_state->i_width,
670 p_button->p_current_state->i_height,
671 p_button->p_current_state->p_pic );
672 osd_SetMenuUpdate( p_osd, true );
673 osd_SetMenuVisible( p_osd, true );
676 vlc_mutex_unlock( p_lock );
679 osd_button_t *__osd_ButtonFind( vlc_object_t *p_this, int i_x, int i_y,
680 int i_window_height, int i_window_width,
681 int i_scale_width, int i_scale_height )
684 osd_button_t *p_button;
685 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
687 vlc_mutex_lock( p_lock );
689 p_osd = osd_Find( p_this );
690 if( p_osd == NULL || !osd_isVisible( p_osd ) )
692 vlc_mutex_unlock( p_lock );
693 msg_Err( p_this, "osd_ButtonFind failed" );
697 p_button = p_osd->p_button;
698 for( ; p_button != NULL; p_button = p_button->p_next )
700 int i_source_video_width = ( i_window_width * 1000 ) / i_scale_width;
701 int i_source_video_height = ( i_window_height * 1000 ) / i_scale_height;
702 int i_y_offset = p_button->i_y;
703 int i_x_offset = p_button->i_x;
704 int i_width = p_button->i_width;
705 int i_height = p_button->i_height;
707 if( p_osd->i_position > 0 )
709 int i_inv_scale_y = i_source_video_height;
710 int i_inv_scale_x = i_source_video_width;
713 if( p_osd->i_position & SUBPICTURE_ALIGN_BOTTOM )
715 i_y_offset = i_window_height - p_button->i_height -
716 (p_osd->i_y + p_button->i_y) * i_inv_scale_y / 1000;
718 else if ( !(p_osd->i_position & SUBPICTURE_ALIGN_TOP) )
720 i_y_offset = i_window_height / 2 - p_button->i_height / 2;
723 if( p_osd->i_position & SUBPICTURE_ALIGN_RIGHT )
725 i_x_offset = i_window_width - p_button->i_width -
726 (pi_x + p_button->i_x)
727 * i_inv_scale_x / 1000;
729 else if ( !(p_osd->i_position & SUBPICTURE_ALIGN_LEFT) )
731 i_x_offset = i_window_width / 2 - p_button->i_width / 2;
734 i_width = i_window_width - p_button->i_width - i_inv_scale_x / 1000;
735 i_height = i_window_height - p_button->i_height - i_inv_scale_y / 1000;
738 // TODO: write for Up / Down case too.
739 // TODO: handle absolute positioning case
740 if( ( i_x >= i_x_offset ) && ( i_x <= i_x_offset + i_width ) &&
741 ( i_y >= i_y_offset ) && ( i_y <= i_y_offset + i_height ) )
743 vlc_mutex_unlock( p_lock );
748 vlc_mutex_unlock( p_lock );
753 * Select the button provided as the new active button
755 void __osd_ButtonSelect( vlc_object_t *p_this, osd_button_t *p_button )
759 vlc_mutex_t *p_lock = osd_GetMutex( p_this );
761 vlc_mutex_lock( p_lock );
763 p_osd = osd_Find( p_this );
764 if( p_osd == NULL || !osd_isVisible( p_osd ) )
766 vlc_mutex_unlock( p_lock );
767 msg_Err( p_this, "osd_ButtonSelect failed" );
771 p_old = p_osd->p_state->p_visible;
774 if( !p_old->b_range )
775 p_old->p_current_state = osd_StateChange( p_old, OSD_BUTTON_UNSELECT );
776 p_osd->p_state->p_visible = p_button;
778 if( !p_osd->p_state->p_visible->b_range )
779 p_osd->p_state->p_visible->p_current_state =
780 osd_StateChange( p_osd->p_state->p_visible, OSD_BUTTON_SELECT );
782 osd_UpdateState( p_osd->p_state,
783 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
784 p_osd->p_state->p_visible->p_current_state->i_width,
785 p_osd->p_state->p_visible->p_current_state->i_height,
786 p_osd->p_state->p_visible->p_current_state->p_pic );
787 osd_SetMenuUpdate( p_osd, true );
789 #if defined(OSD_MENU_DEBUG)
790 msg_Dbg( p_osd, "button selected is [button %s]", p_osd->p_state->p_visible->psz_action );
793 vlc_mutex_unlock( p_lock );