Commit 14ee5f12 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

Create preparser and fetcher immediately

They do not create threads anymore (unless they have work to do).

LibVLC needs this because we are sloppy programmers^W^W^W^Wit still
depends on the playlist for item meta infos (it should probably
instantiate the fetcher and preparser directly).

Also, do not create the preparser if there is no fetcher.
parent fdabacb8
......@@ -1015,9 +1015,8 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
}
#endif
/* Free playlist now */
msg_Dbg( p_libvlc, "removing playlist" );
vlc_object_release( p_playlist );
/* Free playlist now, all threads are gone */
playlist_Destroy( p_playlist );
stats_TimersDumpAll( p_libvlc );
stats_TimersCleanAll( p_libvlc );
......
......@@ -105,6 +105,20 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
pl_priv(p_playlist)->b_auto_preparse =
var_InheritBool( p_parent, "auto-preparse" );
/* Fetcher */
p->p_fetcher = playlist_fetcher_New( p_playlist );
if( unlikely(p->p_fetcher == NULL) )
{
msg_Err( p_playlist, "cannot create fetcher" );
p->p_preparser = NULL;
}
else
{ /* Preparse */
p->p_preparser = playlist_preparser_New( p_playlist, p->p_fetcher );
if( unlikely(p->p_preparser == NULL) )
msg_Err( p_playlist, "cannot create preparser" );
}
/* Create the root node */
PL_LOCK;
p_playlist->p_root = playlist_NodeCreate( p_playlist, NULL, NULL,
......@@ -165,6 +179,18 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
return p_playlist;
}
void playlist_Destroy( playlist_t *p_playlist )
{
playlist_private_t *p_sys = pl_priv(p_playlist);
msg_Dbg( p_playlist, "destroying" );
if( p_sys->p_preparser )
playlist_preparser_Delete( p_sys->p_preparser );
if( p_sys->p_fetcher )
playlist_fetcher_Delete( p_sys->p_fetcher );
vlc_object_release( p_playlist );
}
/**
* Destroy playlist
*
......@@ -180,8 +206,6 @@ static void playlist_Destructor( vlc_object_t * p_this )
assert( !p_sys->p_input );
assert( !p_sys->p_input_resource );
assert( !p_sys->p_preparser );
assert( !p_sys->p_fetcher );
vlc_cond_destroy( &p_sys->signal );
vlc_mutex_destroy( &p_sys->lock );
......
......@@ -101,6 +101,7 @@ typedef struct playlist_private_t
/* Creation/Deletion */
playlist_t *playlist_Create( vlc_object_t * );
void playlist_Destroy( playlist_t * );
/* */
void playlist_Activate( playlist_t * );
......
......@@ -57,16 +57,6 @@ void playlist_Activate( playlist_t *p_playlist )
/* */
playlist_private_t *p_sys = pl_priv(p_playlist);
/* Fetcher */
p_sys->p_fetcher = playlist_fetcher_New( p_playlist );
if( !p_sys->p_fetcher )
msg_Err( p_playlist, "cannot create playlist fetcher" );
/* Preparse */
p_sys->p_preparser = playlist_preparser_New( p_playlist, p_sys->p_fetcher );
if( !p_sys->p_preparser )
msg_Err( p_playlist, "cannot create playlist preparser" );
/* Start the playlist thread */
if( vlc_clone( &p_sys->thread, Thread, p_playlist,
VLC_THREAD_PRIORITY_LOW ) )
......@@ -91,19 +81,6 @@ void playlist_Deactivate( playlist_t *p_playlist )
vlc_join( p_sys->thread, NULL );
assert( !p_sys->p_input );
PL_LOCK;
playlist_preparser_t *p_preparser = p_sys->p_preparser;
playlist_fetcher_t *p_fetcher = p_sys->p_fetcher;
p_sys->p_preparser = NULL;
p_sys->p_fetcher = NULL;
PL_UNLOCK;
if( p_preparser )
playlist_preparser_Delete( p_preparser );
if( p_fetcher )
playlist_fetcher_Delete( p_fetcher );
/* release input resources */
if( p_sys->p_input_resource )
input_resource_Delete( p_sys->p_input_resource );
......
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