X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fosd%2Fosd.c;h=086abf8c87e3acdbc7c523189aea5e440b64ea62;hb=f4362a24bf6d9c93c78455988505fd184a5e5316;hp=829af78cc33e05dd43e24162507793818059e4e2;hpb=99fab9089e9e1709d9c3a4bc5ced0c137ac59134;p=vlc diff --git a/src/osd/osd.c b/src/osd/osd.c index 829af78cc3..086abf8c87 100644 --- a/src/osd/osd.c +++ b/src/osd/osd.c @@ -1,7 +1,7 @@ /***************************************************************************** * osd.c - The OSD Menu core code. ***************************************************************************** - * Copyright (C) 2005-2007 M2X + * Copyright (C) 2005-2008 M2X * $Id$ * * Authors: Jean-Paul Saman @@ -29,17 +29,16 @@ # include "config.h" #endif -#include +#include #include #include #include +#include #include "libvlc.h" #undef OSD_MENU_DEBUG -static const char *ppsz_button_states[] = { "unselect", "select", "pressed" }; - /***************************************************************************** * Local prototypes *****************************************************************************/ @@ -47,83 +46,72 @@ static const char *ppsz_button_states[] = { "unselect", "select", "pressed" }; static void osd_UpdateState( osd_menu_state_t *, int, int, int, int, picture_t * ); static inline osd_state_t *osd_VolumeStateChange( osd_state_t *, int ); static int osd_VolumeStep( vlc_object_t *, int, int ); -static vlc_bool_t osd_isVisible( osd_menu_t *p_osd ); -static osd_menu_t *osd_ParserLoad( vlc_object_t *, const char * ); -static void osd_ParserUnload( vlc_object_t *, osd_menu_t * ); +static bool osd_ParserLoad( osd_menu_t *, const char * ); +static void osd_ParserUnload( osd_menu_t * ); -static vlc_bool_t osd_isVisible( osd_menu_t *p_osd ) +static inline bool osd_isVisible( osd_menu_t *p_osd ) { - vlc_value_t val; + return var_GetBool( p_osd, "osd-menu-visible" ); +} + +static vlc_mutex_t *osd_GetMutex( vlc_object_t *p_this ) +{ + vlc_value_t lockval; - var_Get( p_osd, "osd-menu-visible", &val ); - return val.b_bool; + var_Create( p_this->p_libvlc, "osd_mutex", VLC_VAR_MUTEX ); + var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); + return lockval.p_address; } /***************************************************************************** * Wrappers for loading and unloading osd parser modules. *****************************************************************************/ -static osd_menu_t *osd_ParserLoad( vlc_object_t *p_this, const char *psz_file ) +static bool osd_ParserLoad( osd_menu_t *p_menu, const char *psz_file ) { - osd_menu_t *p_menu; - - p_menu = vlc_object_create( p_this, VLC_OBJECT_OSDMENU ); - if( !p_menu ) - { - msg_Err( p_this, "out of memory" ); - return NULL; - } - vlc_object_yield( p_menu ); - vlc_object_attach( p_menu, p_this->p_libvlc ); - /* Stuff needed for Parser */ p_menu->psz_file = strdup( psz_file ); - p_menu->p_image = image_HandlerCreate( p_this ); + p_menu->p_image = image_HandlerCreate( p_menu ); if( !p_menu->p_image || !p_menu->psz_file ) { - msg_Err( p_this, "unable to load images, aborting .." ); - osd_ParserUnload( p_this, p_menu ); - return NULL; + msg_Err( p_menu, "unable to load images, aborting .." ); + return false; } else { - char *psz_type; - char *psz_ext = strrchr( p_menu->psz_file, '.' ); + const char *psz_type; + const char *psz_ext = strrchr( p_menu->psz_file, '.' ); if( psz_ext && !strcmp( psz_ext, ".cfg") ) psz_type = "import-osd"; else psz_type = "import-osd-xml"; - p_menu->p_parser = module_Need( p_menu, "osd parser", - psz_type, VLC_TRUE ); + p_menu->p_parser = module_need( p_menu, "osd parser", + psz_type, true ); if( !p_menu->p_parser ) { - osd_ParserUnload( p_this, p_menu ); - return NULL; + return false; } } - return p_menu; + return true; } -static void osd_ParserUnload( vlc_object_t *p_this, osd_menu_t *p_menu ) +static void osd_ParserUnload( osd_menu_t *p_menu ) { if( p_menu->p_image ) image_HandlerDelete( p_menu->p_image ); - if( p_menu->psz_file ) - free( p_menu->psz_file ); if( p_menu->p_parser ) - module_Unneed( p_menu, p_menu->p_parser ); + module_unneed( p_menu, p_menu->p_parser ); - vlc_object_detach( p_menu ); - vlc_object_destroy( p_menu ); + free( p_menu->psz_file ); } /** * Change state on an osd_button_t. * - * This function selects the specified state and returns a pointer to it. The - * following states are currently supported: + * This function selects the specified state and returns a pointer + * vlc_custom_create to it. The following states are currently supported: * \see OSD_BUTTON_UNSELECT * \see OSD_BUTTON_SELECT * \see OSD_BUTTON_PRESSED @@ -134,7 +122,7 @@ static osd_state_t *osd_StateChange( osd_button_t *p_button, const int i_state ) osd_state_t *p_temp = NULL; int i = 0; - for( i=0; p_current != NULL; i++ ) + for( i= 0; p_current != NULL; i++ ) { if( p_current->i_state == i_state ) { @@ -150,29 +138,40 @@ static osd_state_t *osd_StateChange( osd_button_t *p_button, const int i_state ) return p_button->p_states; } +#undef osd_MenuCreate /***************************************************************************** * OSD menu Funtions *****************************************************************************/ -osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file ) +osd_menu_t *osd_MenuCreate( vlc_object_t *p_this, const char *psz_file ) { osd_menu_t *p_osd = NULL; - vlc_value_t lockval; + vlc_value_t val; + vlc_mutex_t *p_lock; int i_volume = 0; int i_steps = 0; /* to be sure to avoid multiple creation */ - var_Create( p_this->p_libvlc, "osd_mutex", VLC_VAR_MUTEX ); - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); + p_lock = osd_GetMutex( p_this ); + vlc_mutex_lock( p_lock ); - p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ); - if( p_osd == NULL ) + var_Create( p_this->p_libvlc, "osd-object", VLC_VAR_ADDRESS ); + var_Get( p_this->p_libvlc, "osd-object", &val ); + if( val.p_address == NULL ) { - vlc_value_t val; + static const char osdmenu_name[] = "osd menu"; - /* Parse configuration file */ - p_osd = osd_ParserLoad( p_this, psz_file ); + p_osd = vlc_custom_create( p_this, sizeof( *p_osd ), + VLC_OBJECT_GENERIC, osdmenu_name ); if( !p_osd ) + return NULL; + + p_osd->p_parser = NULL; + vlc_object_attach( p_osd, p_this->p_libvlc ); + + /* Parse configuration file */ + if ( !osd_ParserLoad( p_osd, psz_file ) ) + goto error; + if( !p_osd->p_state ) goto error; /* Setup default button (first button) */ @@ -198,49 +197,56 @@ osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file ) var_Create( p_osd, "osd-menu-update", VLC_VAR_BOOL ); var_Create( p_osd, "osd-menu-visible", VLC_VAR_BOOL ); - val.b_bool = VLC_FALSE; - var_Set( p_osd, "osd-menu-update", val ); - var_Set( p_osd, "osd-menu-visible", val ); + var_SetBool( p_osd, "osd-menu-update", false ); + var_SetBool( p_osd, "osd-menu-visible", false ); + + val.p_address = p_osd; + var_Set( p_this->p_libvlc, "osd-object", val ); } - vlc_mutex_unlock( lockval.p_address ); + else + p_osd = val.p_address; + vlc_object_hold( p_osd ); + vlc_mutex_unlock( p_lock ); return p_osd; error: - msg_Err( p_this, "creating OSD menu object failed" ); - - if( p_osd->p_image ) - image_HandlerDelete( p_osd->p_image ); - if( p_osd->psz_file ) - free( p_osd->psz_file ); - - vlc_object_detach( p_osd ); - vlc_object_destroy( p_osd ); - vlc_mutex_unlock( lockval.p_address ); + vlc_mutex_unlock( p_lock ); + osd_MenuDelete( p_this, p_osd ); return NULL; } -void __osd_MenuDelete( vlc_object_t *p_this, osd_menu_t *p_osd ) +#undef osd_MenuDelete +void osd_MenuDelete( vlc_object_t *p_this, osd_menu_t *p_osd ) { - vlc_value_t lockval; + vlc_mutex_t *p_lock; if( !p_osd || !p_this ) return; - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); + p_lock = osd_GetMutex( p_this ); + vlc_mutex_lock( p_lock ); - vlc_object_release( p_osd ); - if( p_osd->p_internals->i_refcount > 0 ) + if( vlc_internals( VLC_OBJECT(p_osd) )->i_refcount == 1 ) { - vlc_mutex_unlock( lockval.p_address ); - return; + vlc_value_t val; + + var_Destroy( p_osd, "osd-menu-visible" ); + var_Destroy( p_osd, "osd-menu-update" ); + osd_ParserUnload( p_osd ); + val.p_address = NULL; + var_Set( p_this->p_libvlc, "osd-object", val ); } - var_Destroy( p_osd, "osd-menu-visible" ); - var_Destroy( p_osd, "osd-menu-update" ); + vlc_object_release( p_osd ); + vlc_mutex_unlock( p_lock ); +} - osd_ParserUnload( p_this, p_osd ); - p_osd = NULL; - vlc_mutex_unlock( lockval.p_address ); +static osd_menu_t *osd_Find( vlc_object_t *p_this ) +{ + vlc_value_t val; + + if( var_Get( p_this->p_libvlc, "osd-object", &val ) ) + return NULL; + return val.p_address; } /* The volume can be modified in another interface while the OSD Menu @@ -274,22 +280,22 @@ static void osd_UpdateState( osd_menu_state_t *p_state, int i_x, int i_y, p_state->p_pic = p_pic; } -void __osd_MenuShow( vlc_object_t *p_this ) +#undef osd_MenuShow +void osd_MenuShow( vlc_object_t *p_this ) { - osd_menu_t *p_osd = NULL; + osd_menu_t *p_osd; osd_button_t *p_button = NULL; - vlc_value_t lockval; + vlc_mutex_t *p_lock = osd_GetMutex( p_this ); - p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ); + vlc_mutex_lock( p_lock ); + p_osd = osd_Find( p_this ); if( p_osd == NULL ) { - msg_Err( p_this, "osd_MenuNext failed" ); + vlc_mutex_unlock( p_lock ); + msg_Err( p_this, "osd_MenuShow failed" ); return; } - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); - #if defined(OSD_MENU_DEBUG) msg_Dbg( p_osd, "menu on" ); #endif @@ -309,63 +315,57 @@ void __osd_MenuShow( vlc_object_t *p_this ) p_osd->p_state->p_visible->p_current_state->i_width, p_osd->p_state->p_visible->p_current_state->i_height, p_osd->p_state->p_visible->p_current_state->p_pic ); - osd_SetMenuUpdate( p_osd, VLC_TRUE ); + osd_SetMenuUpdate( p_osd, true ); } - osd_SetMenuVisible( p_osd, VLC_TRUE ); + osd_SetMenuVisible( p_osd, true ); - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); + vlc_mutex_unlock( p_lock ); } -void __osd_MenuHide( vlc_object_t *p_this ) +#undef osd_MenuHide +void osd_MenuHide( vlc_object_t *p_this ) { - osd_menu_t *p_osd = NULL; - vlc_value_t lockval; + osd_menu_t *p_osd; + vlc_mutex_t *p_lock = osd_GetMutex( p_this ); + + vlc_mutex_lock( p_lock ); - p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ); + p_osd = osd_Find( p_this ); if( p_osd == NULL ) { - msg_Err( p_this, "osd_MenuNext failed" ); + vlc_mutex_unlock( p_lock ); + msg_Err( p_this, "osd_MenuHide failed" ); return; } - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); - #if defined(OSD_MENU_DEBUG) msg_Dbg( p_osd, "menu off" ); #endif osd_UpdateState( p_osd->p_state, p_osd->p_state->i_x, p_osd->p_state->i_y, 0, 0, NULL ); - osd_SetMenuUpdate( p_osd, VLC_TRUE ); + osd_SetMenuUpdate( p_osd, true ); - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); + vlc_mutex_unlock( p_lock ); } -void __osd_MenuActivate( vlc_object_t *p_this ) +#undef osd_MenuActivate +void osd_MenuActivate( vlc_object_t *p_this ) { - osd_menu_t *p_osd = NULL; + osd_menu_t *p_osd; osd_button_t *p_button = NULL; - vlc_value_t lockval; + vlc_mutex_t *p_lock = osd_GetMutex( p_this ); - p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ); - if( p_osd == NULL ) - { - msg_Err( p_this, "osd_MenuNext failed" ); - return; - } + vlc_mutex_lock( p_lock ); - if( osd_isVisible( p_osd ) == VLC_FALSE ) + p_osd = osd_Find( p_this ); + if( p_osd == NULL || !osd_isVisible( p_osd ) ) { - vlc_object_release( (vlc_object_t*) p_osd ); + vlc_mutex_unlock( p_lock ); + msg_Err( p_this, "osd_MenuActivate failed" ); return; } - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); - #if defined(OSD_MENU_DEBUG) msg_Dbg( p_osd, "select" ); #endif @@ -375,16 +375,14 @@ void __osd_MenuActivate( vlc_object_t *p_this ) */ if( p_button && p_button->p_up ) { - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); - __osd_MenuUp( p_this ); /* "menu select" means go to menu item above. */ + vlc_mutex_unlock( p_lock ); + osd_MenuUp( p_this ); /* "menu select" means go to menu item above. */ return; } if( p_button && p_button->p_down ) { - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); - __osd_MenuDown( p_this ); /* "menu select" means go to menu item below. */ + vlc_mutex_unlock( p_lock ); + osd_MenuDown( p_this ); /* "menu select" means go to menu item below. */ return; } @@ -396,39 +394,36 @@ void __osd_MenuActivate( vlc_object_t *p_this ) p_osd->p_state->p_visible->p_current_state->i_width, p_osd->p_state->p_visible->p_current_state->i_height, p_button->p_current_state->p_pic ); - osd_SetMenuUpdate( p_osd, VLC_TRUE ); - osd_SetMenuVisible( p_osd, VLC_TRUE ); - osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), config_GetInt( p_osd, p_button->psz_action ) ); + osd_SetMenuUpdate( p_osd, true ); + osd_SetMenuVisible( p_osd, true ); + osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), + var_InheritInteger( p_osd, p_button->psz_action ) ); #if defined(OSD_MENU_DEBUG) - msg_Dbg( p_osd, "select (%d, %s)", config_GetInt( p_osd, p_button->psz_action ), p_button->psz_action ); + msg_Dbg( p_osd, "select (%d, %s)", + (int)var_InheritInteger( p_osd, p_button->psz_action ), + p_button->psz_action ); #endif } - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); + vlc_mutex_unlock( p_lock ); } -void __osd_MenuNext( vlc_object_t *p_this ) +#undef osd_MenuNext +void osd_MenuNext( vlc_object_t *p_this ) { - osd_menu_t *p_osd = NULL; + osd_menu_t *p_osd; osd_button_t *p_button = NULL; - vlc_value_t lockval; + vlc_mutex_t *p_lock = osd_GetMutex( p_this ); - p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ); - if( p_osd == NULL ) - { - msg_Err( p_this, "osd_MenuNext failed" ); - return; - } + vlc_mutex_lock( p_lock ); - if( osd_isVisible( p_osd ) == VLC_FALSE ) + p_osd = osd_Find( p_this ); + if( p_osd == NULL || !osd_isVisible( p_osd ) ) { - vlc_object_release( (vlc_object_t*) p_osd ); + vlc_mutex_unlock( p_lock ); + msg_Err( p_this, "osd_MenuNext failed" ); return; } - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); - p_button = p_osd->p_state->p_visible; if( p_button ) { @@ -448,38 +443,31 @@ void __osd_MenuNext( vlc_object_t *p_this ) p_osd->p_state->p_visible->p_current_state->i_width, p_osd->p_state->p_visible->p_current_state->i_height, p_osd->p_state->p_visible->p_current_state->p_pic ); - osd_SetMenuUpdate( p_osd, VLC_TRUE ); + osd_SetMenuUpdate( p_osd, true ); } #if defined(OSD_MENU_DEBUG) msg_Dbg( p_osd, "direction right [button %s]", p_osd->p_state->p_visible->psz_action ); #endif - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); + vlc_mutex_unlock( p_lock ); } -void __osd_MenuPrev( vlc_object_t *p_this ) +#undef osd_MenuPrev +void osd_MenuPrev( vlc_object_t *p_this ) { - osd_menu_t *p_osd = NULL; + osd_menu_t *p_osd; osd_button_t *p_button = NULL; - vlc_value_t lockval; + vlc_mutex_t *p_lock = osd_GetMutex( p_this ); - p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ); - if( p_osd == NULL ) + vlc_mutex_lock( p_lock ); + p_osd = osd_Find( p_this ); + if( p_osd == NULL || !osd_isVisible( p_osd ) ) { + vlc_mutex_unlock( p_lock ); msg_Err( p_this, "osd_MenuPrev failed" ); return; } - if( osd_isVisible( p_osd ) == VLC_FALSE ) - { - vlc_object_release( (vlc_object_t*) p_osd ); - return; - } - - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); - p_button = p_osd->p_state->p_visible; if( p_button ) { @@ -499,40 +487,34 @@ void __osd_MenuPrev( vlc_object_t *p_this ) p_osd->p_state->p_visible->p_current_state->i_width, p_osd->p_state->p_visible->p_current_state->i_height, p_osd->p_state->p_visible->p_current_state->p_pic ); - osd_SetMenuUpdate( p_osd, VLC_TRUE ); + osd_SetMenuUpdate( p_osd, true ); } #if defined(OSD_MENU_DEBUG) msg_Dbg( p_osd, "direction left [button %s]", p_osd->p_state->p_visible->psz_action ); #endif - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); + vlc_mutex_unlock( p_lock ); } -void __osd_MenuUp( vlc_object_t *p_this ) +#undef osd_MenuUp +void osd_MenuUp( vlc_object_t *p_this ) { - osd_menu_t *p_osd = NULL; + osd_menu_t *p_osd; osd_button_t *p_button = NULL; - vlc_value_t lockval; #if defined(OSD_MENU_DEBUG) vlc_value_t val; #endif - p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ); - if( p_osd == NULL ) - { - msg_Err( p_this, "osd_MenuDown failed" ); - return; - } + vlc_mutex_t *p_lock = osd_GetMutex( p_this ); - if( osd_isVisible( p_osd ) == VLC_FALSE ) + vlc_mutex_lock( p_lock ); + p_osd = osd_Find( p_this ); + if( p_osd == NULL || !osd_isVisible( p_osd ) ) { - vlc_object_release( (vlc_object_t*) p_osd ); + vlc_mutex_unlock( p_lock ); + msg_Err( p_this, "osd_MenuActivate failed" ); return; } - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); - p_button = p_osd->p_state->p_visible; if( p_button ) { @@ -560,15 +542,16 @@ void __osd_MenuUp( vlc_object_t *p_this ) p_osd->p_state->p_visible->p_current_state->i_width, p_osd->p_state->p_visible->p_current_state->i_height, p_osd->p_state->p_visible->p_current_state->p_pic ); - osd_SetMenuUpdate( p_osd, VLC_TRUE ); + osd_SetMenuUpdate( p_osd, true ); /* If this is a range style action with associated images of only one state, * then perform "menu select" on every menu navigation */ if( p_button->b_range ) { - osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), config_GetInt(p_osd, p_button->psz_action) ); + osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), + var_InheritInteger(p_osd, p_button->psz_action) ); #if defined(OSD_MENU_DEBUG) - msg_Dbg( p_osd, "select (%d, %s)", val.i_int, p_button->psz_action ); + msg_Dbg( p_osd, "select (%"PRId64", %s)", val.i_int, p_button->psz_action ); #endif } } @@ -576,35 +559,29 @@ void __osd_MenuUp( vlc_object_t *p_this ) msg_Dbg( p_osd, "direction up [button %s]", p_osd->p_state->p_visible->psz_action ); #endif - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); + vlc_mutex_unlock( p_lock ); } -void __osd_MenuDown( vlc_object_t *p_this ) +#undef osd_MenuDown +void osd_MenuDown( vlc_object_t *p_this ) { - osd_menu_t *p_osd = NULL; + osd_menu_t *p_osd; osd_button_t *p_button = NULL; - vlc_value_t lockval; #if defined(OSD_MENU_DEBUG) vlc_value_t val; #endif + vlc_mutex_t *p_lock = osd_GetMutex( p_this ); - p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ); - if( p_osd == NULL ) - { - msg_Err( p_this, "osd_MenuDown failed" ); - return; - } + vlc_mutex_lock( p_lock ); - if( osd_isVisible( p_osd ) == VLC_FALSE ) + p_osd = osd_Find( p_this ); + if( p_osd == NULL || !osd_isVisible( p_osd ) ) { - vlc_object_release( (vlc_object_t*) p_osd ); + vlc_mutex_unlock( p_lock ); + msg_Err( p_this, "osd_MenuActivate failed" ); return; } - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); - p_button = p_osd->p_state->p_visible; if( p_button ) { @@ -632,15 +609,16 @@ void __osd_MenuDown( vlc_object_t *p_this ) p_osd->p_state->p_visible->p_current_state->i_width, p_osd->p_state->p_visible->p_current_state->i_height, p_osd->p_state->p_visible->p_current_state->p_pic ); - osd_SetMenuUpdate( p_osd, VLC_TRUE ); + osd_SetMenuUpdate( p_osd, true ); /* If this is a range style action with associated images of only one state, * then perform "menu select" on every menu navigation */ if( p_button->b_range ) { - osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), config_GetInt(p_osd, p_button->psz_action_down) ); + osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), + var_InheritInteger(p_osd, p_button->psz_action_down) ); #if defined(OSD_MENU_DEBUG) - msg_Dbg( p_osd, "select (%d, %s)", val.i_int, p_button->psz_action_down ); + msg_Dbg( p_osd, "select (%"PRId64", %s)", val.i_int, p_button->psz_action_down ); #endif } } @@ -648,8 +626,7 @@ void __osd_MenuDown( vlc_object_t *p_this ) msg_Dbg( p_osd, "direction down [button %s]", p_osd->p_state->p_visible->psz_action ); #endif - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); + vlc_mutex_unlock( p_lock ); } static int osd_VolumeStep( vlc_object_t *p_this, int i_volume, int i_steps ) @@ -661,31 +638,33 @@ static int osd_VolumeStep( vlc_object_t *p_this, int i_volume, int i_steps ) return (i_volume/i_volume_step); } +#undef osd_Volume /** * Display current audio volume bitmap * * The OSD Menu audio volume bar is updated to reflect the new audio volume. Call this function * when the audio volume is updated outside the OSD menu command "menu up", "menu down" or "menu select". */ -void __osd_Volume( vlc_object_t *p_this ) +void osd_Volume( vlc_object_t *p_this ) { - osd_menu_t *p_osd = NULL; + osd_menu_t *p_osd; osd_button_t *p_button = NULL; - vlc_value_t lockval; + vlc_mutex_t *p_lock = osd_GetMutex( p_this ); int i_volume = 0; int i_steps = 0; - p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ); + vlc_mutex_lock( p_lock ); + + p_osd = osd_Find( p_this ); if( p_osd == NULL ) { + vlc_mutex_unlock( p_lock ); msg_Err( p_this, "OSD menu volume update failed" ); return; } if( p_osd->p_state && p_osd->p_state->p_volume ) { - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); p_button = p_osd->p_state->p_volume; if( p_osd->p_state->p_volume ) @@ -702,38 +681,32 @@ void __osd_Volume( vlc_object_t *p_this ) p_button->p_current_state->i_width, p_button->p_current_state->i_height, p_button->p_current_state->p_pic ); - osd_SetMenuUpdate( p_osd, VLC_TRUE ); - osd_SetMenuVisible( p_osd, VLC_TRUE ); + osd_SetMenuUpdate( p_osd, true ); + osd_SetMenuVisible( p_osd, true ); } - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); } + vlc_mutex_unlock( p_lock ); } -osd_button_t *__osd_ButtonFind( vlc_object_t *p_this, int i_x, int i_y, +#undef osd_ButtonFind +osd_button_t *osd_ButtonFind( vlc_object_t *p_this, int i_x, int i_y, int i_window_height, int i_window_width, int i_scale_width, int i_scale_height ) { osd_menu_t *p_osd; osd_button_t *p_button; - vlc_value_t lockval; + vlc_mutex_t *p_lock = osd_GetMutex( p_this ); - p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ); - if( p_osd == NULL ) - { - msg_Err( p_this, "OSD menu button find failed" ); - return NULL; - } + vlc_mutex_lock( p_lock ); - if( osd_isVisible( p_osd ) == VLC_FALSE ) + p_osd = osd_Find( p_this ); + if( p_osd == NULL || !osd_isVisible( p_osd ) ) { - vlc_object_release( (vlc_object_t*) p_osd ); + vlc_mutex_unlock( p_lock ); + msg_Err( p_this, "osd_ButtonFind failed" ); return NULL; } - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); - p_button = p_osd->p_button; for( ; p_button != NULL; p_button = p_button->p_next ) { @@ -780,42 +753,35 @@ osd_button_t *__osd_ButtonFind( vlc_object_t *p_this, int i_x, int i_y, if( ( i_x >= i_x_offset ) && ( i_x <= i_x_offset + i_width ) && ( i_y >= i_y_offset ) && ( i_y <= i_y_offset + i_height ) ) { - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); + vlc_mutex_unlock( p_lock ); return p_button; } } - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); + vlc_mutex_unlock( p_lock ); return NULL; } +#undef osd_ButtonSelect /** * Select the button provided as the new active button */ -void __osd_ButtonSelect( vlc_object_t *p_this, osd_button_t *p_button ) +void osd_ButtonSelect( vlc_object_t *p_this, osd_button_t *p_button ) { osd_menu_t *p_osd; osd_button_t *p_old; - vlc_value_t lockval; + vlc_mutex_t *p_lock = osd_GetMutex( p_this ); - p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ); - if( p_osd == NULL ) - { - msg_Err( p_this, "OSD menu button select failed" ); - return; - } + vlc_mutex_lock( p_lock ); - if( osd_isVisible( p_osd ) == VLC_FALSE ) + p_osd = osd_Find( p_this ); + if( p_osd == NULL || !osd_isVisible( p_osd ) ) { - vlc_object_release( (vlc_object_t*) p_osd ); + vlc_mutex_unlock( p_lock ); + msg_Err( p_this, "osd_ButtonSelect failed" ); return; } - var_Get( p_this->p_libvlc, "osd_mutex", &lockval ); - vlc_mutex_lock( lockval.p_address ); - p_old = p_osd->p_state->p_visible; if( p_old ) { @@ -832,12 +798,11 @@ void __osd_ButtonSelect( vlc_object_t *p_this, osd_button_t *p_button ) p_osd->p_state->p_visible->p_current_state->i_width, p_osd->p_state->p_visible->p_current_state->i_height, p_osd->p_state->p_visible->p_current_state->p_pic ); - osd_SetMenuUpdate( p_osd, VLC_TRUE ); + osd_SetMenuUpdate( p_osd, true ); } #if defined(OSD_MENU_DEBUG) msg_Dbg( p_osd, "button selected is [button %s]", p_osd->p_state->p_visible->psz_action ); #endif - vlc_object_release( (vlc_object_t*) p_osd ); - vlc_mutex_unlock( lockval.p_address ); + vlc_mutex_unlock( p_lock ); }