[vlc-devel] [PATCH] [HACK] marq: support $x variables

Jean-Baptiste Kempf jb at videolan.org
Wed Feb 15 13:57:38 CET 2017


Since this is a spu-source filter, this walks up the chain to get the PL,
and then gets the input and use strfinput on them.

Opinions very welcome

Ref #9514
---
 modules/spu/marq.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/modules/spu/marq.c b/modules/spu/marq.c
index 28c04f8a35..a8395cc167 100644
--- a/modules/spu/marq.c
+++ b/modules/spu/marq.c
@@ -32,6 +32,7 @@
 #endif
 
 #include <errno.h>
+#include <assert.h>
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
@@ -40,6 +41,8 @@
 #include <vlc_fs.h>
 #include <vlc_strings.h>
 #include <vlc_subpicture.h>
+#include <vlc_playlist.h>
+#include <vlc_input.h>
 
 /*****************************************************************************
  * Local prototypes
@@ -291,6 +294,35 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     char *msg = vlc_strftime( p_sys->format ? p_sys->format : "" );
     if( unlikely( msg == NULL ) )
         goto out;
+
+    /* Parental advisory required.
+     * To get the $ variables to work, we need an input.
+     * Since the vout/spu and the input are totally decorellated,
+     * we must look for the input at every Filter call...
+     * And we must look it up by walking up the chain
+     *
+     * See #9514 b55ddc8f, 68bc7fd9 and cccd51a
+     */
+    if( strchr (msg, '$' ) ) {
+       vlc_object_t *spu_obj = VLC_OBJECT(p_filter)->obj.parent;
+        if( spu_obj != NULL ) {
+            vlc_object_t *vout = VLC_OBJECT(spu_obj)->obj.parent;
+            if( vout != NULL ) {
+                vlc_object_t *pl = VLC_OBJECT(vout)->obj.parent;
+                if( pl != NULL ) {
+                    assert( !strcmp( pl->obj.object_type, "playlist" ) );
+                    input_thread_t *input = playlist_CurrentInput( (playlist_t*)pl );
+                    if( input != NULL ) {
+                        char *msg2 = vlc_strfinput( input, msg );
+                        free( msg );
+                        msg = msg2;
+                        vlc_object_release( input );
+                    }
+                }
+            }
+        }
+    }
+
     if( p_sys->message != NULL && !strcmp( msg, p_sys->message ) )
     {
         free( msg );
-- 
2.11.0



More information about the vlc-devel mailing list