]> git.sesse.net Git - vlc/blobdiff - src/osd/osd.c
osd: Make sure we release properly in __osd_Volume.
[vlc] / src / osd / osd.c
index b89024470ef522c8367715027958df98b8730140..87be707d6aabb3be2ce1f28575d52101b1c5950a 100644 (file)
@@ -29,7 +29,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_keys.h>
 #include <vlc_osd.h>
 #include <vlc_image.h>
@@ -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 );
@@ -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 );
     }
@@ -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,7 +726,7 @@ 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 );
         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,7 +833,7 @@ 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 );