Commit 5e5bf285 authored by Gildas Bazin's avatar Gildas Bazin

* include/vlc_playlist.h, src/playlist/playlist.c,...

* include/vlc_playlist.h, src/playlist/playlist.c, src/video_output/video_output.c: added a lock to the playlist garbage collector to avoid a race condition with the vout creation/destruction.
parent 1bd3ab7f
......@@ -210,6 +210,8 @@ struct playlist_t
playlist_preparse_t *p_preparse;
vlc_mutex_t gc_lock; /**< Lock to protect the garbage collection */
/*@}*/
};
......
......@@ -107,6 +107,7 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
var_CreateGetBool( p_playlist, "loop" );
/* Initialise data structures */
vlc_mutex_init( p_playlist, &p_playlist->gc_lock );
p_playlist->i_last_id = 0;
p_playlist->b_go_next = VLC_TRUE;
p_playlist->p_input = NULL;
......@@ -127,8 +128,9 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent )
p_view = playlist_ViewFind( p_playlist, VIEW_CATEGORY );
p_playlist->p_general = playlist_NodeCreate( p_playlist, VIEW_CATEGORY,
_( "General" ), p_view->p_root );
p_playlist->p_general =
playlist_NodeCreate( p_playlist, VIEW_CATEGORY,
_( "General" ), p_view->p_root );
p_playlist->p_general->i_flags |= PLAYLIST_RO_FLAG;
/* Set startup status
......@@ -228,6 +230,7 @@ int playlist_Destroy( playlist_t * p_playlist )
free( p_view );
}
vlc_mutex_destroy( &p_playlist->gc_lock );
vlc_object_destroy( p_playlist->p_preparse );
vlc_object_destroy( p_playlist );
......@@ -451,6 +454,7 @@ static mtime_t ObjectGarbageCollector( playlist_t *p_playlist, int i_type,
}
else
{
vlc_mutex_lock( &p_playlist->gc_lock );
while( ( p_obj = vlc_object_find( p_playlist, i_type, FIND_CHILD ) ) )
{
if( p_obj->p_parent != (vlc_object_t*)p_playlist )
......@@ -472,6 +476,7 @@ static mtime_t ObjectGarbageCollector( playlist_t *p_playlist, int i_type,
sout_DeleteInstance( (sout_instance_t*)p_obj );
}
}
vlc_mutex_unlock( &p_playlist->gc_lock );
return 0;
}
}
......
......@@ -41,6 +41,7 @@
#include "video_output.h"
#include "vlc_spu.h"
#include <vlc/input.h> /* for input_thread_t and i_pts_delay */
#include "vlc_playlist.h"
#if defined( SYS_DARWIN )
#include "darwin_specific.h"
......@@ -117,12 +118,13 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
if( !p_vout )
{
vlc_object_t *p_playlist;
playlist_t *p_playlist;
p_playlist = vlc_object_find( p_this,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist )
{
vlc_mutex_lock( &p_playlist->gc_lock );
p_vout = vlc_object_find( p_playlist,
VLC_OBJECT_VOUT, FIND_CHILD );
/* only first children of p_input for unused vout */
......@@ -131,6 +133,7 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
vlc_object_release( p_vout );
p_vout = NULL;
}
vlc_mutex_unlock( &p_playlist->gc_lock );
vlc_object_release( p_playlist );
}
}
......
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