Commit c8897e2c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use PL_LOCK/PL_UNLOCK

parent 143dc11a
...@@ -542,17 +542,17 @@ static void Run( intf_thread_t *p_intf ) ...@@ -542,17 +542,17 @@ static void Run( intf_thread_t *p_intf )
if( p_playlist ) if( p_playlist )
{ {
vlc_object_lock( p_playlist ); PL_LOCK;
p_intf->p_sys->i_last_state = (int) PLAYLIST_STOPPED; p_intf->p_sys->i_last_state = (int) PLAYLIST_STOPPED;
msg_rc( STATUS_CHANGE "( stop state: 0 )" ); 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) && if( (p_input != NULL) && !p_input->b_dead && vlc_object_alive (p_input) &&
(p_playlist != NULL) ) (p_playlist != NULL) )
{ {
vlc_object_lock( p_playlist ); PL_LOCK;
if( (p_intf->p_sys->i_last_state != p_playlist->status.i_status) && if( (p_intf->p_sys->i_last_state != p_playlist->status.i_status) &&
(p_playlist->status.i_status == PLAYLIST_STOPPED) ) (p_playlist->status.i_status == PLAYLIST_STOPPED) )
{ {
...@@ -573,7 +573,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -573,7 +573,7 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->i_last_state = p_playlist->status.i_status; p_intf->p_sys->i_last_state = p_playlist->status.i_status;
msg_rc( STATUS_CHANGE "( pause state: 4 )" ); msg_rc( STATUS_CHANGE "( pause state: 4 )" );
} }
vlc_object_unlock( p_playlist ); PL_UNLOCK;
} }
if( p_input && b_showpos ) if( p_input && b_showpos )
......
...@@ -119,19 +119,15 @@ ...@@ -119,19 +119,15 @@
{ {
intf_thread_t * p_intf = VLCIntf; intf_thread_t * p_intf = VLCIntf;
playlist_t * p_playlist = pl_Yield( p_intf ); playlist_t * p_playlist = pl_Yield( p_intf );
bool empty;
vlc_object_lock( p_playlist ); PL_LOCK;
if( playlist_IsEmpty( p_playlist ) ) empty = playlist_IsEmpty( p_playlist );
{ PL_UNLOCK;
vlc_object_unlock( p_playlist ); vlc_object_release( p_playlist );
vlc_object_release( p_playlist );
if( empty )
[o_main intfOpenFileGeneric: (id)sender]; [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 ); var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
} }
......
...@@ -1297,9 +1297,9 @@ ...@@ -1297,9 +1297,9 @@
i_type = ORDER_NORMAL; i_type = ORDER_NORMAL;
} }
vlc_object_lock( p_playlist ); PL_LOCK;
playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_category, i_mode, i_type ); 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 ); vlc_object_release( p_playlist );
[self playlistUpdated]; [self playlistUpdated];
......
...@@ -161,7 +161,7 @@ void PlaylistRebuildListStore( intf_thread_t *p_intf, ...@@ -161,7 +161,7 @@ void PlaylistRebuildListStore( intf_thread_t *p_intf,
red.blue = 0; red.blue = 0;
red.green = 0; red.green = 0;
#endif #endif
vlc_object_lock( p_playlist ); PL_LOCK;
for( i_dummy = 0; i_dummy < playlist_CurrentSize(p_playlist) ; i_dummy++ ) 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 ); playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_dummy, pl_Locked );
...@@ -177,7 +177,7 @@ void PlaylistRebuildListStore( intf_thread_t *p_intf, ...@@ -177,7 +177,7 @@ void PlaylistRebuildListStore( intf_thread_t *p_intf,
-1); -1);
} }
} }
vlc_object_unlock( p_playlist ); PL_UNLOCK;
} }
/***************************************************************** /*****************************************************************
...@@ -382,17 +382,17 @@ void onPlay(GtkButton *button, gpointer user_data) ...@@ -382,17 +382,17 @@ void onPlay(GtkButton *button, gpointer user_data)
if (p_playlist) if (p_playlist)
{ {
vlc_object_lock( p_playlist ); int s;
if (playlist_CurrentSize(p_playlist))
PL_LOCK;
s = playlist_CurrentSize(p_playlist);
PL_UNLOCK;
/* FIXME: This is racy... */
if (s)
{ {
vlc_object_unlock( p_playlist );
playlist_Play( p_playlist ); playlist_Play( p_playlist );
gdk_window_lower( p_intf->p_sys->p_window->window ); gdk_window_lower( p_intf->p_sys->p_window->window );
} }
else
{
vlc_object_unlock( p_playlist );
}
pl_Release( p_intf ); pl_Release( p_intf );
} }
} }
......
...@@ -37,10 +37,10 @@ void CmdPlaytreeSort::execute() ...@@ -37,10 +37,10 @@ void CmdPlaytreeSort::execute()
/// \todo Choose sort method/order - Need more commands /// \todo Choose sort method/order - Need more commands
/// \todo Choose the correct view /// \todo Choose the correct view
playlist_t *p_playlist = getIntf()->p_sys->p_playlist; 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, playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root_onelevel,
SORT_TITLE, ORDER_NORMAL ); SORT_TITLE, ORDER_NORMAL );
vlc_object_unlock( p_playlist ); PL_UNLOCK;
// Ask for rebuild // Ask for rebuild
Playtree &rVar = VlcProc::instance( getIntf() )->getPlaytreeVar(); Playtree &rVar = VlcProc::instance( getIntf() )->getPlaytreeVar();
......
...@@ -594,7 +594,7 @@ void Playlist::UpdatePlaylist() ...@@ -594,7 +594,7 @@ void Playlist::UpdatePlaylist()
/* Update the colour of items */ /* Update the colour of items */
vlc_object_lock( p_playlist ); PL_LOCK;
if( p_intf->p_sys->i_playing != playlist_CurrentSize( p_playlist ) ) if( p_intf->p_sys->i_playing != playlist_CurrentSize( p_playlist ) )
{ {
// p_playlist->i_index in RED // p_playlist->i_index in RED
...@@ -603,7 +603,7 @@ void Playlist::UpdatePlaylist() ...@@ -603,7 +603,7 @@ void Playlist::UpdatePlaylist()
// if exists, p_intf->p_sys->i_playing in BLACK // if exists, p_intf->p_sys->i_playing in BLACK
p_intf->p_sys->i_playing = p_playlist->i_current_index; p_intf->p_sys->i_playing = p_playlist->i_current_index;
} }
vlc_object_unlock( p_playlist ); PL_UNLOCK;
pl_Release( p_intf ); pl_Release( p_intf );
} }
...@@ -623,7 +623,7 @@ void Playlist::Rebuild() ...@@ -623,7 +623,7 @@ void Playlist::Rebuild()
ListView_DeleteAllItems( hListView ); ListView_DeleteAllItems( hListView );
/* ...and rebuild it */ /* ...and rebuild it */
vlc_object_lock( p_playlist ); PL_LOCK;
playlist_item_t * p_root = p_playlist->p_local_onelevel; playlist_item_t * p_root = p_playlist->p_local_onelevel;
playlist_item_t * p_child = NULL; playlist_item_t * p_child = NULL;
...@@ -642,7 +642,7 @@ void Playlist::Rebuild() ...@@ -642,7 +642,7 @@ void Playlist::Rebuild()
UpdateItem( p_child->i_id ); UpdateItem( p_child->i_id );
} }
vlc_object_unlock( p_playlist ); PL_UNLOCK;
if ( i_focused ) if ( i_focused )
ListView_SetItemState( hListView, i_focused, LVIS_FOCUSED | ListView_SetItemState( hListView, i_focused, LVIS_FOCUSED |
...@@ -869,9 +869,9 @@ void Playlist::ShowInfos( HWND hwnd, int i_item ) ...@@ -869,9 +869,9 @@ void Playlist::ShowInfos( HWND hwnd, int i_item )
playlist_t *p_playlist = pl_Yield( p_intf ); playlist_t *p_playlist = pl_Yield( p_intf );
if( p_playlist == NULL ) return; if( p_playlist == NULL ) return;
vlc_object_lock( p_playlist); PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_item, true ); playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_item, true );
vlc_object_unlock( p_playlist ); PL_UNLOCK;
if( p_item ) if( p_item )
{ {
......
...@@ -49,10 +49,10 @@ ...@@ -49,10 +49,10 @@
input_thread_t * vlclua_get_input_internal( lua_State *L ) input_thread_t * vlclua_get_input_internal( lua_State *L )
{ {
playlist_t *p_playlist = vlclua_get_playlist_internal( 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; input_thread_t *p_input = p_playlist->p_input;
if( p_input ) vlc_object_yield( p_input ); if( p_input ) vlc_object_yield( p_input );
vlc_object_unlock( p_playlist ); PL_UNLOCK;
vlclua_release_playlist_internal( p_playlist ); vlclua_release_playlist_internal( p_playlist );
return p_input; return p_input;
} }
......
...@@ -87,9 +87,9 @@ static int vlclua_playlist_skip( lua_State * L ) ...@@ -87,9 +87,9 @@ static int vlclua_playlist_skip( lua_State * L )
static int vlclua_playlist_play( lua_State * L ) static int vlclua_playlist_play( lua_State * L )
{ {
playlist_t *p_playlist = vlclua_get_playlist_internal( L ); playlist_t *p_playlist = vlclua_get_playlist_internal( L );
vlc_object_lock( p_playlist ); PL_LOCK;
playlist_Play( p_playlist ); playlist_Play( p_playlist );
vlc_object_unlock( p_playlist ); PL_UNLOCK;
vlclua_release_playlist_internal( p_playlist ); vlclua_release_playlist_internal( p_playlist );
return 0; return 0;
} }
...@@ -147,12 +147,12 @@ static int vlclua_playlist_goto( lua_State * L ) ...@@ -147,12 +147,12 @@ static int vlclua_playlist_goto( lua_State * L )
{ {
int i_id = luaL_checkint( L, 1 ); int i_id = luaL_checkint( L, 1 );
playlist_t *p_playlist = vlclua_get_playlist_internal( L ); 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, int i_ret = playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
true, NULL, true, NULL,
playlist_ItemGetById( p_playlist, i_id, playlist_ItemGetById( p_playlist, i_id,
true ) ); true ) );
vlc_object_unlock( p_playlist ); PL_UNLOCK;
vlclua_release_playlist_internal( p_playlist ); vlclua_release_playlist_internal( p_playlist );
return vlclua_push_ret( L, i_ret ); return vlclua_push_ret( L, i_ret );
} }
...@@ -236,7 +236,7 @@ static void push_playlist_item( lua_State *L, playlist_item_t *p_item ) ...@@ -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 ) static int vlclua_playlist_get( lua_State *L )
{ {
playlist_t *p_playlist = vlclua_get_playlist_internal( 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) */ 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; playlist_item_t *p_item = NULL;
...@@ -246,7 +246,7 @@ static int vlclua_playlist_get( lua_State *L ) ...@@ -246,7 +246,7 @@ static int vlclua_playlist_get( lua_State *L )
p_item = playlist_ItemGetById( p_playlist, i_id, true ); p_item = playlist_ItemGetById( p_playlist, i_id, true );
if( !p_item ) if( !p_item )
{ {
vlc_object_unlock( p_playlist ); PL_UNLOCK;
vlclua_release_playlist_internal( p_playlist ); vlclua_release_playlist_internal( p_playlist );
return 0; /* Should we return an error instead? */ return 0; /* Should we return an error instead? */
} }
...@@ -280,7 +280,7 @@ static int vlclua_playlist_get( lua_State *L ) ...@@ -280,7 +280,7 @@ static int vlclua_playlist_get( lua_State *L )
} }
if( !p_item ) if( !p_item )
{ {
vlc_object_unlock( p_playlist ); PL_UNLOCK;
vlclua_release_playlist_internal( p_playlist ); vlclua_release_playlist_internal( p_playlist );
return 0; /* Should we return an error instead? */ return 0; /* Should we return an error instead? */
} }
...@@ -292,7 +292,7 @@ static int vlclua_playlist_get( lua_State *L ) ...@@ -292,7 +292,7 @@ static int vlclua_playlist_get( lua_State *L )
: p_playlist->p_root_onelevel; : p_playlist->p_root_onelevel;
} }
push_playlist_item( L, p_item ); push_playlist_item( L, p_item );
vlc_object_unlock( p_playlist ); PL_UNLOCK;
vlclua_release_playlist_internal( p_playlist ); vlclua_release_playlist_internal( p_playlist );
return 1; return 1;
} }
...@@ -304,9 +304,9 @@ static int vlclua_playlist_search( lua_State *L ) ...@@ -304,9 +304,9 @@ static int vlclua_playlist_search( lua_State *L )
int b_category = luaL_optboolean( L, 2, 1 ); /* default to category */ int b_category = luaL_optboolean( L, 2, 1 ); /* default to category */
playlist_item_t *p_item = b_category ? p_playlist->p_root_category playlist_item_t *p_item = b_category ? p_playlist->p_root_category
: p_playlist->p_root_onelevel; : p_playlist->p_root_onelevel;
vlc_object_lock( p_playlist ); PL_LOCK;
playlist_LiveSearchUpdate( p_playlist, p_item, psz_string ); playlist_LiveSearchUpdate( p_playlist, p_item, psz_string );
vlc_object_unlock( p_playlist ); PL_UNLOCK;
push_playlist_item( L, p_item ); push_playlist_item( L, p_item );
vlclua_release_playlist_internal( p_playlist ); vlclua_release_playlist_internal( p_playlist );
return 1; return 1;
...@@ -355,12 +355,12 @@ static int vlclua_playlist_sort( lua_State *L ) ...@@ -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 i_type = luaL_optboolean( L, 2, 0 ) ? ORDER_REVERSE : ORDER_NORMAL;
int b_category = luaL_optboolean( L, 3, 1 ); /* default to category */ int b_category = luaL_optboolean( L, 3, 1 ); /* default to category */
playlist_t *p_playlist = vlclua_get_playlist_internal( L ); 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 playlist_item_t *p_root = b_category ? p_playlist->p_local_category
: p_playlist->p_local_onelevel; : p_playlist->p_local_onelevel;
int i_ret = playlist_RecursiveNodeSort( p_playlist, p_root, i_mode, int i_ret = playlist_RecursiveNodeSort( p_playlist, p_root, i_mode,
i_type ); i_type );
vlc_object_unlock( p_playlist ); PL_UNLOCK;
vlclua_release_playlist_internal( p_playlist ); vlclua_release_playlist_internal( p_playlist );
return vlclua_push_ret( L, i_ret ); return vlclua_push_ret( L, i_ret );
} }
...@@ -379,7 +379,7 @@ static int vlclua_playlist_status( lua_State *L ) ...@@ -379,7 +379,7 @@ static int vlclua_playlist_status( lua_State *L )
lua_pushstring( L, psz_uri ); lua_pushstring( L, psz_uri );
free( psz_uri ); free( psz_uri );
lua_pushnumber( L, config_GetInt( p_intf, "volume" ) );*/ lua_pushnumber( L, config_GetInt( p_intf, "volume" ) );*/
vlc_object_lock( p_playlist ); PL_LOCK;
switch( p_playlist->status.i_status ) switch( p_playlist->status.i_status )
{ {
case PLAYLIST_STOPPED: case PLAYLIST_STOPPED:
...@@ -395,7 +395,7 @@ static int vlclua_playlist_status( lua_State *L ) ...@@ -395,7 +395,7 @@ static int vlclua_playlist_status( lua_State *L )
lua_pushstring( L, "unknown" ); lua_pushstring( L, "unknown" );
break; break;
} }
vlc_object_unlock( p_playlist ); PL_UNLOCK;
/*i_count += 3;*/ /*i_count += 3;*/
} }
else else
......
...@@ -297,18 +297,19 @@ static int Open( vlc_object_t *p_this ) ...@@ -297,18 +297,19 @@ static int Open( vlc_object_t *p_this )
{ {
services_discovery_t *p_sd = ( services_discovery_t* )p_this; services_discovery_t *p_sd = ( services_discovery_t* )p_this;
services_discovery_sys_t *p_sys = ( services_discovery_sys_t * ) 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_sd->p_sys = p_sys;
p_sys->p_playlist = pl_Yield( p_sd ); p_sys->p_playlist = p_playlist;
Cookie *cookie = &p_sys->cookie; Cookie *cookie = &p_sys->cookie;
/* Create our playlist node */ /* Create our playlist node */
vlc_object_lock( p_sys->p_playlist ); PL_LOCK;
playlist_NodesPairCreate( pl_Get( p_sd ), _("Devices"), playlist_NodesPairCreate( p_playlist, _("Devices"),
&p_sys->p_node_cat, &p_sys->p_node_one, &p_sys->p_node_cat, &p_sys->p_node_one,
true ); true );
vlc_object_unlock( p_sys->p_playlist ); PL_UNLOCK;
cookie->serviceDiscovery = p_sd; cookie->serviceDiscovery = p_sd;
cookie->lock = new Lockable(); cookie->lock = new Lockable();
...@@ -347,17 +348,16 @@ static void Close( vlc_object_t *p_this ) ...@@ -347,17 +348,16 @@ static void Close( vlc_object_t *p_this )
{ {
services_discovery_t *p_sd = ( services_discovery_t* )p_this; services_discovery_t *p_sd = ( services_discovery_t* )p_this;
services_discovery_sys_t *p_sys = p_sd->p_sys; services_discovery_sys_t *p_sys = p_sd->p_sys;
playlist_t *p_playlist = p_sys->p_playlist;
UpnpFinish(); UpnpFinish();
delete p_sys->cookie.serverList; delete p_sys->cookie.serverList;
delete p_sys->cookie.lock; delete p_sys->cookie.lock;
vlc_object_lock( p_sys->p_playlist ); PL_LOCK;
playlist_NodeDelete( pl_Get( p_sd ), p_sys->p_node_one, true, playlist_NodeDelete( p_playlist, p_sys->p_node_one, true, true );
true ); playlist_NodeDelete( p_playlist, p_sys->p_node_cat, true, true );
playlist_NodeDelete( pl_Get( p_sd ), p_sys->p_node_cat, true, PL_UNLOCK;
true );
vlc_object_unlock( p_sys->p_playlist );
pl_Release( p_sd ); pl_Release( p_sd );
free( p_sys ); free( p_sys );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment