[vlc-devel] [PATCH] filter_chain: reset the fmt_in/out between failed load of filters

Steve Lhomme robux4 at videolabs.io
Wed Jul 19 16:04:52 CEST 2017


The filter chain is then safer from failing filters.
---
 src/misc/filter_chain.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/misc/filter_chain.c b/src/misc/filter_chain.c
index 02e389d4ef..fc4bdb4be4 100644
--- a/src/misc/filter_chain.c
+++ b/src/misc/filter_chain.c
@@ -179,6 +179,24 @@ void filter_chain_Reset( filter_chain_t *p_chain, const es_format_t *p_fmt_in,
     }
 }
 
+static int FilterLoader(void *func, va_list ap)
+{
+    filter_t *p_dec = va_arg(ap, filter_t *);
+    int (*activate)(vlc_object_t *) = func;
+
+    int res = activate( VLC_OBJECT(p_dec) );
+    if ( res != VLC_SUCCESS )
+    {
+        const es_format_t *fmt_in = va_arg(ap, const es_format_t *);
+        const es_format_t *fmt_out = va_arg(ap, const es_format_t *);
+        es_format_Clean( &p_dec->fmt_in );
+        es_format_Copy( &p_dec->fmt_in, fmt_in );
+        es_format_Clean( &p_dec->fmt_out );
+        es_format_Copy( &p_dec->fmt_out, fmt_out );
+    }
+    return res;
+}
+
 static filter_t *filter_chain_AppendInner( filter_chain_t *chain,
     const char *name, const char *capability, config_chain_t *cfg,
     const es_format_t *fmt_in, const es_format_t *fmt_out )
@@ -219,10 +237,12 @@ static filter_t *filter_chain_AppendInner( filter_chain_t *chain,
          * It will then try to add a video converter before. */
         char name_chained[strlen(name) + sizeof(",chain")];
         sprintf( name_chained, "%s,chain", name );
-        filter->p_module = module_need( filter, capability, name_chained, true );
+        filter->p_module = vlc_module_load( filter, capability, name_chained, true,
+                                            FilterLoader, filter, fmt_in, fmt_out );
     }
     else
-        filter->p_module = module_need( filter, capability, name, name != NULL );
+        filter->p_module = vlc_module_load( filter, capability, name, name != NULL,
+                                            FilterLoader, filter, fmt_in, fmt_out );
 
     if( filter->p_module == NULL )
         goto error;
-- 
2.12.1



More information about the vlc-devel mailing list