X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fosd%2Fosd.c;h=97ade75c2b917c16f4d38c9c587be1d9e3069bad;hb=72e40270e69b40b5d23541b83859210e4e5242ce;hp=0afb0534e61926cd3b5cd1ed937fcb6294c6de91;hpb=07c3e97d597df3b58b263def3e86371c7df688f8;p=vlc diff --git a/src/osd/osd.c b/src/osd/osd.c index 0afb0534e6..97ade75c2b 100644 --- a/src/osd/osd.c +++ b/src/osd/osd.c @@ -29,7 +29,7 @@ # include "config.h" #endif -#include +#include #include #include #include @@ -49,11 +49,11 @@ 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 bool osd_isVisible( osd_menu_t *p_osd ); static osd_menu_t *osd_ParserLoad( vlc_object_t *, const char * ); static void osd_ParserUnload( osd_menu_t * ); -static vlc_bool_t osd_isVisible( osd_menu_t *p_osd ) +static bool osd_isVisible( osd_menu_t *p_osd ) { vlc_value_t val; @@ -67,14 +67,13 @@ static vlc_bool_t osd_isVisible( osd_menu_t *p_osd ) static osd_menu_t *osd_ParserLoad( vlc_object_t *p_this, const char *psz_file ) { osd_menu_t *p_menu; + static const char osdmenu_name[] = "osd menu"; - p_menu = vlc_object_create( p_this, VLC_OBJECT_OSDMENU ); + p_menu = vlc_custom_create( p_this, sizeof( *p_menu ), VLC_OBJECT_OSDMENU, + osdmenu_name ); 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 */ @@ -97,7 +96,7 @@ static osd_menu_t *osd_ParserLoad( vlc_object_t *p_this, const char *psz_file ) psz_type = (char*)"import-osd-xml"; p_menu->p_parser = module_Need( p_menu, "osd parser", - psz_type, VLC_TRUE ); + psz_type, true ); if( !p_menu->p_parser ) { osd_ParserUnload( p_menu ); @@ -118,7 +117,7 @@ static void osd_ParserUnload( osd_menu_t *p_menu ) module_Unneed( p_menu, p_menu->p_parser ); vlc_object_detach( p_menu ); - vlc_object_destroy( p_menu ); + vlc_object_release( p_menu ); } /** @@ -200,7 +199,7 @@ 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; + val.b_bool = false; var_Set( p_osd, "osd-menu-update", val ); var_Set( p_osd, "osd-menu-visible", val ); } @@ -216,7 +215,7 @@ error: free( p_osd->psz_file ); vlc_object_detach( p_osd ); - vlc_object_destroy( p_osd ); + vlc_object_release( p_osd ); vlc_mutex_unlock( lockval.p_address ); return NULL; } @@ -231,7 +230,7 @@ void __osd_MenuDelete( vlc_object_t *p_this, osd_menu_t *p_osd ) vlc_mutex_lock( lockval.p_address ); vlc_object_release( p_osd ); - if( p_osd->p_internals->i_refcount > 0 ) + if( vlc_internals( VLC_OBJECT(p_osd) )->i_refcount > 0 ) { vlc_mutex_unlock( lockval.p_address ); return; @@ -311,9 +310,9 @@ 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 ); @@ -340,7 +339,7 @@ void __osd_MenuHide( vlc_object_t *p_this ) 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 ); @@ -359,7 +358,7 @@ void __osd_MenuActivate( vlc_object_t *p_this ) return; } - if( osd_isVisible( p_osd ) == VLC_FALSE ) + if( osd_isVisible( p_osd ) == false ) { vlc_object_release( (vlc_object_t*) p_osd ); return; @@ -398,8 +397,8 @@ 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_SetMenuUpdate( p_osd, true ); + osd_SetMenuVisible( p_osd, true ); osd_SetKeyPressed( VLC_OBJECT(p_osd->p_libvlc), config_GetInt( 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 ); @@ -422,7 +421,7 @@ void __osd_MenuNext( vlc_object_t *p_this ) return; } - if( osd_isVisible( p_osd ) == VLC_FALSE ) + if( osd_isVisible( p_osd ) == false ) { vlc_object_release( (vlc_object_t*) p_osd ); return; @@ -450,7 +449,7 @@ 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 ); @@ -473,7 +472,7 @@ void __osd_MenuPrev( vlc_object_t *p_this ) return; } - if( osd_isVisible( p_osd ) == VLC_FALSE ) + if( osd_isVisible( p_osd ) == false ) { vlc_object_release( (vlc_object_t*) p_osd ); return; @@ -501,7 +500,7 @@ 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 ); @@ -526,7 +525,7 @@ void __osd_MenuUp( vlc_object_t *p_this ) return; } - if( osd_isVisible( p_osd ) == VLC_FALSE ) + if( osd_isVisible( p_osd ) == false ) { vlc_object_release( (vlc_object_t*) p_osd ); return; @@ -562,7 +561,7 @@ 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 */ @@ -598,7 +597,7 @@ void __osd_MenuDown( vlc_object_t *p_this ) return; } - if( osd_isVisible( p_osd ) == VLC_FALSE ) + if( osd_isVisible( p_osd ) == false ) { vlc_object_release( (vlc_object_t*) p_osd ); return; @@ -634,7 +633,7 @@ 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 */ @@ -704,12 +703,12 @@ 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_object_release( p_osd ); } osd_button_t *__osd_ButtonFind( vlc_object_t *p_this, int i_x, int i_y, @@ -727,9 +726,9 @@ osd_button_t *__osd_ButtonFind( vlc_object_t *p_this, int i_x, int i_y, return NULL; } - if( osd_isVisible( p_osd ) == VLC_FALSE ) + if( osd_isVisible( p_osd ) == false ) { - vlc_object_release( (vlc_object_t*) p_osd ); + vlc_object_release( p_osd ); return NULL; } @@ -782,13 +781,13 @@ 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_object_release( p_osd ); vlc_mutex_unlock( lockval.p_address ); return p_button; } } - vlc_object_release( (vlc_object_t*) p_osd ); + vlc_object_release( p_osd ); vlc_mutex_unlock( lockval.p_address ); return NULL; } @@ -809,7 +808,7 @@ void __osd_ButtonSelect( vlc_object_t *p_this, osd_button_t *p_button ) return; } - if( osd_isVisible( p_osd ) == VLC_FALSE ) + if( osd_isVisible( p_osd ) == false ) { vlc_object_release( (vlc_object_t*) p_osd ); return; @@ -834,12 +833,12 @@ 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_object_release( p_osd ); vlc_mutex_unlock( lockval.p_address ); }