Commit 7e4419bc authored by Rémi Duraffort's avatar Rémi Duraffort

The playlist have to be locked when calling playlist_ItemGetById (not tested...

The playlist have to be locked when calling playlist_ItemGetById (not tested for wince and pda interface).
parent ed8fa003
...@@ -322,7 +322,7 @@ VLC_EXPORT( int, playlist_BothAddInput, ( playlist_t *, input_item_t *,playlist_ ...@@ -322,7 +322,7 @@ VLC_EXPORT( int, playlist_BothAddInput, ( playlist_t *, input_item_t *,playlist_
VLC_EXPORT( playlist_item_t*, playlist_ItemToNode, (playlist_t *,playlist_item_t *, bool) ); VLC_EXPORT( playlist_item_t*, playlist_ItemToNode, (playlist_t *,playlist_item_t *, bool) );
/********************************** Item search *************************/ /********************************** Item search *************************/
VLC_EXPORT( playlist_item_t *, playlist_ItemGetById, (playlist_t *, int, bool ) ); VLC_EXPORT( playlist_item_t *, playlist_ItemGetById, (playlist_t *, int ) );
VLC_EXPORT( playlist_item_t *, playlist_ItemGetByInput, (playlist_t *,input_item_t *, bool ) ); VLC_EXPORT( playlist_item_t *, playlist_ItemGetByInput, (playlist_t *,input_item_t *, bool ) );
VLC_EXPORT( playlist_item_t *, playlist_ItemGetByInputId, (playlist_t *, int, playlist_item_t *) ); VLC_EXPORT( playlist_item_t *, playlist_ItemGetByInputId, (playlist_t *, int, playlist_item_t *) );
......
...@@ -867,7 +867,7 @@ static int TrackListChangeEmit( vlc_object_t *p_this, const char *psz_var, ...@@ -867,7 +867,7 @@ static int TrackListChangeEmit( vlc_object_t *p_this, const char *psz_var,
playlist_t *p_playlist = (playlist_t*)p_this; playlist_t *p_playlist = (playlist_t*)p_this;
playlist_add_t *p_add = newval.p_address; playlist_add_t *p_add = newval.p_address;
playlist_item_t *p_item; playlist_item_t *p_item;
p_item = playlist_ItemGetById( p_playlist, p_add->i_node, pl_Locked ); p_item = playlist_ItemGetById( p_playlist, p_add->i_node );
assert( p_item ); assert( p_item );
while( p_item->p_parent ) while( p_item->p_parent )
p_item = p_item->p_parent; p_item = p_item->p_parent;
......
...@@ -776,10 +776,12 @@ int ArtCallback( httpd_handler_sys_t *p_args, ...@@ -776,10 +776,12 @@ int ArtCallback( httpd_handler_sys_t *p_args,
i_id = atoi( psz_id ); i_id = atoi( psz_id );
if( i_id ) if( i_id )
{ {
playlist_Lock( p_sys->p_playlist );
playlist_item_t *p_pl_item = playlist_ItemGetById( p_sys->p_playlist, playlist_item_t *p_pl_item = playlist_ItemGetById( p_sys->p_playlist,
i_id, false ); i_id );
if( p_pl_item ) if( p_pl_item )
p_item = p_pl_item->p_input; p_item = p_pl_item->p_input;
playlist_Unlock( p_sys->p_playlist );
} }
else else
{ {
......
...@@ -199,10 +199,11 @@ static void MacroDo( httpd_file_sys_t *p_args, ...@@ -199,10 +199,11 @@ static void MacroDo( httpd_file_sys_t *p_args,
msg_Dbg( p_intf, "requested playlist play" ); msg_Dbg( p_intf, "requested playlist play" );
break; break;
} }
//TODO: really locked here ?
playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY, playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
true, NULL, true, NULL,
playlist_ItemGetById( p_sys->p_playlist, playlist_ItemGetById( p_sys->p_playlist,
i_item, true ) ); i_item ) );
msg_Dbg( p_intf, "requested playlist item: %i", i_item ); msg_Dbg( p_intf, "requested playlist item: %i", i_item );
break; break;
} }
......
...@@ -494,7 +494,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -494,7 +494,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
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 ) );
playlist_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 );
...@@ -878,12 +878,13 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -878,12 +878,13 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
else if( !strcmp( s, "playlist_delete" ) ) else if( !strcmp( s, "playlist_delete" ) )
{ {
int i_id = SSPopN( st, vars ); int i_id = SSPopN( st, vars );
playlist_Lock( p_sys->p_playlist );
playlist_item_t *p_item = playlist_ItemGetById( p_sys->p_playlist, playlist_item_t *p_item = playlist_ItemGetById( p_sys->p_playlist,
i_id, pl_Unlocked ); i_id );
if( p_item ) if( p_item )
{ {
playlist_DeleteFromInput( p_sys->p_playlist, playlist_DeleteFromInput( p_sys->p_playlist,
p_item->p_input->i_id, pl_Unlocked ); p_item->p_input->i_id, pl_Locked );
msg_Dbg( p_intf, "requested playlist delete: %d", i_id ); msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
} }
else else
...@@ -891,6 +892,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars, ...@@ -891,6 +892,7 @@ void EvaluateRPN( intf_thread_t *p_intf, mvar_t *vars,
msg_Dbg( p_intf, "couldn't find playlist item to delete (%d)", msg_Dbg( p_intf, "couldn't find playlist item to delete (%d)",
i_id ); i_id );
} }
playlist_Unlock( p_sys->p_playlist );
} }
else if( !strcmp( s, "playlist_move" ) ) else if( !strcmp( s, "playlist_move" ) )
{ {
......
...@@ -164,7 +164,7 @@ void PlaylistRebuildListStore( intf_thread_t *p_intf, ...@@ -164,7 +164,7 @@ void PlaylistRebuildListStore( intf_thread_t *p_intf,
PL_LOCK; 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 );
if( p_item ) if( p_item )
{ {
ppsz_text[0] = p_item->p_input->psz_name; ppsz_text[0] = p_item->p_input->psz_name;
......
...@@ -168,10 +168,8 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action, ...@@ -168,10 +168,8 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
PL_LOCK; PL_LOCK;
playlist_item_t *p_target = playlist_item_t *p_target =
playlist_ItemGetById( p_playlist, targetItem->i_id, playlist_ItemGetById( p_playlist, targetItem->i_id );
pl_Locked ); playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId );
playlist_item_t *p_src = playlist_ItemGetById( p_playlist, srcId,
pl_Locked );
if( !p_target || !p_src ) if( !p_target || !p_src )
{ {
...@@ -183,8 +181,7 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action, ...@@ -183,8 +181,7 @@ bool PLModel::dropMimeData( const QMimeData *data, Qt::DropAction action,
PLItem *parentItem = targetItem->parent(); PLItem *parentItem = targetItem->parent();
assert( parentItem ); assert( parentItem );
playlist_item_t *p_parent = playlist_item_t *p_parent =
playlist_ItemGetById( p_playlist, parentItem->i_id, playlist_ItemGetById( p_playlist, parentItem->i_id );
pl_Locked );
if( !p_parent ) if( !p_parent )
{ {
PL_UNLOCK; PL_UNLOCK;
...@@ -246,8 +243,7 @@ void PLModel::activateItem( const QModelIndex &index ) ...@@ -246,8 +243,7 @@ void PLModel::activateItem( const QModelIndex &index )
PLItem *item = static_cast<PLItem*>(index.internalPointer()); PLItem *item = static_cast<PLItem*>(index.internalPointer());
assert( item ); assert( item );
PL_LOCK; PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id, playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
pl_Locked );
activateItem( p_item ); activateItem( p_item );
PL_UNLOCK; PL_UNLOCK;
} }
...@@ -563,7 +559,7 @@ void PLModel::ProcessItemAppend( playlist_add_t *p_add ) ...@@ -563,7 +559,7 @@ void PLModel::ProcessItemAppend( playlist_add_t *p_add )
PL_LOCK; PL_LOCK;
if( !nodeItem ) goto end; if( !nodeItem ) goto end;
p_item = playlist_ItemGetById( p_playlist, p_add->i_item, pl_Locked ); p_item = playlist_ItemGetById( p_playlist, p_add->i_item );
if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end; if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end;
if( i_depth == DEPTH_SEL && p_item->p_parent && if( i_depth == DEPTH_SEL && p_item->p_parent &&
p_item->p_parent->i_id != rootItem->i_id ) p_item->p_parent->i_id != rootItem->i_id )
...@@ -632,8 +628,7 @@ void PLModel::rebuild( playlist_item_t *p_root ) ...@@ -632,8 +628,7 @@ void PLModel::rebuild( playlist_item_t *p_root )
/* This function must be entered WITH the playlist lock */ /* This function must be entered WITH the playlist lock */
void PLModel::UpdateNodeChildren( PLItem *root ) void PLModel::UpdateNodeChildren( PLItem *root )
{ {
playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id, playlist_item_t *p_node = playlist_ItemGetById( p_playlist, root->i_id );
pl_Locked );
UpdateNodeChildren( p_node, root ); UpdateNodeChildren( p_node, root );
} }
...@@ -654,8 +649,7 @@ void PLModel::UpdateNodeChildren( playlist_item_t *p_node, PLItem *root ) ...@@ -654,8 +649,7 @@ void PLModel::UpdateNodeChildren( playlist_item_t *p_node, PLItem *root )
/* This function must be entered WITH the playlist lock */ /* This function must be entered WITH the playlist lock */
void PLModel::UpdateTreeItem( PLItem *item, bool signal, bool force ) void PLModel::UpdateTreeItem( PLItem *item, bool signal, bool force )
{ {
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id, playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
pl_Locked );
UpdateTreeItem( p_item, item, signal, force ); UpdateTreeItem( p_item, item, signal, force );
} }
...@@ -714,11 +708,11 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList ) ...@@ -714,11 +708,11 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
fullList->removeAll( deleteIndex ); fullList->removeAll( deleteIndex );
PL_LOCK; PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id, playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item->i_id );
pl_Locked );
if( !p_item ) if( !p_item )
{ {
PL_UNLOCK; return; PL_UNLOCK;
return;
} }
if( p_item->i_children == -1 ) if( p_item->i_children == -1 )
playlist_DeleteFromInput( p_playlist, item->i_input_id, pl_Locked ); playlist_DeleteFromInput( p_playlist, item->i_input_id, pl_Locked );
...@@ -752,8 +746,7 @@ next: ...@@ -752,8 +746,7 @@ next:
PL_LOCK; PL_LOCK;
{ {
playlist_item_t *p_root = playlist_ItemGetById( p_playlist, playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
rootItem->i_id, rootItem->i_id );
pl_Locked );
if( p_root ) if( p_root )
{ {
playlist_RecursiveNodeSort( p_playlist, p_root, playlist_RecursiveNodeSort( p_playlist, p_root,
...@@ -772,8 +765,7 @@ void PLModel::search( QString search_text ) ...@@ -772,8 +765,7 @@ void PLModel::search( QString search_text )
PL_LOCK; PL_LOCK;
{ {
playlist_item_t *p_root = playlist_ItemGetById( p_playlist, playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
rootItem->i_id, rootItem->i_id );
pl_Locked );
assert( p_root ); assert( p_root );
char *psz_name = search_text.toUtf8().data(); char *psz_name = search_text.toUtf8().data();
playlist_LiveSearchUpdate( p_playlist , p_root, psz_name ); playlist_LiveSearchUpdate( p_playlist , p_root, psz_name );
...@@ -787,8 +779,7 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list ) ...@@ -787,8 +779,7 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
{ {
assert( index.isValid() ); assert( index.isValid() );
PL_LOCK; PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, playlist_item_t *p_item = playlist_ItemGetById( p_playlist, itemId( index ) );
itemId( index ), pl_Locked );
if( p_item ) if( p_item )
{ {
i_popup_item = p_item->i_id; i_popup_item = p_item->i_id;
...@@ -867,8 +858,7 @@ void PLModel::popupPlay() ...@@ -867,8 +858,7 @@ void PLModel::popupPlay()
PL_LOCK; PL_LOCK;
{ {
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
i_popup_item, i_popup_item );
pl_Locked );
activateItem( p_item ); activateItem( p_item );
} }
PL_UNLOCK; PL_UNLOCK;
...@@ -876,12 +866,16 @@ void PLModel::popupPlay() ...@@ -876,12 +866,16 @@ void PLModel::popupPlay()
void PLModel::popupInfo() void PLModel::popupInfo()
{ {
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
i_popup_item, i_popup_item );
pl_Unlocked );
if( p_item ) if( p_item )
{ {
MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_item->p_input ); input_item_t* p_input = p_item->p_input;
vlc_gc_incref( p_input );
PL_UNLOCK;
MediaInfoDialog *mid = new MediaInfoDialog( p_intf, p_input );
vlc_gc_decref( p_input );
mid->setParent( PlaylistDialog::getInstance( p_intf ), mid->setParent( PlaylistDialog::getInstance( p_intf ),
Qt::Dialog ); Qt::Dialog );
mid->show(); mid->show();
...@@ -908,13 +902,14 @@ void PLModel::popupSave() ...@@ -908,13 +902,14 @@ void PLModel::popupSave()
#include <QDesktopServices> #include <QDesktopServices>
void PLModel::popupExplore() void PLModel::popupExplore()
{ {
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
i_popup_item, i_popup_item );
pl_Unlocked );
if( p_item ) if( p_item )
{ {
input_item_t *p_input = p_item->p_input; input_item_t *p_input = p_item->p_input;
char *psz_meta = input_item_GetURI( p_input ); char *psz_meta = input_item_GetURI( p_input );
PL_UNLOCK;
if( psz_meta ) if( psz_meta )
{ {
const char *psz_access; const char *psz_access;
...@@ -933,6 +928,8 @@ void PLModel::popupExplore() ...@@ -933,6 +928,8 @@ void PLModel::popupExplore()
free( psz_meta ); free( psz_meta );
} }
} }
else
PL_UNLOCK;
} }
/********************************************************************** /**********************************************************************
......
...@@ -305,8 +305,7 @@ void StandardPLPanel::doPopup( QModelIndex index, QPoint point ) ...@@ -305,8 +305,7 @@ void StandardPLPanel::doPopup( QModelIndex index, QPoint point )
void StandardPLPanel::setRoot( int i_root_id ) void StandardPLPanel::setRoot( int i_root_id )
{ {
QPL_LOCK; QPL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( THEPL, i_root_id, playlist_item_t *p_item = playlist_ItemGetById( THEPL, i_root_id );
pl_Locked );
assert( p_item ); assert( p_item );
p_item = playlist_GetPreferredNode( THEPL, p_item ); p_item = playlist_GetPreferredNode( THEPL, p_item );
assert( p_item ); assert( p_item );
......
...@@ -174,14 +174,20 @@ void Playtree::onAppend( playlist_add_t *p_add ) ...@@ -174,14 +174,20 @@ void Playtree::onAppend( playlist_add_t *p_add )
Iterator item = findById( p_add->i_item ); Iterator item = findById( p_add->i_item );
if( item == end() ) if( item == end() )
{ {
playlist_Lock( m_pPlaylist );
playlist_item_t *p_item = playlist_ItemGetById( playlist_item_t *p_item = playlist_ItemGetById(
m_pPlaylist, p_add->i_item, pl_Unlocked ); m_pPlaylist, p_add->i_item );
if( !p_item ) return; if( !p_item )
{
playlist_Unlock( m_pPlaylist );
return;
}
UString *pName = new UString( getIntf(), UString *pName = new UString( getIntf(),
p_item->p_input->psz_name ); p_item->p_input->psz_name );
node->add( p_add->i_item, UStringPtr( pName ), node->add( p_add->i_item, UStringPtr( pName ),
false,false, false, p_item->i_flags & PLAYLIST_RO_FLAG, false,false, false, p_item->i_flags & PLAYLIST_RO_FLAG,
p_item ); p_item );
playlist_Unlock( m_pPlaylist );
} }
} }
tree_update descr; tree_update descr;
......
...@@ -525,20 +525,24 @@ LRESULT Playlist::ProcessCustomDraw( LPARAM lParam ) ...@@ -525,20 +525,24 @@ LRESULT Playlist::ProcessCustomDraw( LPARAM lParam )
pl_Release( p_intf ); pl_Release( p_intf );
return CDRF_NEWFONT; return CDRF_NEWFONT;
} }
PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, playlist_item_t *p_item = playlist_ItemGetById( p_playlist,
(int)lplvcd->nmcd.dwItemSpec, FALSE ); (int)lplvcd->nmcd.dwItemSpec );
if( !p_item ) if( !p_item )
{ {
PL_UNLOCK;
pl_Release( p_intf ); pl_Release( p_intf );
return CDRF_DODEFAULT; return CDRF_DODEFAULT;
} }
if( p_item->i_flags & PLAYLIST_DBL_FLAG ) if( p_item->i_flags & PLAYLIST_DBL_FLAG )
{ {
lplvcd->clrText = RGB(192,192,192); lplvcd->clrText = RGB(192,192,192);
PL_UNLOCK;
pl_Release( p_intf ); pl_Release( p_intf );
return CDRF_NEWFONT; return CDRF_NEWFONT;
} }
PL_UNLOCK;
pl_Release( p_intf ); pl_Release( p_intf );
} }
...@@ -663,10 +667,12 @@ void Playlist::UpdateItem( int i ) ...@@ -663,10 +667,12 @@ void Playlist::UpdateItem( int i )
if( p_playlist == NULL ) return; if( p_playlist == NULL ) return;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i, FALSE ); PL_LOCK;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i );
if( !p_item ) if( !p_item )
{ {
PL_UNLOCK;
pl_Release( p_intf ); pl_Release( p_intf );
return; return;
} }
...@@ -679,6 +685,7 @@ void Playlist::UpdateItem( int i ) ...@@ -679,6 +685,7 @@ void Playlist::UpdateItem( int i )
char psz_duration[MSTRTIME_MAX_SIZE]; char psz_duration[MSTRTIME_MAX_SIZE];
mtime_t dur = input_item_GetDuration( p_item->p_input ); mtime_t dur = input_item_GetDuration( p_item->p_input );
PL_UNLOCK;
if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 ); if( dur != -1 ) secstotimestr( psz_duration, dur/1000000 );
else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") ); else memcpy( psz_duration , "-:--:--", sizeof("-:--:--") );
...@@ -816,9 +823,10 @@ void Playlist::OnEnableSelection() ...@@ -816,9 +823,10 @@ void Playlist::OnEnableSelection()
{ {
if( ListView_GetItemState( hListView, item, LVIS_SELECTED ) ) if( ListView_GetItemState( hListView, item, LVIS_SELECTED ) )
{ {
playlist_item_t *p_item = PL_LOCK;
playlist_ItemGetById( p_playlist, item, FALSE ); playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item );
p_item->i_flags ^= PLAYLIST_DBL_FLAG; p_item->i_flags ^= PLAYLIST_DBL_FLAG;
PL_UNLOCK;
UpdateItem( item ); UpdateItem( item );
} }
} }
...@@ -835,10 +843,10 @@ void Playlist::OnDisableSelection() ...@@ -835,10 +843,10 @@ void Playlist::OnDisableSelection()
{ {
if( ListView_GetItemState( hListView, item, LVIS_SELECTED ) ) if( ListView_GetItemState( hListView, item, LVIS_SELECTED ) )
{ {
/*XXX*/ PL_LOCK;
playlist_item_t *p_item = playlist_item_t *p_item = playlist_ItemGetById( p_playlist, item );
playlist_ItemGetById( p_playlist, item, FALSE );
p_item->i_flags |= PLAYLIST_DBL_FLAG; p_item->i_flags |= PLAYLIST_DBL_FLAG;
PL_UNLOCK;
UpdateItem( item ); UpdateItem( item );
} }
} }
...@@ -870,13 +878,12 @@ void Playlist::ShowInfos( HWND hwnd, int i_item ) ...@@ -870,13 +878,12 @@ void Playlist::ShowInfos( HWND hwnd, int i_item )
if( p_playlist == NULL ) return; if( p_playlist == NULL ) return;
PL_LOCK; 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 );
PL_UNLOCK;
if( p_item ) if( p_item )
{ {
ItemInfoDialog *iteminfo_dialog = ItemInfoDialog *iteminfo_dialog =
new ItemInfoDialog( p_intf, this, hInst, p_item ); new ItemInfoDialog( p_intf, this, hInst, p_item );
PL_UNLOCK;
CreateDialogBox( hwnd, iteminfo_dialog ); CreateDialogBox( hwnd, iteminfo_dialog );
UpdateItem( i_item ); UpdateItem( i_item );
delete iteminfo_dialog; delete iteminfo_dialog;
...@@ -1098,8 +1105,8 @@ void Playlist::OnPopupEna() ...@@ -1098,8 +1105,8 @@ void Playlist::OnPopupEna()
playlist_t *p_playlist = pl_Hold( p_intf ); playlist_t *p_playlist = pl_Hold( p_intf );
if( p_playlist == NULL ) return; if( p_playlist == NULL ) return;
playlist_item_t *p_item = PL_LOCK;
playlist_ItemGetById( p_playlist, i_popup_item, FALSE ); playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_popup_item );
if( !(p_playlist->items.p_elems[i_popup_item]->i_flags & PLAYLIST_DBL_FLAG) ) if( !(p_playlist->items.p_elems[i_popup_item]->i_flags & PLAYLIST_DBL_FLAG) )
//playlist_IsEnabled( p_playlist, i_popup_item ) ) //playlist_IsEnabled( p_playlist, i_popup_item ) )
...@@ -1111,6 +1118,7 @@ void Playlist::OnPopupEna() ...@@ -1111,6 +1118,7 @@ void Playlist::OnPopupEna()
p_item->i_flags ^= PLAYLIST_DBL_FLAG; p_item->i_flags ^= PLAYLIST_DBL_FLAG;
} }
PL_UNLOCK;
pl_Release( p_intf ); pl_Release( p_intf );
UpdateItem( i_popup_item ); UpdateItem( i_popup_item );
} }
......
...@@ -150,8 +150,7 @@ static int vlclua_playlist_goto( lua_State * L ) ...@@ -150,8 +150,7 @@ static int vlclua_playlist_goto( lua_State * L )
PL_LOCK; 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 ) );
PL_UNLOCK; 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 );
...@@ -243,7 +242,7 @@ static int vlclua_playlist_get( lua_State *L ) ...@@ -243,7 +242,7 @@ static int vlclua_playlist_get( lua_State *L )
if( lua_isnumber( L, 1 ) ) if( lua_isnumber( L, 1 ) )
{ {
int i_id = lua_tointeger( L, 1 ); int i_id = lua_tointeger( L, 1 );
p_item = playlist_ItemGetById( p_playlist, i_id, true ); p_item = playlist_ItemGetById( p_playlist, i_id );
if( !p_item ) if( !p_item )
{ {
PL_UNLOCK; PL_UNLOCK;
......
...@@ -315,8 +315,7 @@ void playlist_Clear( playlist_t * p_playlist, bool b_locked ) ...@@ -315,8 +315,7 @@ void playlist_Clear( playlist_t * p_playlist, bool b_locked )
int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id ) int playlist_DeleteFromItemId( playlist_t *p_playlist, int i_id )
{ {
PL_ASSERT_LOCKED; PL_ASSERT_LOCKED;
playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id, playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
pl_Locked );
if( !p_item ) return VLC_EGENERIC; if( !p_item ) return VLC_EGENERIC;
return DeleteInner( p_playlist, p_item, true ); return DeleteInner( p_playlist, p_item, true );
} }
......
...@@ -34,25 +34,21 @@ ...@@ -34,25 +34,21 @@
***************************************************************************/ ***************************************************************************/
/** /**
* Search a playlist item by its playlist_item id * Search a playlist item by its playlist_item id.
* * The playlist have to be locked
* \param p_playlist the playlist * @param p_playlist: the playlist
* \param i_id the id to find * @param i_id: the id to find
* \return the item or NULL on failure * @return the item or NULL on failure
*/ */
playlist_item_t * playlist_ItemGetById( playlist_t * p_playlist , int i_id, playlist_item_t* playlist_ItemGetById( playlist_t * p_playlist , int i_id )
bool b_locked )
{ {
int i; int i;
PL_LOCK_IF( !b_locked ); PL_ASSERT_LOCKED;
ARRAY_BSEARCH( p_playlist->all_items,->i_id, int, i_id, i ); ARRAY_BSEARCH( p_playlist->all_items,->i_id, int, i_id, i );
if( i != -1 ) if( i != -1 )
{
PL_UNLOCK_IF( !b_locked );
return ARRAY_VAL( p_playlist->all_items, i ); return ARRAY_VAL( p_playlist->all_items, i );
} else
PL_UNLOCK_IF( !b_locked ); return NULL;
return NULL;
} }
/** /**
......
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