]> git.sesse.net Git - vlc/commitdiff
Use PL_LOCK/PL_UNLOCK
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sun, 14 Sep 2008 15:06:38 +0000 (18:06 +0300)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sun, 14 Sep 2008 15:06:38 +0000 (18:06 +0300)
modules/control/rc.c
modules/gui/macosx/controls.m
modules/gui/macosx/playlist.m
modules/gui/pda/pda_callbacks.c
modules/gui/skins2/commands/cmd_playtree.cpp
modules/gui/wince/playlist.cpp
modules/misc/lua/libs/input.c
modules/misc/lua/libs/playlist.c
modules/services_discovery/upnp_intel.cpp

index 4bf38c5eccaf05bfb743a919b88295439a864e2b..2c252c2b4c0cf6f127ad2e5e07b5e634f59eca1a 100644 (file)
@@ -542,17 +542,17 @@ static void Run( intf_thread_t *p_intf )
 
             if( p_playlist )
             {
-                vlc_object_lock( p_playlist );
+                PL_LOCK;
                 p_intf->p_sys->i_last_state = (int) PLAYLIST_STOPPED;
                 msg_rc( STATUS_CHANGE "( stop state: 0 )" );
-                vlc_object_unlock( p_playlist );
+                PL_UNLOCK;
             }
         }
 
         if( (p_input != NULL) && !p_input->b_dead && vlc_object_alive (p_input) &&
             (p_playlist != NULL) )
         {
-            vlc_object_lock( p_playlist );
+            PL_LOCK;
             if( (p_intf->p_sys->i_last_state != p_playlist->status.i_status) &&
                 (p_playlist->status.i_status == PLAYLIST_STOPPED) )
             {
@@ -573,7 +573,7 @@ static void Run( intf_thread_t *p_intf )
                 p_intf->p_sys->i_last_state = p_playlist->status.i_status;
                 msg_rc( STATUS_CHANGE "( pause state: 4 )" );
             }
-            vlc_object_unlock( p_playlist );
+            PL_UNLOCK;
         }
 
         if( p_input && b_showpos )
index 7c1a2fb4a380634411850328699424b87f81745f..dff64b9104542f93713a7469c141a12bdc80a815 100644 (file)
 {
     intf_thread_t * p_intf = VLCIntf;
     playlist_t * p_playlist = pl_Yield( p_intf );
+    bool empty;
 
-    vlc_object_lock( p_playlist );
-    if( playlist_IsEmpty( p_playlist ) )
-    {
-        vlc_object_unlock( p_playlist );
-        vlc_object_release( p_playlist );
+    PL_LOCK;
+    empty = playlist_IsEmpty( p_playlist );
+    PL_UNLOCK;
+    vlc_object_release( p_playlist );
+
+    if( empty )
         [o_main intfOpenFileGeneric: (id)sender];
-    }
-    else
-    {
-        vlc_object_unlock( p_playlist );
-        vlc_object_release( p_playlist );
-    }
 
     var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
 }
index d9a77a84601308ad3a330bfe1594f3d69991e269..afa1f721464a6ad5eb3ce9a50379f3295a923f93 100644 (file)
         i_type = ORDER_NORMAL;
     }
 
-    vlc_object_lock( p_playlist );
+    PL_LOCK;
     playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_category, i_mode, i_type );
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
 
     vlc_object_release( p_playlist );
     [self playlistUpdated];
index 936060489a2f56443927e9ce0783b2f701f5697a..67f92c5c1be8f7a87190ad2660e4e15aa24977c2 100644 (file)
@@ -161,7 +161,7 @@ void PlaylistRebuildListStore( intf_thread_t *p_intf,
     red.blue    = 0;
     red.green   = 0;
 #endif
-    vlc_object_lock( p_playlist );
+    PL_LOCK;
     for( i_dummy = 0; i_dummy < playlist_CurrentSize(p_playlist) ; i_dummy++ )
     {
         playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_dummy, pl_Locked );
@@ -177,7 +177,7 @@ void PlaylistRebuildListStore( intf_thread_t *p_intf,
                                 -1);
         }
     }
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
 }
 
 /*****************************************************************
@@ -382,17 +382,17 @@ void onPlay(GtkButton *button, gpointer user_data)
 
     if (p_playlist)
     {
-        vlc_object_lock( p_playlist );
-        if (playlist_CurrentSize(p_playlist))
+        int s;
+
+        PL_LOCK;
+        s = playlist_CurrentSize(p_playlist);
+        PL_UNLOCK;
+        /* FIXME: This is racy... */
+        if (s)
         {
-            vlc_object_unlock( p_playlist );
             playlist_Play( p_playlist );
             gdk_window_lower( p_intf->p_sys->p_window->window );
         }
-        else
-        {
-            vlc_object_unlock( p_playlist );
-        }
         pl_Release( p_intf );
     }
 }
index 9d61617f2cbcc3f6b9674c9cf515e968bfbefa72..a91c1e9ff63c95f9a8345a4b4811a565ab1e5d7f 100644 (file)
@@ -37,10 +37,10 @@ void CmdPlaytreeSort::execute()
     /// \todo Choose sort method/order - Need more commands
     /// \todo Choose the correct view
     playlist_t *p_playlist = getIntf()->p_sys->p_playlist;
-    vlc_object_lock( p_playlist );
+    PL_LOCK;
     playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_onelevel,
                                 SORT_TITLE, ORDER_NORMAL );
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
 
     // Ask for rebuild
     Playtree &rVar = VlcProc::instance( getIntf() )->getPlaytreeVar();
index 4d53c10359de919474c909a1e53dc2ea96f5f7de..6de3a7d94c344accaeb7ce3d8c332e58fe823757 100644 (file)
@@ -594,7 +594,7 @@ void Playlist::UpdatePlaylist()
  
     /* Update the colour of items */
 
-    vlc_object_lock( p_playlist );
+    PL_LOCK;
     if( p_intf->p_sys->i_playing != playlist_CurrentSize( p_playlist ) )
     {
         // p_playlist->i_index in RED
@@ -603,7 +603,7 @@ void Playlist::UpdatePlaylist()
         // if exists, p_intf->p_sys->i_playing in BLACK
         p_intf->p_sys->i_playing = p_playlist->i_current_index;
     }
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
 
     pl_Release( p_intf );
 }
@@ -623,7 +623,7 @@ void Playlist::Rebuild()
     ListView_DeleteAllItems( hListView );
 
     /* ...and rebuild it */
-    vlc_object_lock( p_playlist );
+    PL_LOCK;
     playlist_item_t * p_root = p_playlist->p_local_onelevel;
     playlist_item_t * p_child = NULL;
 
@@ -642,7 +642,7 @@ void Playlist::Rebuild()
 
         UpdateItem( p_child->i_id );
     }
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
 
     if ( i_focused )
         ListView_SetItemState( hListView, i_focused, LVIS_FOCUSED |
@@ -869,9 +869,9 @@ void Playlist::ShowInfos( HWND hwnd, int i_item )
     playlist_t *p_playlist = pl_Yield( p_intf );
     if( p_playlist == NULL ) return;
 
-    vlc_object_lock( p_playlist);
+    PL_LOCK;
     playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_item, true );
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
 
     if( p_item )
     {
index 7b2da567a382175a5fa3eb75fad8e3aaa7692479..0e0f5e5af74581d696d5c4ab8a9eb99a4d46572e 100644 (file)
 input_thread_t * vlclua_get_input_internal( lua_State *L )
 {
     playlist_t *p_playlist = vlclua_get_playlist_internal( L );
-    vlc_object_lock( p_playlist );
+    PL_LOCK;
     input_thread_t *p_input = p_playlist->p_input;
     if( p_input ) vlc_object_yield( p_input );
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
     vlclua_release_playlist_internal( p_playlist );
     return p_input;
 }
index ff65f3e3e27bc6872bf6ebeef9f109ca23f7debc..68498fc5c199229d5afe0245b1f1ac4f37e53f5e 100644 (file)
@@ -87,9 +87,9 @@ static int vlclua_playlist_skip( lua_State * L )
 static int vlclua_playlist_play( lua_State * L )
 {
     playlist_t *p_playlist = vlclua_get_playlist_internal( L );
-    vlc_object_lock( p_playlist );
+    PL_LOCK;
     playlist_Play( p_playlist );
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
     vlclua_release_playlist_internal( p_playlist );
     return 0;
 }
@@ -147,12 +147,12 @@ static int vlclua_playlist_goto( lua_State * L )
 {
     int i_id = luaL_checkint( L, 1 );
     playlist_t *p_playlist = vlclua_get_playlist_internal( L );
-    vlc_object_lock( p_playlist );
+    PL_LOCK;
     int i_ret = playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
                                   true, NULL,
                                   playlist_ItemGetById( p_playlist, i_id,
                                                         true ) );
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
     vlclua_release_playlist_internal( p_playlist );
     return vlclua_push_ret( L, i_ret );
 }
@@ -236,7 +236,7 @@ static void push_playlist_item( lua_State *L, playlist_item_t *p_item )
 static int vlclua_playlist_get( lua_State *L )
 {
     playlist_t *p_playlist = vlclua_get_playlist_internal( L );
-    vlc_object_lock( p_playlist );
+    PL_LOCK;
     int b_category = luaL_optboolean( L, 2, 1 ); /* Default to tree playlist (discared when 1st argument is a playlist_item's id) */
     playlist_item_t *p_item = NULL;
 
@@ -246,7 +246,7 @@ static int vlclua_playlist_get( lua_State *L )
         p_item = playlist_ItemGetById( p_playlist, i_id, true );
         if( !p_item )
         {
-            vlc_object_unlock( p_playlist );
+            PL_UNLOCK;
             vlclua_release_playlist_internal( p_playlist );
             return 0; /* Should we return an error instead? */
         }
@@ -280,7 +280,7 @@ static int vlclua_playlist_get( lua_State *L )
             }
             if( !p_item )
             {
-                vlc_object_unlock( p_playlist );
+                PL_UNLOCK;
                 vlclua_release_playlist_internal( p_playlist );
                 return 0; /* Should we return an error instead? */
             }
@@ -292,7 +292,7 @@ static int vlclua_playlist_get( lua_State *L )
                             : p_playlist->p_root_onelevel;
     }
     push_playlist_item( L, p_item );
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
     vlclua_release_playlist_internal( p_playlist );
     return 1;
 }
@@ -304,9 +304,9 @@ static int vlclua_playlist_search( lua_State *L )
     int b_category = luaL_optboolean( L, 2, 1 ); /* default to category */
     playlist_item_t *p_item = b_category ? p_playlist->p_root_category
                                          : p_playlist->p_root_onelevel;
-    vlc_object_lock( p_playlist );
+    PL_LOCK;
     playlist_LiveSearchUpdate( p_playlist, p_item, psz_string );
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
     push_playlist_item( L, p_item );
     vlclua_release_playlist_internal( p_playlist );
     return 1;
@@ -355,12 +355,12 @@ static int vlclua_playlist_sort( lua_State *L )
     int i_type = luaL_optboolean( L, 2, 0 ) ? ORDER_REVERSE : ORDER_NORMAL;
     int b_category = luaL_optboolean( L, 3, 1 ); /* default to category */
     playlist_t *p_playlist = vlclua_get_playlist_internal( L );
-    vlc_object_lock( p_playlist );
+    PL_LOCK;
     playlist_item_t *p_root = b_category ? p_playlist->p_local_category
                                          : p_playlist->p_local_onelevel;
     int i_ret = playlist_RecursiveNodeSort( p_playlist, p_root, i_mode,
                                             i_type );
-    vlc_object_unlock( p_playlist );
+    PL_UNLOCK;
     vlclua_release_playlist_internal( p_playlist );
     return vlclua_push_ret( L, i_ret );
 }
@@ -379,7 +379,7 @@ static int vlclua_playlist_status( lua_State *L )
         lua_pushstring( L, psz_uri );
         free( psz_uri );
         lua_pushnumber( L, config_GetInt( p_intf, "volume" ) );*/
-        vlc_object_lock( p_playlist );
+        PL_LOCK;
         switch( p_playlist->status.i_status )
         {
             case PLAYLIST_STOPPED:
@@ -395,7 +395,7 @@ static int vlclua_playlist_status( lua_State *L )
                 lua_pushstring( L, "unknown" );
                 break;
         }
-        vlc_object_unlock( p_playlist );
+        PL_UNLOCK;
         /*i_count += 3;*/
     }
     else
index 5da4aa6303ff81a48bb51351bac7e04209958940..4220aff0531569773906f16f56645f275b438d86 100644 (file)
@@ -297,18 +297,19 @@ static int Open( vlc_object_t *p_this )
 {
     services_discovery_t *p_sd = ( services_discovery_t* )p_this;
     services_discovery_sys_t *p_sys  = ( services_discovery_sys_t * )
-    malloc( sizeof( services_discovery_sys_t ) );
+        malloc( sizeof( services_discovery_sys_t ) );
+    playlist_t *p_playlist = pl_Yield( p_sd );
 
     p_sd->p_sys = p_sys;
-    p_sys->p_playlist = pl_Yield( p_sd );
+    p_sys->p_playlist = p_playlist;
     Cookie *cookie = &p_sys->cookie;
 
     /* Create our playlist node */
-    vlc_object_lock( p_sys->p_playlist );
-    playlist_NodesPairCreate( pl_Get( p_sd ), _("Devices"),
+    PL_LOCK;
+    playlist_NodesPairCreate( p_playlist, _("Devices"),
                               &p_sys->p_node_cat, &p_sys->p_node_one,
                               true );
-    vlc_object_unlock( p_sys->p_playlist );
+    PL_UNLOCK;
 
     cookie->serviceDiscovery = p_sd;
     cookie->lock = new Lockable();
@@ -347,17 +348,16 @@ static void Close( vlc_object_t *p_this )
 {
     services_discovery_t *p_sd = ( services_discovery_t* )p_this;
     services_discovery_sys_t *p_sys = p_sd->p_sys;
+    playlist_t *p_playlist = p_sys->p_playlist;
 
     UpnpFinish();
     delete p_sys->cookie.serverList;
     delete p_sys->cookie.lock;
 
-    vlc_object_lock( p_sys->p_playlist );
-    playlist_NodeDelete( pl_Get( p_sd ), p_sys->p_node_one, true,
-                         true );
-    playlist_NodeDelete( pl_Get( p_sd ), p_sys->p_node_cat, true,
-                         true );
-    vlc_object_unlock( p_sys->p_playlist );
+    PL_LOCK;
+    playlist_NodeDelete( p_playlist, p_sys->p_node_one, true, true );
+    playlist_NodeDelete( p_playlist, p_sys->p_node_cat, true, true );
+    PL_UNLOCK;
     pl_Release( p_sd );
     free( p_sys );
 }