// Preparse
p_playlist->p_preparse = vlc_object_create( p_playlist,
sizeof( playlist_preparse_t ) );
- p_playlist->p_preparse->psz_object_name = "preparser";
+ p_playlist->p_preparse->psz_object_name = strdup( "preparser" );
if( !p_playlist->p_preparse )
{
msg_Err( p_playlist, "unable to create preparser" );
vlc_object_attach( p_playlist->p_preparse, p_playlist );
if( vlc_thread_create( p_playlist->p_preparse, "preparser",
- RunPreparse, VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) )
+ RunPreparse, VLC_THREAD_PRIORITY_LOW, true ) )
{
msg_Err( p_playlist, "cannot spawn preparse thread" );
vlc_object_release( p_playlist->p_preparse );
// Secondary Preparse
p_playlist->p_fetcher = vlc_object_create( p_playlist,
sizeof( playlist_fetcher_t ) );
- p_playlist->p_fetcher->psz_object_name = "fetcher";
+ p_playlist->p_fetcher->psz_object_name = strdup( "fetcher" );
if( !p_playlist->p_fetcher )
{
msg_Err( p_playlist, "unable to create secondary preparser" );
if( vlc_thread_create( p_playlist->p_fetcher,
"fetcher",
RunFetcher,
- VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) )
+ VLC_THREAD_PRIORITY_LOW, true ) )
{
msg_Err( p_playlist, "cannot spawn secondary preparse thread" );
vlc_object_release( p_playlist->p_fetcher );
// Start the thread
if( vlc_thread_create( p_playlist, "playlist", RunControlThread,
- VLC_THREAD_PRIORITY_LOW, VLC_TRUE ) )
+ VLC_THREAD_PRIORITY_LOW, true ) )
{
msg_Err( p_playlist, "cannot spawn playlist thread" );
vlc_object_release( p_playlist );
*/
static void RunControlThread ( playlist_t *p_playlist )
{
- int i_loops = 0;
-
/* Tell above that we're ready */
vlc_thread_ready( p_playlist );
- while( !p_playlist->b_die )
- {
- i_loops++;
+ vlc_object_lock( p_playlist );
+ while( vlc_object_alive( p_playlist ) )
+ {
+ PL_UNLOCK;
playlist_MainLoop( p_playlist );
+ PL_LOCK;
+
+ /* The playlist lock has been unlocked, so we can't tell if
+ * someone has killed us in the meantime. Check now. */
+ if( !vlc_object_alive( p_playlist ) )
+ break;
+
if( p_playlist->b_cant_sleep )
{
/* 100 ms is an acceptable delay for playlist operations */
+ PL_UNLOCK;
msleep( INTF_IDLE_SLEEP*2 );
+ PL_LOCK;
}
else
{
- PL_LOCK;
- vlc_cond_wait( &p_playlist->object_wait, &p_playlist->object_lock );
- PL_UNLOCK;
+ vlc_object_wait( p_playlist );
}
}
+ vlc_object_unlock( p_playlist );
+
playlist_LastLoop( p_playlist );
}