[vlc-devel] commit: input: Don't assume the playlist always exists. (Pierre d' Herbemont )

git version control git at videolan.org
Mon Mar 31 03:52:05 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Mon Mar 31 03:29:31 2008 +0200| [3ccc28637b958e0893a12872e1ced3f24b817027]

input: Don't assume the playlist always exists.

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

 src/input/control.c |   11 +++++++----
 src/input/es_out.c  |   17 +++++++++++------
 src/input/input.c   |   48 ++++++++++++++++++++++++++++++------------------
 3 files changed, 48 insertions(+), 28 deletions(-)

diff --git a/src/input/control.c b/src/input/control.c
index 210469d..0609c60 100644
--- a/src/input/control.c
+++ b/src/input/control.c
@@ -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 )
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 733d907..9eb7e7c 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -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;
  
diff --git a/src/input/input.c b/src/input/input.c
index 6a4d44c..befb73a 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -40,10 +40,10 @@
 #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 )




More information about the vlc-devel mailing list