[vlc-commits] aout: handle headphones in aout_filters_cfg_t
Thomas Guillem
git at videolan.org
Wed Jul 19 18:57:28 CEST 2017
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Jul 17 18:29:09 2017 +0200| [711650edc63ab53f98e6e8a759308dbde9ec199a] | committer: Thomas Guillem
aout: handle headphones in aout_filters_cfg_t
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=711650edc63ab53f98e6e8a759308dbde9ec199a
---
include/vlc_aout.h | 6 ++++++
src/audio_output/filters.c | 22 +++++++++++++++++-----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index 4548ad06f0..983936e7c9 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -358,10 +358,16 @@ typedef struct
* be inserted to remap channels according to this array.
*/
int remap[AOUT_CHANIDX_MAX];
+ /**
+ * If true, a filter will be inserted to add a headphones effect (like a
+ * binauralizer audio filter).
+ */
+ bool headphones;
} aout_filters_cfg_t;
#define AOUT_FILTERS_CFG_INIT (aout_filters_cfg_t) \
{ .remap = AOUT_CHAN_REMAP_INIT, \
+ .headphones = false, \
};
typedef struct aout_filters aout_filters_t;
diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index 334e8f5b7b..04b13dd8bd 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -147,7 +147,8 @@ 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)
+ const audio_sample_format_t *restrict outfmt,
+ bool headphones)
{
aout_FormatsPrint (obj, "conversion:", infmt, outfmt);
max -= *count;
@@ -197,8 +198,14 @@ 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, filter_type, NULL, NULL,
- &input, &output, NULL, true);
+ &input, &output, cfg, true);
+ if (cfg)
+ config_ChainDestroy(cfg);
+
if (f == NULL)
{
msg_Err (obj, "cannot find %s for conversion pipeline",
@@ -402,7 +409,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))
+ max - 1, infmt, &filter->fmt_in.audio, false))
{
msg_Err (filter, "cannot add user %s \"%s\" (skipped)", type, name);
module_unneed (filter, filter->p_module);
@@ -533,7 +540,8 @@ aout_filters_t *aout_FiltersNew (vlc_object_t *obj,
/* 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))
+ AOUT_MAX_FILTERS, &input_format, &output_format,
+ cfg->headphones))
{
msg_Warn (obj, "cannot setup audio renderer pipeline");
/* Fallback to bitmap without any conversions */
@@ -580,6 +588,10 @@ aout_filters_t *aout_FiltersNew (vlc_object_t *obj,
AppendRemapFilter(obj, filters, &input_format, &output_format,
cfg->remap);
+ if (input_format.i_channels > 2 && cfg->headphones)
+ AppendFilter(obj, "audio filter", "binauralizer", filters, NULL,
+ &input_format, &output_format, NULL);
+
/* Now add user filters */
char *str = var_InheritString (obj, "audio-filter");
if (str != NULL)
@@ -605,7 +617,7 @@ aout_filters_t *aout_FiltersNew (vlc_object_t *obj,
/* 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))
+ AOUT_MAX_FILTERS, &input_format, &output_format, false))
{
msg_Err (obj, "cannot setup filtering pipeline");
goto error;
More information about the vlc-commits
mailing list