Commit 68239f63 authored by Thomas Guillem's avatar Thomas Guillem

aout: add a struct to configure the filter chain

parent 5fd35218
......@@ -350,6 +350,20 @@ static inline void aout_RestartRequest(audio_output_t *aout, unsigned mode)
}
/* Audio output filters */
typedef struct
{
/**
* If the remap order differs from the WG4 order, a remap audio filter will
* be inserted to remap channels according to this array.
*/
int remap[AOUT_CHANIDX_MAX];
} aout_filters_cfg_t;
#define AOUT_FILTERS_CFG_INIT (aout_filters_cfg_t) \
{ .remap = AOUT_CHAN_REMAP_INIT, \
};
typedef struct aout_filters aout_filters_t;
typedef struct aout_request_vout aout_request_vout_t;
......@@ -357,7 +371,7 @@ VLC_API aout_filters_t *aout_FiltersNew(vlc_object_t *,
const audio_sample_format_t *,
const audio_sample_format_t *,
const aout_request_vout_t *,
const int *remap) VLC_USED;
const aout_filters_cfg_t *cfg) VLC_USED;
#define aout_FiltersNew(o,inf,outf,rv,remap) \
aout_FiltersNew(VLC_OBJECT(o),inf,outf,rv,remap)
VLC_API void aout_FiltersDelete(vlc_object_t *, aout_filters_t *);
......
......@@ -79,7 +79,7 @@ typedef struct
audio_sample_format_t mixer_format;
aout_request_vout_t request_vout;
int remap[AOUT_CHANIDX_MAX];
aout_filters_cfg_t filters_cfg;
atomic_uint buffers_lost;
atomic_uint buffers_played;
......@@ -115,7 +115,8 @@ audio_output_t *aout_New (vlc_object_t *);
#define aout_New(a) aout_New(VLC_OBJECT(a))
void aout_Destroy (audio_output_t *);
int aout_OutputNew(audio_output_t *, audio_sample_format_t *, int *wg4_remap);
int aout_OutputNew(audio_output_t *, audio_sample_format_t *,
aout_filters_cfg_t *filters_cfg);
int aout_OutputTimeGet(audio_output_t *, mtime_t *);
void aout_OutputPlay(audio_output_t *, block_t *);
void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
......
......@@ -93,15 +93,15 @@ int aout_DecNew( audio_output_t *p_aout,
var_Change (p_aout, "stereo-mode", VLC_VAR_SETVALUE,
&(vlc_value_t) { .i_int = AOUT_VAR_CHAN_UNSET }, NULL);
int remap[] = AOUT_CHAN_REMAP_INIT;
if (aout_OutputNew (p_aout, &owner->mixer_format, remap))
owner->filters_cfg = AOUT_FILTERS_CFG_INIT;
if (aout_OutputNew (p_aout, &owner->mixer_format, &owner->filters_cfg))
goto error;
aout_volume_SetFormat (owner->volume, owner->mixer_format.i_format);
/* Create the audio filtering "input" pipeline */
memcpy(owner->remap, remap, sizeof(remap));
owner->filters = aout_FiltersNew (p_aout, p_format, &owner->mixer_format,
&owner->request_vout, owner->remap);
&owner->request_vout,
&owner->filters_cfg);
if (owner->filters == NULL)
{
aout_OutputDelete (p_aout);
......@@ -158,10 +158,9 @@ static int aout_CheckReady (audio_output_t *aout)
if (owner->mixer_format.i_format)
aout_OutputDelete (aout);
owner->mixer_format = owner->input_format;
int remap[] = AOUT_CHAN_REMAP_INIT;
if (aout_OutputNew (aout, &owner->mixer_format, remap))
owner->filters_cfg = AOUT_FILTERS_CFG_INIT;
if (aout_OutputNew (aout, &owner->mixer_format, &owner->filters_cfg))
owner->mixer_format.i_format = 0;
memcpy(owner->remap, remap, sizeof(remap));
aout_volume_SetFormat (owner->volume,
owner->mixer_format.i_format);
......@@ -182,7 +181,7 @@ static int aout_CheckReady (audio_output_t *aout)
owner->filters = aout_FiltersNew (aout, &owner->input_format,
&owner->mixer_format,
&owner->request_vout,
owner->remap);
&owner->filters_cfg);
if (owner->filters == NULL)
{
aout_OutputDelete (aout);
......
......@@ -470,9 +470,7 @@ static int AppendRemapFilter(vlc_object_t *obj, aout_filters_t *restrict filters
* \param infmt chain input format [IN]
* \param outfmt chain output format [IN]
* \param request_vout visualization video output request callback
* \param remap a const array of size AOUT_CHAN_MAX or NULL. If not NULL, a
* remap audio filter will be inserted to remap channels according to the
* array. The array is in the WG4 order.
* \param cfg a valid aout_filters_cfg_t struct or NULL.
* \return a filters chain or NULL on failure
*
* \note
......@@ -485,7 +483,7 @@ aout_filters_t *aout_FiltersNew (vlc_object_t *obj,
const audio_sample_format_t *restrict infmt,
const audio_sample_format_t *restrict outfmt,
const aout_request_vout_t *request_vout,
const int *remap)
const aout_filters_cfg_t *cfg)
{
aout_filters_t *filters = malloc (sizeof (*filters));
if (unlikely(filters == NULL))
......@@ -578,8 +576,9 @@ aout_filters_t *aout_FiltersNew (vlc_object_t *obj,
filters->rate_filter = filters->tab[filters->count - 1];
}
if (remap != NULL)
AppendRemapFilter(obj, filters, &input_format, &output_format, remap);
if (cfg != NULL)
AppendRemapFilter(obj, filters, &input_format, &output_format,
cfg->remap);
/* Now add user filters */
char *str = var_InheritString (obj, "audio-filter");
......
......@@ -386,7 +386,7 @@ static void aout_Destructor (vlc_object_t *obj)
* \warning The caller must hold the audio output lock.
*/
int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt,
int *remap)
aout_filters_cfg_t *filters_cfg)
{
aout_OutputAssertLocked (aout);
......@@ -457,16 +457,16 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt,
switch (i_forced_stereo_mode)
{
case AOUT_VAR_CHAN_RSTEREO:
remap[AOUT_CHANIDX_LEFT] = AOUT_CHANIDX_RIGHT;
remap[AOUT_CHANIDX_RIGHT] = AOUT_CHANIDX_LEFT;
filters_cfg->remap[AOUT_CHANIDX_LEFT] = AOUT_CHANIDX_RIGHT;
filters_cfg->remap[AOUT_CHANIDX_RIGHT] = AOUT_CHANIDX_LEFT;
break;
case AOUT_VAR_CHAN_STEREO:
break;
case AOUT_VAR_CHAN_LEFT:
remap[AOUT_CHANIDX_RIGHT] = AOUT_CHANIDX_DISABLE;
filters_cfg->remap[AOUT_CHANIDX_RIGHT] = AOUT_CHANIDX_DISABLE;
break;
case AOUT_VAR_CHAN_RIGHT:
remap[AOUT_CHANIDX_LEFT] = AOUT_CHANIDX_DISABLE;
filters_cfg->remap[AOUT_CHANIDX_LEFT] = AOUT_CHANIDX_DISABLE;
break;
case AOUT_VAR_CHAN_DOLBYS:
fmt->i_chan_mode = AOUT_CHANMODE_DOLBYSTEREO;
......@@ -474,7 +474,7 @@ int aout_OutputNew (audio_output_t *aout, audio_sample_format_t *restrict fmt,
default:
if (b_stereo_original && fmt->i_chan_mode & AOUT_CHANMODE_DUALMONO)
{ /* Go directly to the left channel. */
remap[AOUT_CHANIDX_RIGHT] = AOUT_CHANIDX_DISABLE;
filters_cfg->remap[AOUT_CHANIDX_RIGHT] = AOUT_CHANIDX_DISABLE;
default_val.i_int = val.i_int = AOUT_VAR_CHAN_LEFT;
}
var_Change (aout, "stereo-mode", VLC_VAR_SETVALUE, &default_val,
......
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