]> git.sesse.net Git - vlc/commitdiff
input: Don't assume the playlist always exists.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 31 Mar 2008 01:29:31 +0000 (03:29 +0200)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Mon, 31 Mar 2008 01:41:24 +0000 (03:41 +0200)
src/input/control.c
src/input/es_out.c
src/input/input.c

index 210469d9038464a07ebada5715cd66a931daa36e..0609c60a5e47d5a0128c3f308694b19723a51afb 100644 (file)
@@ -598,13 +598,16 @@ int input_vaControl( input_thread_t *p_input, int i_query, va_list args )
 
 static void NotifyPlaylist( input_thread_t *p_input )
 {
-    playlist_t *p_playlist = pl_Get( p_input );
-    if( p_playlist->b_die )
+    /* FIXME: We need to avoid that dependency on the playlist
+     * because it is a circular dependency:
+     * ( playlist -> input -> playlist ) */
+    playlist_t *p_playlist = vlc_object_find( p_input,
+                    VLC_OBJECT_PLAYLIST, FIND_PARENT );
+    if( !p_playlist )
         return;
-    vlc_object_yield( p_playlist );
     var_SetInteger( p_playlist, "item-change",
                     p_input->p->input.p_item->i_id );
-    pl_Release( p_input );
+    vlc_object_release( p_playlist );
 }
 
 static void UpdateBookmarksOption( input_thread_t *p_input )
index 733d907dd874b2c7b720c749d9902d9fab2b4ade..9eb7e7ca34d1b67f0a3e65d6bafae5d06e81e77f 100644 (file)
@@ -1680,12 +1680,17 @@ static int EsOutControl( es_out_t *out, int i_query, va_list args )
                 }
             }
             {
-                playlist_t * p_playlist = pl_Yield( p_sys->p_input );
-                PL_LOCK;
-                p_playlist->gc_date = mdate();
-                vlc_object_signal_unlocked( p_playlist );
-                PL_UNLOCK;
-                pl_Release( p_playlist );
+                /* FIXME: we don't want to depend on the playlist */
+                playlist_t * p_playlist = vlc_object_find( p_sys->p_input,
+                    VLC_OBJECT_PLAYLIST, FIND_PARENT );
+                if( p_playlist )
+                {
+                    PL_LOCK;
+                    p_playlist->gc_date = mdate();
+                    vlc_object_signal_unlocked( p_playlist );
+                    PL_UNLOCK;
+                    vlc_object_release( p_playlist );
+                }
             }
             return VLC_SUCCESS;
  
index 6a4d44c35c970c0dfe58f9e3eac7e3b9590af652..befb73a0b67c9c0a5a3e27b7e724a9b50b99de52 100644 (file)
 #include <vlc_sout.h>
 #include "../stream_output/stream_output.h"
 
-#include <vlc_playlist.h>
 #include <vlc_interface.h>
 #include <vlc_url.h>
 #include <vlc_charset.h>
+#include <vlc_playlist.h>
 
 #ifdef HAVE_SYS_STAT_H
 #   include <sys/stat.h>
@@ -502,7 +502,15 @@ static int Run( input_thread_t *p_input )
     {
         /* If we failed, wait before we are killed, and exit */
         p_input->b_error = VLC_TRUE;
-        playlist_Signal( pl_Get( p_input ) );
+
+        /* FIXME: we don't want to depend on the playlist */
+        playlist_t * p_playlist = vlc_object_find( p_input,
+            VLC_OBJECT_PLAYLIST, FIND_PARENT );
+        if( p_playlist )
+        {
+            playlist_Signal( p_playlist );
+            vlc_object_release( p_playlist );
+        }
 
         Error( p_input );
 
@@ -1373,27 +1381,31 @@ static sout_instance_t *SoutFind( vlc_object_t *p_parent, input_item_t *p_item,
     if( b_keep_sout )
     {
         /* Remove the sout from the playlist garbage collector */
-        playlist_t *p_playlist = pl_Yield( p_parent );
-
-        vlc_mutex_lock( &p_playlist->gc_lock );
-        p_sout = vlc_object_find( p_playlist, VLC_OBJECT_SOUT, FIND_CHILD );
-        if( p_sout )
+        /* FIXME: we don't want to depend on the playlist */
+        playlist_t * p_playlist = vlc_object_find( p_parent,
+            VLC_OBJECT_PLAYLIST, FIND_PARENT );
+        if( p_playlist )
         {
-            if( p_sout->p_parent != VLC_OBJECT(p_playlist) )
+            vlc_mutex_lock( &p_playlist->gc_lock );
+            p_sout = vlc_object_find( p_playlist, VLC_OBJECT_SOUT, FIND_CHILD );
+            if( p_sout )
             {
-                vlc_object_release( p_sout );
-                p_sout = NULL;
-            }
-            else
-            {
-                vlc_object_detach( p_sout );    /* Remove it from the GC */
+                if( p_sout->p_parent != VLC_OBJECT(p_playlist) )
+                {
+                    vlc_object_release( p_sout );
+                    p_sout = NULL;
+                }
+                else
+                {
+                    vlc_object_detach( p_sout );    /* Remove it from the GC */
 
-                vlc_object_release( p_sout );
+                    vlc_object_release( p_sout );
+                }
             }
-        }
-        vlc_mutex_unlock( &p_playlist->gc_lock );
+            vlc_mutex_unlock( &p_playlist->gc_lock );
 
-        pl_Release( p_parent );
+            vlc_object_release( p_playlist );
+        }
     }
 
     if( pb_sout_keep )