]> git.sesse.net Git - vlc/blobdiff - src/playlist/engine.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / src / playlist / engine.c
index 379412ece5007a212e230fad2b5f5d8edf9ab681..8a40f47a50023eb769d26dd0532d26977b0b2e2e 100644 (file)
@@ -38,7 +38,6 @@
  * Local prototypes
  *****************************************************************************/
 static void VariablesInit( playlist_t *p_playlist );
-static void playlist_Destructor( vlc_object_t * p_this );
 
 static int RandomCallback( vlc_object_t *p_this, char const *psz_cmd,
                            vlc_value_t oldval, vlc_value_t newval, void *a )
@@ -105,10 +104,24 @@ 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,
-                                    0, NULL );
+                                    PLAYLIST_END, 0, NULL );
     PL_UNLOCK;
     if( !p_playlist->p_root ) return NULL;
 
@@ -116,7 +129,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
     PL_LOCK;
     p_playlist->p_playing = playlist_NodeCreate(
         p_playlist, _( "Playlist" ), p_playlist->p_root,
-        PLAYLIST_RO_FLAG, NULL );
+        PLAYLIST_END, PLAYLIST_RO_FLAG, NULL );
 
     PL_UNLOCK;
 
@@ -129,7 +142,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
         PL_LOCK;
         p_playlist->p_media_library = playlist_NodeCreate(
             p_playlist, _( "Media Library" ), p_playlist->p_root,
-            PLAYLIST_RO_FLAG, NULL );
+            PLAYLIST_END, PLAYLIST_RO_FLAG, NULL );
         PL_UNLOCK;
 
         if(!p_playlist->p_media_library ) return NULL;
@@ -160,28 +173,29 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
         pl_priv(p_playlist)->b_auto_preparse = b_auto_preparse;
     }
 
-    vlc_object_set_destructor( p_playlist, playlist_Destructor );
-
     return p_playlist;
 }
 
 /**
- * Destroy playlist
+ * Destroy playlist.
+ * This is not thread-safe. Any reference to the playlist is assumed gone.
+ * (In particular, all interface and services threads must have been joined).
  *
- * Destroy a playlist structure.
  * \param p_playlist the playlist object
- * \return nothing
  */
-
-static void playlist_Destructor( vlc_object_t * p_this )
+void playlist_Destroy( playlist_t *p_playlist )
 {
-    playlist_t *p_playlist = (playlist_t *)p_this;
     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 );
+
+    /* Already cleared when deactivating (if activated anyway) */
     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 );
@@ -203,7 +217,7 @@ static void playlist_Destructor( vlc_object_t * p_this )
     ARRAY_RESET( p_playlist->items );
     ARRAY_RESET( p_playlist->current );
 
-    msg_Dbg( p_this, "Destroyed" );
+    vlc_object_release( p_playlist );
 }
 
 /** Get current playing input.
@@ -268,6 +282,12 @@ void set_current_status_node( playlist_t * p_playlist,
     pl_priv(p_playlist)->status.p_node = p_node;
 }
 
+static input_thread_t *playlist_FindInput( vlc_object_t *object )
+{
+    assert( object == VLC_OBJECT(pl_Get(object)) );
+    return playlist_CurrentInput( (playlist_t *)object );
+}
+
 static void VariablesInit( playlist_t *p_playlist )
 {
     /* These variables control updates */
@@ -299,6 +319,18 @@ static void VariablesInit( playlist_t *p_playlist )
 
     /* */
     var_Create( p_playlist, "album-art", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+
+    /* Variables to preserve video output parameters */
+    var_Create( p_playlist, "fullscreen", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+    var_Create( p_playlist, "video-on-top", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+
+    /* Audio output parameters */
+    var_Create( p_playlist, "volume-muted", VLC_VAR_BOOL );
+    var_Create( p_playlist, "saved-volume", VLC_VAR_INTEGER );
+    var_Create( p_playlist, "volume-change", VLC_VAR_VOID );
+    /* FIXME: horrible hack for audio output interface code */
+    var_Create( p_playlist, "find-input-callback", VLC_VAR_ADDRESS );
+    var_SetAddress( p_playlist, "find-input-callback", playlist_FindInput );
 }
 
 playlist_item_t * playlist_CurrentPlayingItem( playlist_t * p_playlist )