[vlc-commits] aout: filters: assert that audio converter/resamplers are const

Thomas Guillem git at videolan.org
Wed Jul 12 19:10:22 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Jul 12 18:57:38 2017 +0200| [c01ab28ec52443459815ae76fa8ac72334104da9] | committer: Thomas Guillem

aout: filters: assert that audio converter/resamplers are const

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

 src/audio_output/filters.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index 9944d0f2e0..50ddb0cd32 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -45,7 +45,8 @@
 static filter_t *CreateFilter (vlc_object_t *obj, const char *type,
                                const char *name, filter_owner_sys_t *owner,
                                const audio_sample_format_t *infmt,
-                               const audio_sample_format_t *outfmt)
+                               const audio_sample_format_t *outfmt,
+                               bool const_fmt)
 {
     filter_t *filter = vlc_custom_create (obj, sizeof (*filter), type);
     if (unlikely(filter == NULL))
@@ -67,11 +68,18 @@ static filter_t *CreateFilter (vlc_object_t *obj, const char *type,
 #endif
 
     filter->p_module = module_need (filter, type, name, false);
-    if (filter->p_module == NULL)
+
+#ifndef NDEBUG
+    if (filter->p_module == NULL || const_fmt)
     {
         /* If probing failed, formats shall not have been modified. */
         assert (AOUT_FMTS_IDENTICAL(&filter->fmt_in.audio, infmt));
         assert (AOUT_FMTS_IDENTICAL(&filter->fmt_out.audio, outfmt));
+    }
+#endif
+
+    if (filter->p_module == NULL)
+    {
         vlc_object_release (filter);
         filter = NULL;
     }
@@ -84,7 +92,7 @@ static filter_t *FindConverter (vlc_object_t *obj,
                                 const audio_sample_format_t *infmt,
                                 const audio_sample_format_t *outfmt)
 {
-    return CreateFilter (obj, "audio converter", NULL, NULL, infmt, outfmt);
+    return CreateFilter (obj, "audio converter", NULL, NULL, infmt, outfmt, true);
 }
 
 static filter_t *FindResampler (vlc_object_t *obj,
@@ -92,7 +100,7 @@ static filter_t *FindResampler (vlc_object_t *obj,
                                 const audio_sample_format_t *outfmt)
 {
     return CreateFilter (obj, "audio resampler", "$audio-resampler", NULL,
-                         infmt, outfmt);
+                         infmt, outfmt, true);
 }
 
 /**
@@ -375,7 +383,7 @@ static int AppendFilter(vlc_object_t *obj, const char *type, const char *name,
     }
 
     filter_t *filter = CreateFilter (obj, type, name,
-                                     (void *)owner, infmt, outfmt);
+                                     (void *)owner, infmt, outfmt, false);
     if (filter == NULL)
     {
         msg_Err (obj, "cannot add user %s \"%s\" (skipped)", type, name);



More information about the vlc-commits mailing list