[vlc-devel] [PATCH V3 1/4] aout: refactor default aout_filters_cfg_t handling

Thomas Guillem thomas at gllm.fr
Tue Nov 26 16:31:23 CET 2019


Use the default one instead of NULL.

No functional changes except a possible NULL-deref fix in case of a
AUDIO_CHANNEL_TYPE_AMBISONICS conversion from a sout plugin.
---
 src/audio_output/filters.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index a297f4c6974..168c97f707f 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -491,6 +491,10 @@ aout_filters_t *aout_FiltersNewWithClock(vlc_object_t *obj, const vlc_clock_t *c
                                          const audio_sample_format_t *restrict outfmt,
                                          const aout_filters_cfg_t *cfg)
 {
+    static const aout_filters_cfg_t default_cfg = AOUT_FILTERS_CFG_INIT;
+    if (!cfg)
+        cfg = &default_cfg;
+
     aout_filters_t *filters = malloc (sizeof (*filters));
     if (unlikely(filters == NULL))
         return NULL;
@@ -590,15 +594,12 @@ aout_filters_t *aout_FiltersNewWithClock(vlc_object_t *obj, const vlc_clock_t *c
             filters->rate_filter = filters->tab[filters->count - 1];
     }
 
-    if (cfg != NULL)
-    {
-        AppendRemapFilter(obj, filters, &input_format, &output_format,
-                          cfg->remap);
+    AppendRemapFilter(obj, filters, &input_format, &output_format,
+                      cfg->remap);
 
-        if (input_format.i_channels > 2 && cfg->headphones)
-            AppendFilter(obj, "audio filter", "binauralizer", filters,
-                         &input_format, &output_format, NULL);
-    }
+    if (input_format.i_channels > 2 && cfg->headphones)
+        AppendFilter(obj, "audio filter", "binauralizer", filters,
+                     &input_format, &output_format, NULL);
 
     /* Now add user filters */
     char *str = var_InheritString (obj, "audio-filter");
-- 
2.20.1



More information about the vlc-devel mailing list