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 )
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 )
......
......@@ -119,19 +119,15 @@
{
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 );
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 );
}
......
......@@ -1297,9 +1297,9 @@
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];
......
......@@ -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 );
}
}
......
......@@ -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();
......
......@@ -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 )
{
......
......@@ -49,10 +49,10 @@
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;
}
......
......@@ -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
......
......@@ -298,17 +298,18 @@ 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 ) );
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 );
}
......
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