[vlc-devel] commit: Create preparser and fetcher immediately ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue Feb 9 20:22:30 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Feb  9 18:38:16 2010 +0200| [14ee5f1254c0aa7cb2e4c01a99fd4d61b009f7e9] | committer: Rémi Denis-Courmont 

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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=14ee5f1254c0aa7cb2e4c01a99fd4d61b009f7e9
---

 src/libvlc.c                     |    5 ++---
 src/playlist/engine.c            |   28 ++++++++++++++++++++++++++--
 src/playlist/playlist_internal.h |    1 +
 src/playlist/thread.c            |   23 -----------------------
 4 files changed, 29 insertions(+), 28 deletions(-)

diff --git a/src/libvlc.c b/src/libvlc.c
index 4c033fe..91e16cb 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -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 );
diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index 379412e..26bc7ee 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -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 );
diff --git a/src/playlist/playlist_internal.h b/src/playlist/playlist_internal.h
index 1d00567..959b8e3 100644
--- a/src/playlist/playlist_internal.h
+++ b/src/playlist/playlist_internal.h
@@ -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 * );
diff --git a/src/playlist/thread.c b/src/playlist/thread.c
index 9d42c3f..ee29e32 100644
--- a/src/playlist/thread.c
+++ b/src/playlist/thread.c
@@ -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 );




More information about the vlc-devel mailing list