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

playlist: add real functions for locking

parent 4d802e18
...@@ -221,9 +221,9 @@ enum pl_locked_state ...@@ -221,9 +221,9 @@ enum pl_locked_state
*****************************************************************************/ *****************************************************************************/
/* Helpers */ /* Helpers */
#define PL_LOCK vlc_object_lock( p_playlist ) #define PL_LOCK playlist_Lock( p_playlist )
#define PL_UNLOCK vlc_object_unlock( p_playlist ) #define PL_UNLOCK playlist_Unlock( p_playlist )
#define PL_ASSERT_LOCKED vlc_object_assert_locked( p_playlist ) #define PL_ASSERT_LOCKED playlist_AssertLocked( p_playlist )
VLC_EXPORT( playlist_t *, __pl_Hold, ( vlc_object_t * ) ); VLC_EXPORT( playlist_t *, __pl_Hold, ( vlc_object_t * ) );
#define pl_Hold( a ) __pl_Hold( VLC_OBJECT(a) ) #define pl_Hold( a ) __pl_Hold( VLC_OBJECT(a) )
...@@ -239,6 +239,10 @@ VLC_EXPORT( void, __pl_Release, ( vlc_object_t * ) ); ...@@ -239,6 +239,10 @@ VLC_EXPORT( void, __pl_Release, ( vlc_object_t * ) );
#define playlist_Prev(p) playlist_Control(p,PLAYLIST_SKIP, pl_Unlocked, -1) #define playlist_Prev(p) playlist_Control(p,PLAYLIST_SKIP, pl_Unlocked, -1)
#define playlist_Skip(p,i) playlist_Control(p,PLAYLIST_SKIP, pl_Unlocked, (i) ) #define playlist_Skip(p,i) playlist_Control(p,PLAYLIST_SKIP, pl_Unlocked, (i) )
VLC_EXPORT( void, playlist_Lock, ( playlist_t * ) );
VLC_EXPORT( void, playlist_Unlock, ( playlist_t * ) );
VLC_EXPORT( void, playlist_AssertLocked, ( playlist_t * ) );
/** /**
* Do a playlist action. * Do a playlist action.
* If there is something in the playlist then you can do playlist actions. * If there is something in the playlist then you can do playlist actions.
......
...@@ -287,9 +287,9 @@ mvar_t *mvar_PlaylistSetNew( intf_thread_t *p_intf, char *name, ...@@ -287,9 +287,9 @@ mvar_t *mvar_PlaylistSetNew( intf_thread_t *p_intf, char *name,
playlist_t *p_pl ) playlist_t *p_pl )
{ {
mvar_t *s = mvar_New( name, "set" ); mvar_t *s = mvar_New( name, "set" );
vlc_object_lock( p_pl ); playlist_Lock( p_pl );
PlaylistListNode( p_intf, p_pl, p_pl->p_root_category , name, s, 0 ); PlaylistListNode( p_intf, p_pl, p_pl->p_root_category , name, s, 0 );
vlc_object_unlock( p_pl ); playlist_Unlock( p_pl );
return s; return s;
} }
......
...@@ -494,12 +494,12 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -494,12 +494,12 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
int i_id = SSPopN( st, vars ); int i_id = SSPopN( st, vars );
int i_ret; int i_ret;
vlc_object_lock( p_sys->p_playlist ); playlist_Lock( p_sys->p_playlist );
i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY, i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
pl_Locked, NULL, pl_Locked, NULL,
playlist_ItemGetById( p_sys->p_playlist, playlist_ItemGetById( p_sys->p_playlist,
i_id, pl_Locked ) ); i_id, pl_Locked ) );
vlc_object_unlock( p_sys->p_playlist ); playlist_Unlock( p_sys->p_playlist );
msg_Dbg( p_intf, "requested playlist item: %i", i_id ); msg_Dbg( p_intf, "requested playlist item: %i", i_id );
SSPushN( st, i_ret ); SSPushN( st, i_ret );
} }
......
...@@ -76,8 +76,8 @@ struct intf_sys_t ...@@ -76,8 +76,8 @@ struct intf_sys_t
}; };
#define THEPL p_intf->p_sys->p_playlist #define THEPL p_intf->p_sys->p_playlist
#define QPL_LOCK vlc_object_lock( THEPL ); #define QPL_LOCK playlist_Lock( THEPL );
#define QPL_UNLOCK vlc_object_unlock( THEPL ); #define QPL_UNLOCK playlist_Unlock( THEPL );
#define THEDP DialogsProvider::getInstance() #define THEDP DialogsProvider::getInstance()
#define THEMIM MainInputManager::getInstance( p_intf ) #define THEMIM MainInputManager::getInstance( p_intf )
......
...@@ -36,9 +36,9 @@ void CmdPlay::execute() ...@@ -36,9 +36,9 @@ void CmdPlay::execute()
return; return;
} }
vlc_object_lock( pPlaylist ); playlist_Lock( pPlaylist );
const bool b_empty = playlist_IsEmpty( pPlaylist ); const bool b_empty = playlist_IsEmpty( pPlaylist );
vlc_object_unlock( pPlaylist ); playlist_Unlock( pPlaylist );
if( !b_empty ) if( !b_empty )
{ {
......
...@@ -52,7 +52,7 @@ Playtree::~Playtree() ...@@ -52,7 +52,7 @@ Playtree::~Playtree()
void Playtree::delSelected() void Playtree::delSelected()
{ {
Iterator it = begin(); Iterator it = begin();
vlc_object_lock( getIntf()->p_sys->p_playlist ); playlist_Lock( getIntf()->p_sys->p_playlist );
for( it = begin(); it != end(); it = getNextVisibleItem( it ) ) for( it = begin(); it != end(); it = getNextVisibleItem( it ) )
{ {
if( (*it).m_selected && !(*it).isReadonly() ) if( (*it).m_selected && !(*it).isReadonly() )
...@@ -93,12 +93,12 @@ void Playtree::delSelected() ...@@ -93,12 +93,12 @@ void Playtree::delSelected()
it = getNextVisibleItem( it ); it = getNextVisibleItem( it );
} }
} }
vlc_object_unlock( getIntf()->p_sys->p_playlist ); playlist_Unlock( getIntf()->p_sys->p_playlist );
} }
void Playtree::action( VarTree *pItem ) void Playtree::action( VarTree *pItem )
{ {
vlc_object_lock( m_pPlaylist ); playlist_Lock( m_pPlaylist );
VarTree::Iterator it; VarTree::Iterator it;
playlist_item_t *p_item = (playlist_item_t *)pItem->m_pData; playlist_item_t *p_item = (playlist_item_t *)pItem->m_pData;
...@@ -114,7 +114,7 @@ void Playtree::action( VarTree *pItem ) ...@@ -114,7 +114,7 @@ void Playtree::action( VarTree *pItem )
{ {
playlist_Control( m_pPlaylist, PLAYLIST_VIEWPLAY, pl_Locked, p_parent, p_item ); playlist_Control( m_pPlaylist, PLAYLIST_VIEWPLAY, pl_Locked, p_parent, p_item );
} }
vlc_object_unlock( m_pPlaylist ); playlist_Unlock( m_pPlaylist );
} }
void Playtree::onChange() void Playtree::onChange()
...@@ -213,7 +213,7 @@ void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree ) ...@@ -213,7 +213,7 @@ void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree )
void Playtree::buildTree() void Playtree::buildTree()
{ {
clear(); clear();
vlc_object_lock( m_pPlaylist ); playlist_Lock( m_pPlaylist );
i_items_to_append = 0; i_items_to_append = 0;
...@@ -228,7 +228,7 @@ void Playtree::buildTree() ...@@ -228,7 +228,7 @@ void Playtree::buildTree()
buildNode( m_pPlaylist->p_root_category, *this ); buildNode( m_pPlaylist->p_root_category, *this );
vlc_object_unlock( m_pPlaylist ); playlist_Unlock( m_pPlaylist );
// What is it ? // What is it ?
// checkParents( NULL ); // checkParents( NULL );
} }
......
...@@ -225,13 +225,13 @@ wxWindow *CreateDialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent ); ...@@ -225,13 +225,13 @@ wxWindow *CreateDialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent );
inline void LockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl ) inline void LockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
{ {
if( p_sys->i_playlist_usage++ == 0) if( p_sys->i_playlist_usage++ == 0)
vlc_object_lock( p_pl ); playlist_lock( p_pl );
} }
inline void UnlockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl ) inline void UnlockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
{ {
if( --p_sys->i_playlist_usage == 0) if( --p_sys->i_playlist_usage == 0)
vlc_object_unlock( p_pl ); playlist_Unlock( p_pl );
} }
#endif #endif
...@@ -275,6 +275,7 @@ playlist_Add ...@@ -275,6 +275,7 @@ playlist_Add
playlist_AddExt playlist_AddExt
playlist_AddInput playlist_AddInput
playlist_AskForArtEnqueue playlist_AskForArtEnqueue
playlist_AssertLocked
playlist_BothAddInput playlist_BothAddInput
playlist_ChildSearchName playlist_ChildSearchName
playlist_Clear playlist_Clear
...@@ -297,6 +298,7 @@ playlist_ItemGetByInputId ...@@ -297,6 +298,7 @@ playlist_ItemGetByInputId
playlist_ItemNewWithType playlist_ItemNewWithType
playlist_ItemToNode playlist_ItemToNode
playlist_LiveSearchUpdate playlist_LiveSearchUpdate
playlist_Lock
playlist_NodeAppend playlist_NodeAppend
playlist_NodeChildrenCount playlist_NodeChildrenCount
playlist_NodeCreate playlist_NodeCreate
...@@ -311,6 +313,7 @@ playlist_ServicesDiscoveryAdd ...@@ -311,6 +313,7 @@ playlist_ServicesDiscoveryAdd
playlist_ServicesDiscoveryRemove playlist_ServicesDiscoveryRemove
playlist_Status playlist_Status
playlist_TreeMove playlist_TreeMove
playlist_Unlock
__pl_Hold __pl_Hold
__pl_Release __pl_Release
resolve_xml_special_chars resolve_xml_special_chars
......
...@@ -66,6 +66,21 @@ void __pl_Release( vlc_object_t *p_this ) ...@@ -66,6 +66,21 @@ void __pl_Release( vlc_object_t *p_this )
vlc_object_release( pl ); vlc_object_release( pl );
} }
void playlist_Lock( playlist_t *pl )
{
vlc_object_lock( pl );
}
void playlist_Unlock( playlist_t *pl )
{
vlc_object_unlock( pl );
}
void playlist_AssertLocked( playlist_t *pl )
{
vlc_object_assert_locked( pl );
}
int playlist_Control( playlist_t * p_playlist, int i_query, int playlist_Control( playlist_t * p_playlist, int i_query,
bool b_locked, ... ) bool b_locked, ... )
{ {
......
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