[vlc-devel] commit: Handle sout-keep from the playlist engine ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed Jun 4 20:16:12 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Wed Jun  4 21:13:47 2008 +0300| [65892ac8249cd60f0f2ae25e138a76c76436e9e3]

Handle sout-keep from the playlist engine

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

 src/libvlc.h           |    3 +++
 src/playlist/control.c |    5 ++++-
 src/playlist/engine.c  |   22 ++++++++++++++--------
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/libvlc.h b/src/libvlc.h
index 7a76650..936b75c 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -237,6 +237,9 @@ typedef struct libvlc_priv_t
     vlm_t             *p_vlm;  ///< the VLM singleton (or NULL)
     vlc_object_t      *p_interaction;    ///< interface interaction object
     httpd_t           *p_httpd; ///< HTTP daemon (src/network/httpd.c)
+
+    /* Private playlist data (FIXME - playlist_t is too public...) */
+    sout_instance_t   *p_sout; ///< kept sout instance (for playlist)
 } libvlc_priv_t;
 
 static inline libvlc_priv_t *libvlc_priv (libvlc_int_t *libvlc)
diff --git a/src/playlist/control.c b/src/playlist/control.c
index 24393b1..9a0ba6d 100644
--- a/src/playlist/control.c
+++ b/src/playlist/control.c
@@ -464,6 +464,7 @@ playlist_item_t * playlist_NextItem( playlist_t *p_playlist )
 int playlist_PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
 {
     input_item_t *p_input = p_item->p_input;
+    sout_instance_t **pp_sout = &libvlc_priv(p_playlist->p_libvlc)->p_sout;
     int i_activity = var_GetInteger( p_playlist, "activity" ) ;
 
     msg_Dbg( p_playlist, "creating new input thread" );
@@ -475,7 +476,9 @@ int playlist_PlayItem( playlist_t *p_playlist, playlist_item_t *p_item )
 
     var_SetInteger( p_playlist, "activity", i_activity +
                     DEFAULT_INPUT_ACTIVITY );
-    p_playlist->p_input = input_CreateThread( p_playlist, p_input );
+    p_playlist->p_input =
+        input_CreateThreadExtended( p_playlist, p_input, NULL, *pp_sout );
+    *pp_sout = NULL;
 
     char *psz_uri = input_item_GetURI( p_item->p_input );
     if( psz_uri && ( !strncmp( psz_uri, "directory:", 10 ) ||
diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index 9c0475c..35fc7d7 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -26,6 +26,7 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
 #include <vlc_common.h>
 #include <vlc_vout.h>
 #include <vlc_sout.h>
@@ -263,10 +264,16 @@ check_input:
         {
             int i_activity;
             input_thread_t *p_input;
+            sout_instance_t **pp_sout =
+                &libvlc_priv(p_playlist->p_libvlc)->p_sout;
+
             PL_DEBUG( "dead input" );
 
             p_input = p_playlist->p_input;
             p_playlist->p_input = NULL;
+            assert( *pp_sout == NULL );
+            if( var_CreateGetBool( p_input, "sout-keep" ) )
+                *pp_sout = input_DetachSout( p_input );
 
             /* Release the playlist lock, because we may get stuck
              * in vlc_object_release() for some time. */
@@ -404,6 +411,9 @@ void playlist_LastLoop( playlist_t *p_playlist )
             p_playlist->p_input = NULL;
             PL_UNLOCK;
 
+            /* sout-keep: no need to anything here.
+             * The last input will destroy its sout, if any, by itself */
+
             /* Destroy input */
             vlc_object_release( p_input );
             continue;
@@ -429,14 +439,10 @@ void playlist_LastLoop( playlist_t *p_playlist )
     }
 
 #ifdef ENABLE_SOUT
-    /* close all remaining sout */
-    while( ( p_obj = vlc_object_find( p_playlist,
-                                      VLC_OBJECT_SOUT, FIND_CHILD ) ) )
-    {
-        vlc_object_detach( p_obj );
-        vlc_object_release( p_obj );
-        sout_DeleteInstance( (sout_instance_t*)p_obj );
-    }
+    /* close the remaining sout-keep (if there was no input atm) */
+    sout_instance_t *p_sout = libvlc_priv (p_playlist->p_libvlc)->p_sout;
+    if (p_sout)
+        sout_DeleteInstance( p_sout );
 #endif
 
     /* close all remaining vout */




More information about the vlc-devel mailing list