Commit d3a8b668 authored by Thomas Guillem's avatar Thomas Guillem

aout: handle exclusive_mode in filters

parent a4825f08
......@@ -511,11 +511,13 @@ typedef struct
* binauralizer audio filter).
*/
bool headphones;
enum vlc_aout_exclusive_mode exclusive_mode;
} aout_filters_cfg_t;
#define AOUT_FILTERS_CFG_INIT (aout_filters_cfg_t) \
{ .remap = AOUT_CHAN_REMAP_INIT, \
.headphones = false, \
.exclusive_mode = VLC_AOUT_EXCLUSIVE_OFF, \
};
typedef struct aout_filters aout_filters_t;
......
......@@ -98,6 +98,7 @@ int aout_DecNew(audio_output_t *p_aout, const audio_sample_format_t *p_format,
owner->sync.clock = clock;
owner->filters_cfg = AOUT_FILTERS_CFG_INIT;
owner->filters_cfg.exclusive_mode = owner->exclusive_mode;
if (aout_OutputNew (p_aout))
goto error;
aout_volume_SetFormat (owner->volume, owner->mixer_format.i_format);
......@@ -164,6 +165,7 @@ static int aout_CheckReady (audio_output_t *aout)
aout_OutputDelete (aout);
owner->filter_format = owner->mixer_format = owner->input_format;
owner->filters_cfg = AOUT_FILTERS_CFG_INIT;
owner->filters_cfg.exclusive_mode = owner->exclusive_mode;
if (aout_OutputNew (aout))
owner->mixer_format.i_format = 0;
aout_volume_SetFormat (owner->volume,
......
......@@ -582,35 +582,57 @@ aout_filters_t *aout_FiltersNewWithClock(vlc_object_t *obj, const vlc_clock_t *c
assert(input_format.channel_type == AUDIO_CHANNEL_TYPE_BITMAP);
/* parse user filter lists */
if (var_InheritBool (obj, "audio-time-stretch"))
bool exclusive_forced = false;
if (cfg)
{
if (AppendFilter(obj, "audio filter", "scaletempo",
filters, &input_format, &output_format, NULL) == 0)
filters->rate_filter = filters->tab[filters->count - 1];
if (cfg->exclusive_mode == VLC_AOUT_EXCLUSIVE_ON)
{
/* Exclusive mode is not possible if input and output formats don't
* match */
if (!AOUT_FMTS_IDENTICAL(&input_format, &output_format))
goto error;
return filters;
}
else if (cfg->exclusive_mode == VLC_AOUT_EXCLUSIVE_FORCED)
{
/* Forced exclusive mode is mode permissive. Allow to add visual
* filters and a converter, but don't insert any resamplers */
exclusive_forced = true;
}
}
if (cfg != NULL)
if (!exclusive_forced)
{
AppendRemapFilter(obj, filters, &input_format, &output_format,
cfg->remap);
/* parse user filter lists */
if (var_InheritBool (obj, "audio-time-stretch"))
{
if (AppendFilter(obj, "audio filter", "scaletempo",
filters, &input_format, &output_format, NULL) == 0)
filters->rate_filter = filters->tab[filters->count - 1];
}
if (input_format.i_channels > 2 && cfg->headphones)
AppendFilter(obj, "audio filter", "binauralizer", filters,
&input_format, &output_format, NULL);
}
if (cfg != NULL)
{
AppendRemapFilter(obj, filters, &input_format, &output_format,
cfg->remap);
/* Now add user filters */
char *str = var_InheritString (obj, "audio-filter");
if (str != NULL)
{
char *p = str, *name;
while ((name = strsep (&p, " :")) != NULL)
if (input_format.i_channels > 2 && cfg->headphones)
AppendFilter(obj, "audio filter", "binauralizer", filters,
&input_format, &output_format, NULL);
}
/* Now add user filters */
char *str = var_InheritString (obj, "audio-filter");
if (str != NULL)
{
AppendFilter(obj, "audio filter", name, filters,
&input_format, &output_format, NULL);
char *p = str, *name;
while ((name = strsep (&p, " :")) != NULL)
{
AppendFilter(obj, "audio filter", name, filters,
&input_format, &output_format, NULL);
}
free (str);
}
free (str);
}
char *visual = var_InheritString(obj, "audio-visual");
......@@ -630,17 +652,20 @@ aout_filters_t *aout_FiltersNewWithClock(vlc_object_t *obj, const vlc_clock_t *c
input_format = output_format;
/* insert the resampler */
output_format.i_rate = outfmt->i_rate;
assert (AOUT_FMTS_IDENTICAL(&output_format, outfmt));
filters->resampler = FindResampler (obj, &input_format,
&output_format);
if (filters->resampler == NULL && input_format.i_rate != outfmt->i_rate)
if (!exclusive_forced)
{
msg_Err (obj, "cannot setup a resampler");
goto error;
output_format.i_rate = outfmt->i_rate;
assert (AOUT_FMTS_IDENTICAL(&output_format, outfmt));
filters->resampler = FindResampler (obj, &input_format,
&output_format);
if (filters->resampler == NULL && input_format.i_rate != outfmt->i_rate)
{
msg_Err (obj, "cannot setup a resampler");
goto error;
}
if (filters->rate_filter == NULL)
filters->rate_filter = filters->resampler;
}
if (filters->rate_filter == NULL)
filters->rate_filter = filters->resampler;
return filters;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment