[vlc-devel] [PATCH 08/12] aout: support unknown channel layout
Thomas Guillem
thomas at gllm.fr
Fri Jul 7 15:39:55 CEST 2017
if the input doesn't have a valid channel layout, use the default one (wg4) and
drop extra channels via the trivial mixer.
---
src/audio_output/dec.c | 18 ++++++++++++++----
src/audio_output/filters.c | 26 ++++++++++++++++++++++++--
2 files changed, 38 insertions(+), 6 deletions(-)
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 157443635e..dbf707113a 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -45,11 +45,14 @@ int aout_DecNew( audio_output_t *p_aout,
const audio_replay_gain_t *p_replay_gain,
const aout_request_vout_t *p_request_vout )
{
- /* Sanitize audio format */
- unsigned i_channels = aout_FormatNbChannels( p_format );
- if( i_channels != p_format->i_channels && AOUT_FMT_LINEAR( p_format ) )
+
+ /* Sanitize audio format, input need to have a valid physical channels
+ * layout or a valid number of channels. */
+ int i_map_channels = aout_FormatNbChannels( p_format );
+ if( ( i_map_channels == 0 && p_format->i_channels == 0 )
+ || i_map_channels > AOUT_CHAN_MAX )
{
- msg_Err( p_aout, "incompatible audio channels count with layout mask" );
+ msg_Err( p_aout, "invalid audio channels count" );
return -1;
}
@@ -82,6 +85,13 @@ int aout_DecNew( audio_output_t *p_aout,
atomic_store (&owner->restart, 0);
owner->input_format = *p_format;
owner->mixer_format = owner->input_format;
+
+ if (i_map_channels == 0)
+ {
+ /* The output channel map is unknown, use the default one (wg4) */
+ assert(owner->mixer_format.i_channels > 0);
+ aout_SetDefaultPhysicalChannels(&owner->mixer_format);
+ }
owner->request_vout = *p_request_vout;
if (aout_OutputNew (p_aout, &owner->mixer_format))
diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index 400d6e72f7..ec868d4a43 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -442,12 +442,34 @@ aout_filters_t *aout_FiltersNew (vlc_object_t *obj,
}
return filters;
}
- if (aout_FormatNbChannels(infmt) == 0 || aout_FormatNbChannels(outfmt) == 0)
+ if (aout_FormatNbChannels(outfmt) == 0)
{
- msg_Warn (obj, "No channel mask, cannot setup filters");
+ msg_Warn (obj, "No ouput channel mask, cannot setup filters");
goto error;
}
+ if (aout_FormatNbChannels(&input_format) == 0)
+ {
+ /* The input channel map is unknown, use the default one (wg4) and add
+ * a converter that will drop extra channels that are not handled by
+ * VLC */
+ msg_Info(obj, "unknown channel map, using the wg4 one.");
+
+ assert(input_format.i_channels > 0);
+ audio_sample_format_t input_phys_format = input_format;
+ aout_SetDefaultPhysicalChannels(&input_phys_format);
+
+ filter_t *f = FindConverter (obj, &input_format, &input_phys_format);
+ if (f == NULL)
+ {
+ msg_Err (obj, "cannot find channel converter");
+ goto error;
+ }
+
+ input_format = input_phys_format;
+ filters->tab[filters->count++] = f;
+ }
+
/* parse user filter lists */
if (var_InheritBool (obj, "audio-time-stretch"))
{
--
2.11.0
More information about the vlc-devel
mailing list