[vlc-devel] [PATCHES] -- fix marquee failing to format input-dependent text ($N, $...)

brezhoneg1 brezhoneg1 at yahoo.fr
Sat Apr 27 02:21:51 CEST 2013


Hi,

    As of today, the marquee plugin suffers from a noticeable 
regression, namely the impossibility to perform
input-dependent text formatting ($N, $....) whatever the use of vlc 
(playlist, libvlc, ....).

   Are there any plans to fix that for the next version ?

   I have got a series of patches (attached to this mail) that can fix 
this issue for the near future without much tampering
   with the code.  Please, review it and tell me if you see it as an 
acceptable fix for the time being ?

Erwan



-------------- next part --------------
>From 4ea8855166443bd5bd9cd531cb3e2b3364d889ad Mon Sep 17 00:00:00 2001
From: Erwan Tulou <erwan10 at videolan.org>
Date: Fri, 26 Apr 2013 23:07:13 +0200
Subject: [PATCH 1/3] core: add a input_resource_HoldInput function

---
 include/vlc_input.h  |    9 +++++++++
 src/input/resource.c |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index b48a256..091fb50 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -645,4 +645,13 @@ VLC_API void input_resource_Terminate( input_resource_t * );
  */
 VLC_API audio_output_t *input_resource_HoldAout( input_resource_t * );
 
+/**
+ * \return the current input if any
+ * Use vlc_object_release() to drop the reference.
+ *
+ * The object passed as parameter must be a descendant of
+ * any aout/vout/sout objects managed as a resource.
+ */
+VLC_API input_thread_t *input_resource_HoldInput( vlc_object_t * );
+
 #endif
diff --git a/src/input/resource.c b/src/input/resource.c
index f3a82dd..1418f62 100644
--- a/src/input/resource.c
+++ b/src/input/resource.c
@@ -76,6 +76,17 @@ struct input_resource_t
 };
 
 /* */
+static void MarkResource( input_resource_t *p_resource, vlc_object_t* p_obj )
+{
+    // add a watermark on our aout/vout/sout objects
+    if( p_obj && !var_Type( p_obj, "resource" ) )
+    {
+        var_Create( p_obj, "resource", VLC_VAR_ADDRESS );
+        var_SetAddress( p_obj, "resource", p_resource );
+    }
+}
+
+/* */
 static void DestroySout( input_resource_t *p_resource )
 {
 #ifdef ENABLE_SOUT
@@ -356,6 +367,8 @@ audio_output_t *input_resource_GetAout( input_resource_t *p_resource )
         vlc_object_hold( p_aout );
     }
     vlc_mutex_unlock( &p_resource->lock );
+
+    MarkResource( p_resource, VLC_OBJECT(p_aout) );
     return p_aout;
 }
 
@@ -419,6 +432,7 @@ input_resource_t *input_resource_New( vlc_object_t *p_parent )
 
     atomic_init( &p_resource->refs, 1 );
     p_resource->p_parent = p_parent;
+    p_resource->p_input = NULL;
     vlc_mutex_init( &p_resource->lock );
     vlc_mutex_init( &p_resource->lock_hold );
     return p_resource;
@@ -453,7 +467,11 @@ void input_resource_SetInput( input_resource_t *p_resource, input_thread_t *p_in
         assert( p_resource->i_vout == 0 );
 
     /* */
+    if( p_resource->p_input )
+        vlc_object_release( p_resource->p_input );
     p_resource->p_input = p_input;
+    if( p_resource->p_input )
+        vlc_object_hold( p_resource->p_input );
 
     vlc_mutex_unlock( &p_resource->lock );
 }
@@ -467,6 +485,7 @@ vout_thread_t *input_resource_RequestVout( input_resource_t *p_resource,
     vout_thread_t *p_ret = RequestVout( p_resource, p_vout, p_fmt, dpb_size, b_recycle );
     vlc_mutex_unlock( &p_resource->lock );
 
+    MarkResource( p_resource, VLC_OBJECT(p_ret) );
     return p_ret;
 }
 vout_thread_t *input_resource_HoldVout( input_resource_t *p_resource )
@@ -501,6 +520,7 @@ sout_instance_t *input_resource_RequestSout( input_resource_t *p_resource, sout_
     sout_instance_t *p_ret = RequestSout( p_resource, p_sout, psz_sout );
     vlc_mutex_unlock( &p_resource->lock );
 
+    MarkResource( p_resource, VLC_OBJECT(p_ret) );
     return p_ret;
 }
 void input_resource_TerminateSout( input_resource_t *p_resource )
@@ -515,3 +535,18 @@ void input_resource_Terminate( input_resource_t *p_resource )
     input_resource_TerminateVout( p_resource );
 }
 
+input_thread_t* input_resource_HoldInput( vlc_object_t* p_obj )
+{
+    input_thread_t* p_input = NULL;
+    input_resource_t *p_resource = var_InheritAddress( p_obj, "resource" );
+
+    if( p_resource )
+    {
+        vlc_mutex_lock( &p_resource->lock );
+        p_input = p_resource->p_input;
+        if( p_input )
+            vlc_object_hold( p_input );
+        vlc_mutex_unlock( &p_resource->lock );
+    }
+    return p_input;
+}
-- 
1.7.10.4

-------------- next part --------------
>From 5c8d3a0b0edbd48cb7acddb057c9bfe72984ad5b Mon Sep 17 00:00:00 2001
From: Erwan Tulou <erwan10 at videolan.org>
Date: Fri, 26 Apr 2013 23:10:25 +0200
Subject: [PATCH 2/3] str_format: use input_resource_HoldInput as the
 preferred input detection

This new str_format now works fine for both the playlist and libvlc
media players when called by aout/vout/sout objects and their descendants.
(filters, ...)
---
 src/text/strings.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/text/strings.c b/src/text/strings.c
index d5d02f4..93c7a4a 100644
--- a/src/text/strings.c
+++ b/src/text/strings.c
@@ -537,7 +537,11 @@ char *str_format_meta( playlist_t *p_object, const char *string )
     if( !dst ) return NULL;
     int d = 0;
 
-    input_thread_t *p_input = playlist_CurrentInput( p_object );
+    input_thread_t *p_input = input_resource_HoldInput( p_object );
+    // fallback the old way to avoid regression for objects not within the
+    // scope of a resource manager
+    if( !p_input )
+        p_input = playlist_CurrentInput( p_object );
     input_item_t *p_item = NULL;
     if( p_input )
     {
-- 
1.7.10.4

-------------- next part --------------
>From 36d5442af960d596bbb09292595732d2a4b57d4d Mon Sep 17 00:00:00 2001
From: Erwan Tulou <erwan10 at videolan.org>
Date: Fri, 26 Apr 2013 23:13:59 +0200
Subject: [PATCH 3/3] marquee: reinstate str_format

With the new str_format, marquee can now perform input-dependent
text formatting for both the playlist and the libvlc programs.
---
 modules/video_filter/marq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/modules/video_filter/marq.c b/modules/video_filter/marq.c
index ebf5b5c..68ce866 100644
--- a/modules/video_filter/marq.c
+++ b/modules/video_filter/marq.c
@@ -291,7 +291,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
         }
     }
 
-    char *msg = str_format_time( p_sys->format ? p_sys->format : "" );
+    char *msg = str_format( p_filter, p_sys->format ? p_sys->format : "" );
     if( unlikely( msg == NULL ) )
         goto out;
     if( p_sys->message != NULL && !strcmp( msg, p_sys->message ) )
-- 
1.7.10.4



More information about the vlc-devel mailing list