[vlc-commits] playlist: hide fetcher underneath the preparser and simplify

Rémi Denis-Courmont git at videolan.org
Tue Dec 31 19:45:11 CET 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Dec 31 19:55:53 2013 +0200| [99a19a8f45c1e2b5bfcbfbcd5db8f101133dcf2c] | committer: Rémi Denis-Courmont

playlist: hide fetcher underneath the preparser and simplify

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

 src/playlist/control.c           |    5 ++---
 src/playlist/engine.c            |   11 ++---------
 src/playlist/playlist_internal.h |    2 --
 src/playlist/preparser.c         |   18 +++++++++++++++---
 src/playlist/preparser.h         |    5 +++--
 5 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/src/playlist/control.c b/src/playlist/control.c
index 5df9283..7d6791b 100644
--- a/src/playlist/control.c
+++ b/src/playlist/control.c
@@ -179,9 +179,8 @@ int playlist_AskForArtEnqueue( playlist_t *p_playlist, input_item_t *p_item )
 {
     playlist_private_t *p_sys = pl_priv(p_playlist);
 
-    if( unlikely(p_sys->p_fetcher == NULL) )
+    if( unlikely(p_sys->p_preparser == NULL) )
         return VLC_ENOMEM;
-    playlist_fetcher_Push( p_sys->p_fetcher, p_item );
+    playlist_preparser_fetcher_Push( p_sys->p_preparser, p_item );
     return VLC_SUCCESS;
 }
-
diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index 8207c79..9aeaf1b 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -233,13 +233,8 @@ static 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( VLC_OBJECT(p_playlist) );
-    if( unlikely(p->p_fetcher == NULL) )
-        msg_Err( p_playlist, "cannot create fetcher" );
-   /* Preparser */
-   p->p_preparser = playlist_preparser_New( VLC_OBJECT(p_playlist),
-                                            p->p_fetcher );
+   /* Preparser (and meta retriever) */
+   p->p_preparser = playlist_preparser_New( VLC_OBJECT(p_playlist) );
    if( unlikely(p->p_preparser == NULL) )
        msg_Err( p_playlist, "cannot create preparser" );
 
@@ -341,8 +336,6 @@ void playlist_Destroy( playlist_t *p_playlist )
     playlist_Deactivate( p_playlist );
     if( p_sys->p_preparser )
         playlist_preparser_Delete( p_sys->p_preparser );
-    if( p_sys->p_fetcher )
-        playlist_fetcher_Delete( p_sys->p_fetcher );
 
     /* Release input resources */
     assert( p_sys->p_input == NULL );
diff --git a/src/playlist/playlist_internal.h b/src/playlist/playlist_internal.h
index 9b6c000..936a51d 100644
--- a/src/playlist/playlist_internal.h
+++ b/src/playlist/playlist_internal.h
@@ -38,7 +38,6 @@
 #include <assert.h>
 
 #include "art.h"
-#include "fetcher.h"
 #include "preparser.h"
 
 typedef struct vlc_sd_internal_t vlc_sd_internal_t;
@@ -47,7 +46,6 @@ typedef struct playlist_private_t
 {
     playlist_t           public_data;
     playlist_preparser_t *p_preparser;  /**< Preparser data */
-    playlist_fetcher_t   *p_fetcher;    /**< Meta and art fetcher data */
 
     playlist_item_array_t items_to_delete; /**< Array of items and nodes to
             delete... At the very end. This sucks. */
diff --git a/src/playlist/preparser.c b/src/playlist/preparser.c
index 72e0a12..505cece 100644
--- a/src/playlist/preparser.c
+++ b/src/playlist/preparser.c
@@ -56,15 +56,17 @@ static void *Thread( void * );
 /*****************************************************************************
  * Public functions
  *****************************************************************************/
-playlist_preparser_t *playlist_preparser_New( vlc_object_t *parent,
-                                              playlist_fetcher_t *p_fetcher )
+playlist_preparser_t *playlist_preparser_New( vlc_object_t *parent )
 {
     playlist_preparser_t *p_preparser = malloc( sizeof(*p_preparser) );
     if( !p_preparser )
         return NULL;
 
     p_preparser->object = parent;
-    p_preparser->p_fetcher = p_fetcher;
+    p_preparser->p_fetcher = playlist_fetcher_New( parent );
+    if( unlikely(p_preparser->p_fetcher == NULL) )
+        msg_Err( parent, "cannot create fetcher" );
+
     vlc_mutex_init( &p_preparser->lock );
     vlc_cond_init( &p_preparser->wait );
     p_preparser->b_live = false;
@@ -93,6 +95,13 @@ void playlist_preparser_Push( playlist_preparser_t *p_preparser, input_item_t *p
     vlc_mutex_unlock( &p_preparser->lock );
 }
 
+void playlist_preparser_fetcher_Push( playlist_preparser_t *p_preparser,
+                                      input_item_t *p_item )
+{
+    if( p_preparser->p_fetcher != NULL )
+        playlist_fetcher_Push( p_preparser->p_fetcher, p_item );
+}
+
 void playlist_preparser_Delete( playlist_preparser_t *p_preparser )
 {
     vlc_mutex_lock( &p_preparser->lock );
@@ -110,6 +119,9 @@ void playlist_preparser_Delete( playlist_preparser_t *p_preparser )
     /* Destroy the item preparser */
     vlc_cond_destroy( &p_preparser->wait );
     vlc_mutex_destroy( &p_preparser->lock );
+
+    if( p_preparser->p_fetcher != NULL )
+        playlist_fetcher_Delete( p_preparser->p_fetcher );
     free( p_preparser );
 }
 
diff --git a/src/playlist/preparser.h b/src/playlist/preparser.h
index 0fecead..1d298c7 100644
--- a/src/playlist/preparser.h
+++ b/src/playlist/preparser.h
@@ -37,8 +37,7 @@ typedef struct playlist_preparser_t playlist_preparser_t;
 /**
  * This function creates the preparser object and thread.
  */
-playlist_preparser_t *playlist_preparser_New( vlc_object_t *,
-                                              playlist_fetcher_t * );
+playlist_preparser_t *playlist_preparser_New( vlc_object_t * );
 
 /**
  * This function enqueues the provided item to be preparsed.
@@ -48,6 +47,8 @@ playlist_preparser_t *playlist_preparser_New( vlc_object_t *,
  */
 void playlist_preparser_Push( playlist_preparser_t *, input_item_t * );
 
+void playlist_preparser_fetcher_Push( playlist_preparser_t *, input_item_t * );
+
 /**
  * This function destroys the preparser object and thread.
  *



More information about the vlc-commits mailing list