[vlc-devel] [PATCH 5/6] aout: use a new i_chan_mode for binaural
Thomas Guillem
thomas at gllm.fr
Thu Jul 16 14:25:34 CEST 2020
Instead of using a custom cfg.
i_chan_mode is already used by the dolbystereo. "audio converter".
---
include/vlc_es.h | 1 +
.../audio_filter/channel_mixer/spatialaudio.cpp | 5 +----
src/audio_output/filters.c | 17 +++++------------
src/audio_output/output.c | 1 +
4 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/include/vlc_es.h b/include/vlc_es.h
index f1ef54283fb..389935df743 100644
--- a/include/vlc_es.h
+++ b/include/vlc_es.h
@@ -170,6 +170,7 @@ static const uint16_t vlc_chan_maps[] =
/* Values available for i_chan_mode only */
#define AOUT_CHANMODE_DUALMONO 0x1
#define AOUT_CHANMODE_DOLBYSTEREO 0x2
+#define AOUT_CHANMODE_BINAURAL 0x4
/**
* Picture orientation.
diff --git a/modules/audio_filter/channel_mixer/spatialaudio.cpp b/modules/audio_filter/channel_mixer/spatialaudio.cpp
index acb9ed0b75b..7671b5b7aa2 100644
--- a/modules/audio_filter/channel_mixer/spatialaudio.cpp
+++ b/modules/audio_filter/channel_mixer/spatialaudio.cpp
@@ -454,12 +454,9 @@ static int Open(vlc_object_t *p_this)
msg_Dbg(p_filter, "Order: %d %d %d", p_sys->i_order, p_sys->i_nondiegetic, infmt->i_channels);
- static const char *const options[] = { "headphones", NULL };
- config_ChainParse(p_filter, CFG_PREFIX, options, p_filter->p_cfg);
-
unsigned i_tailLength = 0;
if (p_filter->fmt_out.audio.i_channels == 2
- && var_InheritBool(p_filter, CFG_PREFIX "headphones"))
+ && p_filter->fmt_out.audio.i_chan_mode == AOUT_CHANMODE_BINAURAL)
{
p_sys->mode = filter_spatialaudio::AMBISONICS_BINAURAL_DECODER;
diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index a297f4c6974..79e90eeea94 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -148,8 +148,7 @@ static filter_t *TryFormat (vlc_object_t *obj, vlc_fourcc_t codec,
static int aout_FiltersPipelineCreate(vlc_object_t *obj, filter_t **filters,
unsigned *count, unsigned max,
const audio_sample_format_t *restrict infmt,
- const audio_sample_format_t *restrict outfmt,
- bool headphones)
+ const audio_sample_format_t *restrict outfmt)
{
aout_FormatsPrint (obj, "conversion:", infmt, outfmt);
max -= *count;
@@ -203,13 +202,8 @@ static int aout_FiltersPipelineCreate(vlc_object_t *obj, filter_t **filters,
infmt->channel_type != outfmt->channel_type ?
"audio renderer" : "audio converter";
- config_chain_t *cfg = NULL;
- if (headphones)
- config_ChainParseOptions(&cfg, "{headphones=true}");
filter_t *f = CreateFilter(obj, NULL, filter_type, NULL,
- &input, &output, cfg, true);
- if (cfg)
- config_ChainDestroy(cfg);
+ &input, &output, NULL, true);
if (f == NULL)
{
@@ -425,7 +419,7 @@ static int AppendFilter(vlc_object_t *obj, const char *type, const char *name,
/* convert to the filter input format if necessary */
if (aout_FiltersPipelineCreate (obj, filters->tab, &filters->count,
- max - 1, infmt, &filter->fmt_in.audio, false))
+ max - 1, infmt, &filter->fmt_in.audio))
{
msg_Err (filter, "cannot add user %s \"%s\" (skipped)", type, name);
module_unneed (filter, filter->p_module);
@@ -546,8 +540,7 @@ aout_filters_t *aout_FiltersNewWithClock(vlc_object_t *obj, const vlc_clock_t *c
/* 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,
- cfg->headphones))
+ AOUT_MAX_FILTERS, &input_format, &output_format))
{
msg_Warn (obj, "cannot setup audio renderer pipeline");
/* Fallback to bitmap without any conversions */
@@ -622,7 +615,7 @@ aout_filters_t *aout_FiltersNewWithClock(vlc_object_t *obj, const vlc_clock_t *c
/* 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, false))
+ AOUT_MAX_FILTERS, &input_format, &output_format))
{
msg_Err (obj, "cannot setup filtering pipeline");
goto error;
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index cbcabf881a2..48b5dffd496 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -505,6 +505,7 @@ static void aout_UpdateStereoMode(audio_output_t *aout, int mode,
case AOUT_VAR_CHAN_HEADPHONES:
filters_cfg->headphones = true;
fmt->i_physical_channels = AOUT_CHANS_STEREO;
+ fmt->i_chan_mode = AOUT_CHANMODE_BINAURAL;
break;
case AOUT_VAR_CHAN_MONO:
/* Remix all channels into one */
--
2.20.1
More information about the vlc-devel
mailing list