]> git.sesse.net Git - vlc/blobdiff - src/osd/osd.c
Fix tiny race condition
[vlc] / src / osd / osd.c
index 6e7bbdc9378d4adf138ef25c8db660de07068345..0026a7993e310301a6a86147e6f35862d487aea5 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>
-#include <string.h>
 
 #include <vlc/vlc.h>
 #include <vlc_keys.h>
 #include <vlc_osd.h>
+#include "libvlc.h"
 
 #undef OSD_MENU_DEBUG
 
@@ -117,8 +116,8 @@ osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file )
 
 error:
     msg_Err( p_this, "creating OSD menu object failed" );
-    vlc_mutex_unlock( lockval.p_address );
     vlc_object_destroy( p_osd );
+    vlc_mutex_unlock( lockval.p_address );
     return NULL;
 }
 
@@ -132,7 +131,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->i_refcount > 0 )
+    if( p_osd->p_internals->i_refcount > 0 )
     {
         vlc_mutex_unlock( lockval.p_address );
         return;
@@ -165,7 +164,7 @@ osd_state_t *__osd_StateChange( osd_state_t *p_states, const int i_state )
     return p_states;
 }
 
-/* The volume can be modified in another interface while the OSD Menu 
+/* The volume can be modified in another interface while the OSD Menu
  * has not been instantiated yet. This routines updates the "volume OSD menu item"
  * to reflect the current state of the GUI.
  */
@@ -218,7 +217,7 @@ void __osd_MenuShow( vlc_object_t *p_this )
     p_button = p_osd->p_state->p_visible;
     if( p_button )
     {
-        if( !p_button->b_range ) 
+        if( !p_button->b_range )
             p_button->p_current_state = osd_StateChange( p_button->p_states, OSD_BUTTON_UNSELECT );
         p_osd->p_state->p_visible = p_osd->p_button;
 
@@ -354,7 +353,7 @@ void __osd_MenuNext( vlc_object_t *p_this )
     p_button = p_osd->p_state->p_visible;
     if( p_button )
     {
-        if( !p_button->b_range ) 
+        if( !p_button->b_range )
             p_button->p_current_state = osd_StateChange( p_button->p_states, OSD_BUTTON_UNSELECT );
         if( p_button->p_next )
             p_osd->p_state->p_visible = p_button->p_next;
@@ -483,7 +482,7 @@ void __osd_MenuUp( vlc_object_t *p_this )
                 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,
                 p_osd->p_state->p_visible->p_current_state->p_pic );
         osd_SetMenuUpdate( p_osd, VLC_TRUE );
-        /* If this is a range style action with associated images of only one state, 
+        /* 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 )
@@ -567,7 +566,7 @@ void __osd_MenuDown( vlc_object_t *p_this )
         }
     }
 #if defined(OSD_MENU_DEBUG)
-    msg_Dbg( p_osd, "direction down [button %s]", p_osd->p_state->p_visible->psz_action ); 
+    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 );