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

Use a custom condition variable for the playlist engine

parent 262e789e
...@@ -176,7 +176,7 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args ...@@ -176,7 +176,7 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
msg_Err( p_playlist, "unknown playlist query" ); msg_Err( p_playlist, "unknown playlist query" );
return VLC_EBADVAR; return VLC_EBADVAR;
} }
vlc_object_signal_unlocked( p_playlist ); vlc_cond_signal( &pl_priv(p_playlist)->signal );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -49,7 +49,7 @@ static int RandomCallback( vlc_object_t *p_this, char const *psz_cmd, ...@@ -49,7 +49,7 @@ static int RandomCallback( vlc_object_t *p_this, char const *psz_cmd,
PL_LOCK; PL_LOCK;
pl_priv(p_playlist)->b_reset_currently_playing = true; pl_priv(p_playlist)->b_reset_currently_playing = true;
vlc_object_signal_unlocked( p_playlist ); vlc_cond_signal( &pl_priv(p_playlist)->signal );
PL_UNLOCK; PL_UNLOCK;
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -81,6 +81,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent ) ...@@ -81,6 +81,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
libvlc_priv(p_parent->p_libvlc)->p_playlist = p_playlist; libvlc_priv(p_parent->p_libvlc)->p_playlist = p_playlist;
VariablesInit( p_playlist ); VariablesInit( p_playlist );
vlc_cond_init( &p->signal );
/* Initialise data structures */ /* Initialise data structures */
pl_priv(p_playlist)->i_last_playlist_id = 0; pl_priv(p_playlist)->i_last_playlist_id = 0;
...@@ -179,6 +180,7 @@ static void playlist_Destructor( vlc_object_t * p_this ) ...@@ -179,6 +180,7 @@ static void playlist_Destructor( vlc_object_t * p_this )
assert( !p_sys->p_preparser ); assert( !p_sys->p_preparser );
assert( !p_sys->p_fetcher ); assert( !p_sys->p_fetcher );
vlc_cond_destroy( &p_sys->signal );
msg_Dbg( p_this, "Destroyed" ); msg_Dbg( p_this, "Destroyed" );
} }
......
...@@ -635,7 +635,7 @@ playlist_item_t *playlist_ItemToNode( playlist_t *p_playlist, ...@@ -635,7 +635,7 @@ playlist_item_t *playlist_ItemToNode( playlist_t *p_playlist,
p_playlist->p_root_onelevel, false ); p_playlist->p_root_onelevel, false );
} }
pl_priv(p_playlist)->b_reset_currently_playing = true; pl_priv(p_playlist)->b_reset_currently_playing = true;
vlc_object_signal_unlocked( p_playlist ); vlc_cond_signal( &pl_priv(p_playlist)->signal );
var_SetInteger( p_playlist, "item-change", p_item_in_category-> var_SetInteger( p_playlist, "item-change", p_item_in_category->
p_input->i_id ); p_input->i_id );
PL_UNLOCK_IF( !b_locked ); PL_UNLOCK_IF( !b_locked );
...@@ -772,7 +772,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item, ...@@ -772,7 +772,7 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
else else
i_ret = TreeMove( p_playlist, p_item, p_node, i_newpos ); i_ret = TreeMove( p_playlist, p_item, p_node, i_newpos );
pl_priv(p_playlist)->b_reset_currently_playing = true; pl_priv(p_playlist)->b_reset_currently_playing = true;
vlc_object_signal_unlocked( p_playlist ); vlc_cond_signal( &pl_priv(p_playlist)->signal );
return i_ret; return i_ret;
} }
...@@ -800,7 +800,7 @@ void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id, ...@@ -800,7 +800,7 @@ void playlist_SendAddNotify( playlist_t *p_playlist, int i_item_id,
val.p_address = p_add; val.p_address = p_add;
pl_priv(p_playlist)->b_reset_currently_playing = true; pl_priv(p_playlist)->b_reset_currently_playing = true;
if( b_signal ) if( b_signal )
vlc_object_signal_unlocked( p_playlist ); vlc_cond_signal( &pl_priv(p_playlist)->signal );
var_Set( p_playlist, "item-append", val ); var_Set( p_playlist, "item-append", val );
free( p_add ); free( p_add );
...@@ -839,7 +839,7 @@ static void GoAndPreparse( playlist_t *p_playlist, int i_mode, ...@@ -839,7 +839,7 @@ static void GoAndPreparse( playlist_t *p_playlist, int i_mode,
if( pl_priv(p_playlist)->p_input ) if( pl_priv(p_playlist)->p_input )
input_StopThread( pl_priv(p_playlist)->p_input ); input_StopThread( pl_priv(p_playlist)->p_input );
pl_priv(p_playlist)->request.i_status = PLAYLIST_RUNNING; pl_priv(p_playlist)->request.i_status = PLAYLIST_RUNNING;
vlc_object_signal_unlocked( p_playlist ); vlc_cond_signal( &pl_priv(p_playlist)->signal );
} }
/* Preparse if PREPARSE or SPREPARSE & not enough meta */ /* Preparse if PREPARSE or SPREPARSE & not enough meta */
char *psz_artist = input_item_GetArtist( p_item_cat->p_input ); char *psz_artist = input_item_GetArtist( p_item_cat->p_input );
...@@ -922,7 +922,7 @@ static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item, ...@@ -922,7 +922,7 @@ static int DeleteInner( playlist_t * p_playlist, playlist_item_t *p_item,
pl_priv(p_playlist)->request.b_request = true; pl_priv(p_playlist)->request.b_request = true;
pl_priv(p_playlist)->request.p_item = NULL; pl_priv(p_playlist)->request.p_item = NULL;
msg_Info( p_playlist, "stopping playback" ); msg_Info( p_playlist, "stopping playback" );
vlc_object_signal_unlocked( VLC_OBJECT(p_playlist) ); vlc_cond_signal( &pl_priv(p_playlist)->signal );
} }
} }
......
...@@ -82,6 +82,8 @@ typedef struct playlist_private_t ...@@ -82,6 +82,8 @@ typedef struct playlist_private_t
vlc_mutex_t lock; /**< Lock to protect request */ vlc_mutex_t lock; /**< Lock to protect request */
} request; } request;
vlc_cond_t signal; /**< wakes up the playlist engine thread */
int i_last_playlist_id; /**< Last id to an item */ int i_last_playlist_id; /**< Last id to an item */
bool b_reset_currently_playing; /** Reset current item array */ bool b_reset_currently_playing; /** Reset current item array */
......
...@@ -173,6 +173,6 @@ int playlist_LiveSearchUpdate( playlist_t *p_playlist, playlist_item_t *p_root, ...@@ -173,6 +173,6 @@ int playlist_LiveSearchUpdate( playlist_t *p_playlist, playlist_item_t *p_root,
PL_ASSERT_LOCKED; PL_ASSERT_LOCKED;
pl_priv(p_playlist)->b_reset_currently_playing = true; pl_priv(p_playlist)->b_reset_currently_playing = true;
playlist_LiveSearchUpdateInternal( p_playlist, p_root, psz_string ); playlist_LiveSearchUpdateInternal( p_playlist, p_root, psz_string );
vlc_object_signal_unlocked( p_playlist ); vlc_cond_signal( &pl_priv(p_playlist)->signal );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -82,6 +82,10 @@ void playlist_Deactivate( playlist_t *p_playlist ) ...@@ -82,6 +82,10 @@ void playlist_Deactivate( playlist_t *p_playlist )
msg_Dbg( p_playlist, "Deactivate" ); msg_Dbg( p_playlist, "Deactivate" );
vlc_object_kill( p_playlist ); vlc_object_kill( p_playlist );
PL_LOCK;
vlc_cond_signal( &p_sys->signal );
PL_UNLOCK;
vlc_thread_join( p_playlist ); vlc_thread_join( p_playlist );
assert( !p_sys->p_input ); assert( !p_sys->p_input );
...@@ -150,7 +154,8 @@ static int InputEvent( vlc_object_t *p_this, char const *psz_cmd, ...@@ -150,7 +154,8 @@ static int InputEvent( vlc_object_t *p_this, char const *psz_cmd,
PL_LOCK; PL_LOCK;
vlc_object_signal_unlocked( p_playlist ); /* XXX: signaling while not changing any parameter... suspicious... */
vlc_cond_signal( &pl_priv(p_playlist)->signal );
PL_UNLOCK; PL_UNLOCK;
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -548,7 +553,8 @@ static void LoopRequest( playlist_t *p_playlist ) ...@@ -548,7 +553,8 @@ static void LoopRequest( playlist_t *p_playlist )
input_ressource_TerminateVout( p_sys->p_input_ressource ); input_ressource_TerminateVout( p_sys->p_input_ressource );
if( vlc_object_alive( p_playlist ) ) if( vlc_object_alive( p_playlist ) )
vlc_object_wait( p_playlist ); vlc_cond_wait( &pl_priv(p_playlist)->signal,
&vlc_internals(p_playlist)->lock );
return; return;
} }
...@@ -593,7 +599,8 @@ static void *Thread ( vlc_object_t *p_this ) ...@@ -593,7 +599,8 @@ static void *Thread ( vlc_object_t *p_this )
/* If there is an input, check that it doesn't need to die. */ /* If there is an input, check that it doesn't need to die. */
while( !LoopInput( p_playlist ) ) while( !LoopInput( p_playlist ) )
vlc_object_wait( p_playlist ); vlc_cond_wait( &pl_priv(p_playlist)->signal,
&vlc_internals(p_playlist)->lock );
LoopRequest( p_playlist ); LoopRequest( 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