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

- Fix playlist deadlock between Timer and Playlist stuff

There are still other deadlocks in wx though
parent 2d16a408
/*****************************************************************************
* playlist.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2004 VideoLAN
* Copyright (C) 2000-2005 VideoLAN
* $Id$
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
......@@ -838,7 +838,7 @@ void Playlist::Rebuild( vlc_bool_t b_root )
var_DelCallback( p_playlist, "item-deleted", ItemDeleted, this );
/* ...and rebuild it */
vlc_mutex_lock( &p_playlist->object_lock );
LockPlaylist( p_intf->p_sys, p_playlist );
}
p_view = playlist_ViewFind( p_playlist, i_current_view ); /* FIXME */
......@@ -882,7 +882,7 @@ void Playlist::Rebuild( vlc_bool_t b_root )
var_AddCallback( p_playlist, "item-append", ItemAppended, this );
var_AddCallback( p_playlist, "item-deleted", ItemDeleted, this );
vlc_mutex_unlock( &p_playlist->object_lock );
UnlockPlaylist( p_intf->p_sys, p_playlist );
}
vlc_object_release( p_playlist );
}
......@@ -1066,7 +1066,7 @@ void Playlist::OnSort( wxCommandEvent& event )
{
return;
}
vlc_mutex_lock( &p_playlist->object_lock );
LockPlaylist( p_intf->p_sys, p_playlist );
switch( event.GetId() )
{
case SortTitle_Event:
......@@ -1077,7 +1077,7 @@ void Playlist::OnSort( wxCommandEvent& event )
playlist_RecursiveNodeSort( p_playlist, p_wxitem->p_item,
SORT_TITLE_NODES_FIRST, ORDER_REVERSE );
}
vlc_mutex_unlock( &p_playlist->object_lock );
UnlockPlaylist( p_intf->p_sys, p_playlist );
vlc_object_release( p_playlist );
Rebuild( VLC_TRUE );
......@@ -1557,10 +1557,10 @@ void Playlist::OnPopupSort( wxMenuEvent& event )
if( p_playlist )
{
vlc_mutex_lock( &p_playlist->object_lock );
LockPlaylist( p_intf->p_sys, p_playlist );
playlist_RecursiveNodeSort( p_playlist, p_wxitem->p_item,
SORT_TITLE_NODES_FIRST, ORDER_NORMAL );
vlc_mutex_unlock( &p_playlist->object_lock );
UnlockPlaylist( p_intf->p_sys, p_playlist );
treectrl->DeleteChildren( i_popup_item );
UpdateNodeChildren( p_playlist, p_wxitem->p_item, i_popup_item );
......
/*****************************************************************************
* timer.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2003 VideoLAN
* Copyright (C) 2000-2005 VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
......@@ -120,11 +120,11 @@ void Timer::Notify()
FIND_ANYWHERE );
if( p_playlist != NULL )
{
vlc_mutex_lock( &p_playlist->object_lock );
LockPlaylist( p_intf->p_sys, p_playlist );
p_intf->p_sys->p_input = p_playlist->p_input;
if( p_intf->p_sys->p_input )
vlc_object_yield( p_intf->p_sys->p_input );
vlc_mutex_unlock( &p_playlist->object_lock );
UnlockPlaylist( p_intf->p_sys, p_playlist );
vlc_object_release( p_playlist );
}
......
......@@ -124,6 +124,7 @@ struct intf_sys_t
/* Playlist management */
int i_playing; /* playlist selected item */
unsigned i_playlist_usage;
/* Send an event to show a dialog */
void (*pf_show_dialog) ( intf_thread_t *p_intf, int i_dialog, int i_arg,
......@@ -1083,5 +1084,24 @@ private:
};
} // end of wxvlc namespace
/*
* wxWindows keeps dead locking because the timer tries to lock the playlist
* when it's already locked somewhere else in the very wxWindows interface
* module. Unless someone implements a "vlc_mutex_trylock", we need that.
*/
inline void LockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
{
if( p_sys->i_playlist_usage++ == 0)
vlc_mutex_lock( &p_pl->object_lock );
}
inline void UnlockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
{
if( --p_sys->i_playlist_usage == 0)
vlc_mutex_unlock( &p_pl->object_lock );
}
using namespace wxvlc;
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