[vlc-commits] aout: add "audio renderer" converters

Thomas Guillem git at videolan.org
Wed Jul 19 18:57:20 CEST 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Jun 20 15:34:10 2017 +0200| [5fd3521851f5394c52070377cea2a86c4bc4ac79] | committer: Thomas Guillem

aout: add "audio renderer" converters

This new "audio renderer" capability will handle channels_type conversions.

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

 src/audio_output/dec.c     |  3 ++-
 src/audio_output/filters.c | 33 +++++++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 2433df0c6b..8610794bea 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -81,7 +81,8 @@ int aout_DecNew( audio_output_t *p_aout,
     owner->input_format = *p_format;
     owner->mixer_format = owner->input_format;
 
-    if (i_map_channels == 0)
+    if (p_format->channel_type == AUDIO_CHANNEL_TYPE_BITMAP
+     && i_map_channels == 0)
     {
         /* The output channel map is unknown, use the WAVE one. */
         assert(owner->mixer_format.i_channels > 0);
diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index f74ac6563c..b8c1c87619 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -163,7 +163,8 @@ static int aout_FiltersPipelineCreate(vlc_object_t *obj, filter_t **filters,
 
     /* Remix channels */
     if (infmt->i_physical_channels != outfmt->i_physical_channels
-     || infmt->i_chan_mode != outfmt->i_chan_mode)
+     || infmt->i_chan_mode != outfmt->i_chan_mode
+     || infmt->channel_type != outfmt->channel_type)
     {   /* Remixing currently requires FL32... TODO: S16N */
         if (input.i_format != VLC_CODEC_FL32)
         {
@@ -188,10 +189,16 @@ static int aout_FiltersPipelineCreate(vlc_object_t *obj, filter_t **filters,
         output.i_format = input.i_format;
         output.i_rate = input.i_rate;
         output.i_physical_channels = outfmt->i_physical_channels;
+        output.channel_type = outfmt->channel_type;
         output.i_chan_mode = outfmt->i_chan_mode;
         aout_FormatPrepare (&output);
 
-        filter_t *f = FindConverter (obj, &input, &output);
+        const char *filter_type =
+            infmt->channel_type != outfmt->channel_type ?
+            "audio renderer" : "audio converter";
+
+        filter_t *f = CreateFilter (obj, filter_type, NULL, NULL,
+                                    &input, &output, NULL, true);
         if (f == NULL)
         {
             msg_Err (obj, "cannot find %s for conversion pipeline",
@@ -519,6 +526,26 @@ aout_filters_t *aout_FiltersNew (vlc_object_t *obj,
         goto error;
     }
 
+    assert(output_format.channel_type == AUDIO_CHANNEL_TYPE_BITMAP);
+    if (input_format.channel_type != output_format.channel_type)
+    {
+        /* Do the channel type conversion before any filters since audio
+         * converters and filters handle only AUDIO_CHANNEL_TYPE_BITMAP */
+
+        /* convert to the output format (minus resampling) if necessary */
+        output_format.i_rate = input_format.i_rate;
+        if (aout_FiltersPipelineCreate (obj, filters->tab, &filters->count,
+                                  AOUT_MAX_FILTERS, &input_format, &output_format))
+        {
+            msg_Warn (obj, "cannot setup audio renderer pipeline");
+            /* Fallback to bitmap without any conversions */
+            input_format.channel_type = AUDIO_CHANNEL_TYPE_BITMAP;
+            aout_FormatPrepare(&input_format);
+        }
+        else
+            input_format = output_format;
+    }
+
     if (aout_FormatNbChannels(&input_format) == 0)
     {
         /* The input channel map is unknown, use the WAVE one and add a
@@ -541,6 +568,8 @@ aout_filters_t *aout_FiltersNew (vlc_object_t *obj,
         filters->tab[filters->count++] = f;
     }
 
+    assert(input_format.channel_type == AUDIO_CHANNEL_TYPE_BITMAP);
+
     /* parse user filter lists */
     if (var_InheritBool (obj, "audio-time-stretch"))
     {



More information about the vlc-commits mailing list