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

Don't start the playlist thread if not needed

parent bbb25382
...@@ -255,11 +255,11 @@ enum pl_locked_state ...@@ -255,11 +255,11 @@ enum pl_locked_state
#define PL_UNLOCK playlist_Unlock( p_playlist ) #define PL_UNLOCK playlist_Unlock( p_playlist )
#define PL_ASSERT_LOCKED playlist_AssertLocked( p_playlist ) #define PL_ASSERT_LOCKED playlist_AssertLocked( p_playlist )
VLC_EXPORT( playlist_t *, __pl_Hold, ( vlc_object_t * ) ); VLC_EXPORT( playlist_t *, pl_Hold, ( vlc_object_t * ) );
#define pl_Hold( a ) __pl_Hold( VLC_OBJECT(a) ) #define pl_Hold( a ) pl_Hold( VLC_OBJECT(a) )
VLC_EXPORT( void, __pl_Release, ( vlc_object_t * ) ); VLC_EXPORT( void, pl_Release, ( vlc_object_t * ) );
#define pl_Release(a) __pl_Release( VLC_OBJECT(a) ) #define pl_Release(a) pl_Release( VLC_OBJECT(a) )
/* Playlist control */ /* Playlist control */
#define playlist_Play(p) playlist_Control(p,PLAYLIST_PLAY, pl_Unlocked ) #define playlist_Play(p) playlist_Control(p,PLAYLIST_PLAY, pl_Unlocked )
......
...@@ -804,7 +804,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -804,7 +804,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
module_EndBank( p_libvlc, true ); module_EndBank( p_libvlc, true );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
playlist_Activate( p_playlist );
/* Add service discovery modules */ /* Add service discovery modules */
psz_modules = var_InheritString( p_libvlc, "services-discovery" ); psz_modules = var_InheritString( p_libvlc, "services-discovery" );
...@@ -987,11 +986,11 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -987,11 +986,11 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
void libvlc_InternalCleanup( libvlc_int_t *p_libvlc ) void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
{ {
libvlc_priv_t *priv = libvlc_priv (p_libvlc); libvlc_priv_t *priv = libvlc_priv (p_libvlc);
playlist_t *p_playlist = priv->p_playlist; playlist_t *p_playlist = libvlc_priv (p_libvlc)->p_playlist;
/* Deactivate the playlist */ /* Deactivate the playlist */
msg_Dbg( p_libvlc, "deactivating the playlist" ); msg_Dbg( p_libvlc, "deactivating the playlist" );
playlist_Deactivate( p_playlist ); pl_Deactivate( p_libvlc );
/* Remove all services discovery */ /* Remove all services discovery */
msg_Dbg( p_libvlc, "removing all services discovery tasks" ); msg_Dbg( p_libvlc, "removing all services discovery tasks" );
...@@ -1010,13 +1009,8 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc ) ...@@ -1010,13 +1009,8 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
} }
#endif #endif
/* Free playlist */ /* Free playlist now */
/* Any thread still running must not assume pl_Hold() succeeds. */
msg_Dbg( p_libvlc, "removing playlist" ); msg_Dbg( p_libvlc, "removing playlist" );
libvlc_priv(p_libvlc)->p_playlist = NULL;
barrier(); /* FIXME is that correct ? */
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
stats_TimersDumpAll( p_libvlc ); stats_TimersDumpAll( p_libvlc );
......
...@@ -206,6 +206,7 @@ typedef struct libvlc_priv_t ...@@ -206,6 +206,7 @@ typedef struct libvlc_priv_t
libvlc_int_t public_data; libvlc_int_t public_data;
int i_last_input_id ; ///< Last id of input item int i_last_input_id ; ///< Last id of input item
bool playlist_active;
/* Messages */ /* Messages */
msg_bank_t msg_bank; ///< The message bank msg_bank_t msg_bank; ///< The message bank
......
...@@ -343,8 +343,8 @@ playlist_Status ...@@ -343,8 +343,8 @@ playlist_Status
playlist_TreeMove playlist_TreeMove
playlist_TreeMoveMany playlist_TreeMoveMany
playlist_Unlock playlist_Unlock
__pl_Hold pl_Hold
__pl_Release pl_Release
resolve_xml_special_chars resolve_xml_special_chars
sdp_AddAttribute sdp_AddAttribute
sdp_AddMedia sdp_AddMedia
......
...@@ -39,22 +39,34 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args ...@@ -39,22 +39,34 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
* Playlist control * Playlist control
*****************************************************************************/ *****************************************************************************/
playlist_t *__pl_Hold( vlc_object_t *p_this ) static vlc_mutex_t global_lock = VLC_STATIC_MUTEX;
#undef pl_Hold
playlist_t *pl_Hold (vlc_object_t *obj)
{ {
playlist_t *pl; playlist_t *pl;
libvlc_int_t *p_libvlc = obj->p_libvlc;
barrier(); vlc_mutex_lock (&global_lock);
pl = libvlc_priv (p_this->p_libvlc)->p_playlist; pl = libvlc_priv (p_libvlc)->p_playlist;
assert (pl != NULL);
assert( VLC_OBJECT(pl) != p_this /* This does not make sense to hold the playlist if (!libvlc_priv (p_libvlc)->playlist_active)
using pl_Hold. use vlc_object_hold in this case */ ); {
playlist_Activate (pl);
libvlc_priv (p_libvlc)->playlist_active = true;
}
/* The playlist should hold itself with vlc_object_hold() if ever. */
assert (VLC_OBJECT (pl) != obj);
if (pl) if (pl)
vlc_object_hold (pl); vlc_object_hold (pl);
vlc_mutex_unlock (&global_lock);
return pl; return pl;
} }
void __pl_Release( vlc_object_t *p_this ) #undef pl_Release
void pl_Release( vlc_object_t *p_this )
{ {
playlist_t *pl = libvlc_priv (p_this->p_libvlc)->p_playlist; playlist_t *pl = libvlc_priv (p_this->p_libvlc)->p_playlist;
assert( pl != NULL ); assert( pl != NULL );
...@@ -66,6 +78,14 @@ void __pl_Release( vlc_object_t *p_this ) ...@@ -66,6 +78,14 @@ void __pl_Release( vlc_object_t *p_this )
vlc_object_release( pl ); vlc_object_release( pl );
} }
void pl_Deactivate (libvlc_int_t *p_libvlc)
{
vlc_mutex_lock (&global_lock);
if (libvlc_priv (p_libvlc)->playlist_active)
playlist_Deactivate (libvlc_priv (p_libvlc)->p_playlist);
vlc_mutex_unlock (&global_lock);
}
void playlist_Lock( playlist_t *pl ) void playlist_Lock( playlist_t *pl )
{ {
vlc_mutex_lock( &pl_priv(pl)->lock ); vlc_mutex_lock( &pl_priv(pl)->lock );
......
...@@ -105,6 +105,7 @@ playlist_t *playlist_Create( vlc_object_t * ); ...@@ -105,6 +105,7 @@ playlist_t *playlist_Create( vlc_object_t * );
/* */ /* */
void playlist_Activate( playlist_t * ); void playlist_Activate( playlist_t * );
void playlist_Deactivate( playlist_t * ); void playlist_Deactivate( playlist_t * );
void pl_Deactivate (libvlc_int_t *);
/* */ /* */
playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist, playlist_item_t *playlist_ItemNewFromInput( playlist_t *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