playlist: Fetcher and parser are playlist private.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Sun, 31 Aug 2008 08:38:56 +0000 (10:38 +0200)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Sun, 31 Aug 2008 08:38:56 +0000 (10:38 +0200)
include/vlc_playlist.h
src/input/meta.c
src/playlist/control.c
src/playlist/engine.c
src/playlist/playlist_internal.h
src/playlist/thread.c

index 54e457c..d11f65d 100644 (file)
@@ -153,6 +153,8 @@ struct playlist_item_t
 typedef enum
 { PLAYLIST_STOPPED,PLAYLIST_RUNNING,PLAYLIST_PAUSED } playlist_status_t;
 
+typedef struct playlist_private_t playlist_private_t;
+
 /** Structure containing information about the playlist */
 struct playlist_t
 {
@@ -200,8 +202,6 @@ struct playlist_t
     int                   i_order; /**< Last ordering applied to the playlist */
     mtime_t               gc_date;
     bool            b_cant_sleep;
-    playlist_preparse_t  *p_preparse; /**< Preparser object */
-    playlist_fetcher_t   *p_fetcher;/**< Meta and art fetcher object */
 
     struct {
         /* Current status. These fields are readonly, only the playlist
@@ -224,6 +224,10 @@ struct playlist_t
                                            when processing the request */
         vlc_mutex_t         lock;     /**< Lock to protect request */
     } request;
+
+    /* All other data is PRIVATE. You can't access it
+     * outside of src/input */
+    playlist_private_t *p;
 };
 
 /** Helper to add an item */
index 402c991..d2fd27e 100644 (file)
@@ -99,7 +99,7 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
     /* If we already checked this album in this session, skip */
     if( psz_artist && psz_album )
     {
-        FOREACH_ARRAY( playlist_album_t album, p_playlist->p_fetcher->albums )
+        FOREACH_ARRAY( playlist_album_t album, p_playlist->p->p_fetcher->albums )
             if( !strcmp( album.psz_artist, psz_artist ) &&
                 !strcmp( album.psz_album, psz_album ) )
             {
@@ -179,7 +179,7 @@ int input_ArtFind( playlist_t *p_playlist, input_item_t *p_item )
         a.psz_album = psz_album;
         a.psz_arturl = input_item_GetArtURL( p_item );
         a.b_found = (i_ret == VLC_EGENERIC ? false : true );
-        ARRAY_APPEND( p_playlist->p_fetcher->albums, a );
+        ARRAY_APPEND( p_playlist->p->p_fetcher->albums, a );
     }
     else
     {
index 3e2abc4..d2dff95 100644 (file)
@@ -190,19 +190,19 @@ static int PlaylistVAControl( playlist_t * p_playlist, int i_query, va_list args
 int playlist_PreparseEnqueue( playlist_t *p_playlist,
                               input_item_t *p_item )
 {
-    vlc_object_lock( p_playlist->p_preparse );
-    if( !vlc_object_alive( p_playlist->p_preparse ) )
+    vlc_object_lock( p_playlist->p->p_preparse );
+    if( !vlc_object_alive( p_playlist->p->p_preparse ) )
     {
-        vlc_object_unlock( p_playlist->p_preparse );
+        vlc_object_unlock( p_playlist->p->p_preparse );
         return VLC_EGENERIC;
     }
     vlc_gc_incref( p_item );
-    INSERT_ELEM( p_playlist->p_preparse->pp_waiting,
-                 p_playlist->p_preparse->i_waiting,
-                 p_playlist->p_preparse->i_waiting,
+    INSERT_ELEM( p_playlist->p->p_preparse->pp_waiting,
+                 p_playlist->p->p_preparse->i_waiting,
+                 p_playlist->p->p_preparse->i_waiting,
                  p_item );
-    vlc_object_signal_unlocked( p_playlist->p_preparse );
-    vlc_object_unlock( p_playlist->p_preparse );
+    vlc_object_signal_unlocked( p_playlist->p->p_preparse );
+    vlc_object_unlock( p_playlist->p->p_preparse );
     return VLC_SUCCESS;
 }
 
@@ -212,15 +212,15 @@ int playlist_PreparseEnqueueItem( playlist_t *p_playlist,
                                   playlist_item_t *p_item )
 {
     vlc_object_lock( p_playlist );
-    vlc_object_lock( p_playlist->p_preparse );
-    if( !vlc_object_alive( p_playlist->p_preparse ) )
+    vlc_object_lock( p_playlist->p->p_preparse );
+    if( !vlc_object_alive( p_playlist->p->p_preparse ) )
     {
-        vlc_object_unlock( p_playlist->p_preparse );
+        vlc_object_unlock( p_playlist->p->p_preparse );
         vlc_object_unlock( p_playlist );
         return VLC_EGENERIC;
     }
     PreparseEnqueueItemSub( p_playlist, p_item );
-    vlc_object_unlock( p_playlist->p_preparse );
+    vlc_object_unlock( p_playlist->p->p_preparse );
     vlc_object_unlock( p_playlist );
     return VLC_SUCCESS;
 }
@@ -228,19 +228,19 @@ int playlist_PreparseEnqueueItem( playlist_t *p_playlist,
 int playlist_AskForArtEnqueue( playlist_t *p_playlist,
                                input_item_t *p_item )
 {
-    vlc_object_lock( p_playlist->p_fetcher );
-    if( !vlc_object_alive( p_playlist->p_fetcher ) )
+    vlc_object_lock( p_playlist->p->p_fetcher );
+    if( !vlc_object_alive( p_playlist->p->p_fetcher ) )
     {
-        vlc_object_unlock( p_playlist->p_fetcher );
+        vlc_object_unlock( p_playlist->p->p_fetcher );
         return VLC_EGENERIC;
     }
 
     vlc_gc_incref( p_item );
-    INSERT_ELEM( p_playlist->p_fetcher->pp_waiting,
-                 p_playlist->p_fetcher->i_waiting,
-                 p_playlist->p_fetcher->i_waiting, p_item );
-    vlc_object_signal_unlocked( p_playlist->p_fetcher );
-    vlc_object_unlock( p_playlist->p_fetcher );
+    INSERT_ELEM( p_playlist->p->p_fetcher->pp_waiting,
+                 p_playlist->p->p_fetcher->i_waiting,
+                 p_playlist->p->p_fetcher->i_waiting, p_item );
+    vlc_object_signal_unlocked( p_playlist->p->p_fetcher );
+    vlc_object_unlock( p_playlist->p->p_fetcher );
     return VLC_SUCCESS;
 }
 
@@ -251,9 +251,9 @@ static void PreparseEnqueueItemSub( playlist_t *p_playlist,
     if( p_item->i_children == -1 )
     {
         vlc_gc_incref( p_item->p_input );
-        INSERT_ELEM( p_playlist->p_preparse->pp_waiting,
-                     p_playlist->p_preparse->i_waiting,
-                     p_playlist->p_preparse->i_waiting,
+        INSERT_ELEM( p_playlist->p->p_preparse->pp_waiting,
+                     p_playlist->p->p_preparse->i_waiting,
+                     p_playlist->p->p_preparse->i_waiting,
                      p_item->p_input );
     }
     else
@@ -540,8 +540,8 @@ int playlist_PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
     }
     free( psz_uri );
 
-    if( p_playlist->p_fetcher &&
-            p_playlist->p_fetcher->i_art_policy == ALBUM_ART_WHEN_PLAYED )
+    if( p_playlist->p->p_fetcher &&
+            p_playlist->p->p_fetcher->i_art_policy == ALBUM_ART_WHEN_PLAYED )
     {
         bool b_has_art;
 
index e0c58dd..85d06b6 100644 (file)
@@ -174,14 +174,14 @@ static void playlist_Destructor( vlc_object_t * p_this )
 {
     playlist_t * p_playlist = (playlist_t *)p_this;
 
-    if( p_playlist->p_preparse )
+    if( p_playlist->p->p_preparse )
     {
-        vlc_object_release( p_playlist->p_preparse );
+        vlc_object_release( p_playlist->p->p_preparse );
     }
 
-    if( p_playlist->p_fetcher )
+    if( p_playlist->p->p_fetcher )
     {
-        vlc_object_release( p_playlist->p_fetcher );
+        vlc_object_release( p_playlist->p->p_fetcher );
     }
     msg_Dbg( p_this, "Destroyed" );
 }
@@ -517,10 +517,10 @@ void playlist_LastLoop( playlist_t *p_playlist )
     playlist_ServicesDiscoveryKillAll( p_playlist );
     playlist_MLDump( p_playlist );
 
-    vlc_object_kill( p_playlist->p_preparse );
-    vlc_thread_join( p_playlist->p_preparse );
-    vlc_object_kill( p_playlist->p_fetcher );
-    vlc_thread_join( p_playlist->p_fetcher );
+    vlc_object_kill( p_playlist->p->p_preparse );
+    vlc_thread_join( p_playlist->p->p_preparse );
+    vlc_object_kill( p_playlist->p->p_fetcher );
+    vlc_thread_join( p_playlist->p->p_fetcher );
 
     PL_LOCK;
 
@@ -603,21 +603,21 @@ void playlist_PreparseLoop( playlist_preparse_t *p_obj )
              */
             char *psz_arturl = input_item_GetArtURL( p_current );
             char *psz_name = input_item_GetName( p_current );
-            if( p_playlist->p_fetcher->i_art_policy == ALBUM_ART_ALL &&
+            if( p_playlist->p->p_fetcher->i_art_policy == ALBUM_ART_ALL &&
                         ( !psz_arturl || strncmp( psz_arturl, "file://", 7 ) ) )
             {
                 PL_DEBUG("meta ok for %s, need to fetch art", psz_name );
-                vlc_object_lock( p_playlist->p_fetcher );
-                if( vlc_object_alive( p_playlist->p_fetcher ) )
+                vlc_object_lock( p_playlist->p->p_fetcher );
+                if( vlc_object_alive( p_playlist->p->p_fetcher ) )
                 {
-                    INSERT_ELEM( p_playlist->p_fetcher->pp_waiting,
-                        p_playlist->p_fetcher->i_waiting,
-                        p_playlist->p_fetcher->i_waiting, p_current);
-                    vlc_object_signal_unlocked( p_playlist->p_fetcher );
+                    INSERT_ELEM( p_playlist->p->p_fetcher->pp_waiting,
+                        p_playlist->p->p_fetcher->i_waiting,
+                        p_playlist->p->p_fetcher->i_waiting, p_current);
+                    vlc_object_signal_unlocked( p_playlist->p->p_fetcher );
                 }
                 else
                     vlc_gc_decref( p_current );
-                vlc_object_unlock( p_playlist->p_fetcher );
+                vlc_object_unlock( p_playlist->p->p_fetcher );
             }
             else
             {
index 6ea98a2..07294b3 100644 (file)
 #include "input/input_internal.h"
 #include <assert.h>
 
+struct playlist_private_t
+{
+    playlist_preparse_t  *p_preparse; /**< Preparser object */
+    playlist_fetcher_t   *p_fetcher; /**< Meta and art fetcher object */
+};
+
 struct playlist_preparse_t
 {
     VLC_COMMON_MEMBERS
index d8821a7..5c23a0c 100644 (file)
@@ -60,57 +60,57 @@ void __playlist_ThreadCreate( vlc_object_t *p_parent )
 
     // Preparse
     static const char ppname[] = "preparser";
-    p_playlist->p_preparse =
+    p_playlist->p->p_preparse =
         vlc_custom_create( p_playlist, sizeof( playlist_preparse_t ),
                            VLC_OBJECT_GENERIC, ppname );
-    if( !p_playlist->p_preparse )
+    if( !p_playlist->p->p_preparse )
     {
         msg_Err( p_playlist, "unable to create preparser" );
         vlc_object_release( p_playlist );
         return;
     }
-    p_playlist->p_preparse->psz_object_name = strdup( "preparser" );
-    p_playlist->p_preparse->i_waiting = 0;
-    p_playlist->p_preparse->pp_waiting = NULL;
+    p_playlist->p->p_preparse->psz_object_name = strdup( "preparser" );
+    p_playlist->p->p_preparse->i_waiting = 0;
+    p_playlist->p->p_preparse->pp_waiting = NULL;
 
-    vlc_object_set_destructor( p_playlist->p_preparse, PreparseDestructor );
+    vlc_object_set_destructor( p_playlist->p->p_preparse, PreparseDestructor );
 
-    vlc_object_attach( p_playlist->p_preparse, p_playlist );
-    if( vlc_thread_create( p_playlist->p_preparse, "preparser",
+    vlc_object_attach( p_playlist->p->p_preparse, p_playlist );
+    if( vlc_thread_create( p_playlist->p->p_preparse, "preparser",
                            RunPreparse, VLC_THREAD_PRIORITY_LOW, true ) )
     {
         msg_Err( p_playlist, "cannot spawn preparse thread" );
-        vlc_object_release( p_playlist->p_preparse );
+        vlc_object_release( p_playlist->p->p_preparse );
         return;
     }
 
     // Secondary Preparse
     static const char fname[] = "fetcher";
-    p_playlist->p_fetcher =
+    p_playlist->p->p_fetcher =
         vlc_custom_create( p_playlist, sizeof( playlist_fetcher_t ),
                            VLC_OBJECT_GENERIC, fname );
-    if( !p_playlist->p_fetcher )
+    if( !p_playlist->p->p_fetcher )
     {
         msg_Err( p_playlist, "unable to create secondary preparser" );
         vlc_object_release( p_playlist );
         return;
     }
-    p_playlist->p_fetcher->psz_object_name = strdup( "fetcher" );
-    p_playlist->p_fetcher->i_waiting = 0;
-    p_playlist->p_fetcher->pp_waiting = NULL;
-    p_playlist->p_fetcher->i_art_policy = var_CreateGetInteger( p_playlist,
+    p_playlist->p->p_fetcher->psz_object_name = strdup( "fetcher" );
+    p_playlist->p->p_fetcher->i_waiting = 0;
+    p_playlist->p->p_fetcher->pp_waiting = NULL;
+    p_playlist->p->p_fetcher->i_art_policy = var_CreateGetInteger( p_playlist,
                                                                 "album-art" );
 
-    vlc_object_set_destructor( p_playlist->p_fetcher, FetcherDestructor );
+    vlc_object_set_destructor( p_playlist->p->p_fetcher, FetcherDestructor );
 
-    vlc_object_attach( p_playlist->p_fetcher, p_playlist );
-    if( vlc_thread_create( p_playlist->p_fetcher,
+    vlc_object_attach( p_playlist->p->p_fetcher, p_playlist );
+    if( vlc_thread_create( p_playlist->p->p_fetcher,
                            "fetcher",
                            RunFetcher,
                            VLC_THREAD_PRIORITY_LOW, true ) )
     {
         msg_Err( p_playlist, "cannot spawn secondary preparse thread" );
-        vlc_object_release( p_playlist->p_fetcher );
+        vlc_object_release( p_playlist->p->p_fetcher );
         return;
     }