]> git.sesse.net Git - vlc/commitdiff
Create preparser and fetcher immediately
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 9 Feb 2010 16:38:16 +0000 (18:38 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 9 Feb 2010 19:14:26 +0000 (21:14 +0200)
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.

src/libvlc.c
src/playlist/engine.c
src/playlist/playlist_internal.h
src/playlist/thread.c

index 4c033fe80cb1fb4353b85086085cbcd1bd2f726b..91e16cb65cdb733320e343e9b4dd4914c8d3949d 100644 (file)
@@ -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 );
index 379412ece5007a212e230fad2b5f5d8edf9ab681..26bc7ee4e36e0c81c829670af2c883297231c173 100644 (file)
@@ -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 );
index 1d00567652bb2d6a848d4647d275927d1a8065f7..959b8e3d9f1bf5cbd52e37be480fb131f187dd98 100644 (file)
@@ -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 * );
index 9d42c3fedb774bc6a6612f8f94e765d2efba1071..ee29e32bc35e9c61069db42a75700ec70a2c0253 100644 (file)
@@ -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 );