Commit 5576aaac authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: revector filters chain (part 1)

This tries to make the aout filters reusable outside of the aout
(refs #8447).
parent 683f96fa
...@@ -44,6 +44,7 @@ typedef struct ...@@ -44,6 +44,7 @@ typedef struct
void *p_private; void *p_private;
} aout_request_vout_t; } aout_request_vout_t;
typedef struct aout_filters aout_filters_t;
typedef struct aout_volume aout_volume_t; typedef struct aout_volume aout_volume_t;
typedef struct aout_dev aout_dev_t; typedef struct aout_dev aout_dev_t;
...@@ -51,6 +52,7 @@ typedef struct ...@@ -51,6 +52,7 @@ typedef struct
{ {
vlc_mutex_t lock; vlc_mutex_t lock;
module_t *module; /**< Output plugin (or NULL if inactive) */ module_t *module; /**< Output plugin (or NULL if inactive) */
aout_filters_t *filters;
aout_volume_t *volume; aout_volume_t *volume;
struct struct
...@@ -79,14 +81,6 @@ typedef struct ...@@ -79,14 +81,6 @@ typedef struct
audio_sample_format_t input_format; audio_sample_format_t input_format;
audio_sample_format_t mixer_format; audio_sample_format_t mixer_format;
filter_t *rate_filter; /**< The filter adjusting samples count
(either the scaletempo filter or a resampler) */
filter_t *resampler; /**< The resampler */
int resampling; /**< Current resampling (Hz) */
unsigned nb_filters;
filter_t *filters[AOUT_MAX_FILTERS]; /**< Configured user filters
(e.g. equalization) and their conversions */
aout_request_vout_t request_vout; aout_request_vout_t request_vout;
bool recycle_vout; bool recycle_vout;
...@@ -110,11 +104,13 @@ static inline aout_owner_t *aout_owner (audio_output_t *aout) ...@@ -110,11 +104,13 @@ static inline aout_owner_t *aout_owner (audio_output_t *aout)
*****************************************************************************/ *****************************************************************************/
/* From filters.c : */ /* From filters.c : */
int aout_FiltersNew(audio_output_t *, const audio_sample_format_t *, aout_filters_t *aout_FiltersNew(audio_output_t *,
const audio_sample_format_t *, const aout_request_vout_t *); const audio_sample_format_t *,
void aout_FiltersDelete(audio_output_t *); const audio_sample_format_t *,
bool aout_FiltersAdjustResampling(audio_output_t *, int); const aout_request_vout_t *);
block_t *aout_FiltersPlay(audio_output_t *, block_t *, int rate); void aout_FiltersDelete(audio_output_t *, aout_filters_t *);
bool aout_FiltersAdjustResampling(aout_filters_t *, int);
block_t *aout_FiltersPlay(aout_filters_t *, block_t *, int rate);
/* From mixer.c : */ /* From mixer.c : */
aout_volume_t *aout_volume_New(vlc_object_t *, const audio_replay_gain_t *); aout_volume_t *aout_volume_New(vlc_object_t *, const audio_replay_gain_t *);
......
...@@ -84,8 +84,9 @@ int aout_DecNew( audio_output_t *p_aout, ...@@ -84,8 +84,9 @@ int aout_DecNew( audio_output_t *p_aout,
aout_volume_SetFormat (owner->volume, owner->mixer_format.i_format); aout_volume_SetFormat (owner->volume, owner->mixer_format.i_format);
/* Create the audio filtering "input" pipeline */ /* Create the audio filtering "input" pipeline */
if (aout_FiltersNew (p_aout, p_format, &owner->mixer_format, owner->filters = aout_FiltersNew (p_aout, p_format, &owner->mixer_format,
p_request_vout)) p_request_vout);
if (owner->filters == NULL)
{ {
aout_OutputDelete (p_aout); aout_OutputDelete (p_aout);
error: error:
...@@ -113,7 +114,7 @@ void aout_DecDelete (audio_output_t *aout) ...@@ -113,7 +114,7 @@ void aout_DecDelete (audio_output_t *aout)
aout_OutputLock (aout); aout_OutputLock (aout);
if (owner->mixer_format.i_format) if (owner->mixer_format.i_format)
{ {
aout_FiltersDelete (aout); aout_FiltersDelete (aout, owner->filters);
aout_OutputDelete (aout); aout_OutputDelete (aout);
} }
aout_volume_Delete (owner->volume); aout_volume_Delete (owner->volume);
...@@ -131,7 +132,7 @@ static int aout_CheckReady (audio_output_t *aout) ...@@ -131,7 +132,7 @@ static int aout_CheckReady (audio_output_t *aout)
const aout_request_vout_t request_vout = owner->request_vout; const aout_request_vout_t request_vout = owner->request_vout;
if (owner->mixer_format.i_format) if (owner->mixer_format.i_format)
aout_FiltersDelete (aout); aout_FiltersDelete (aout, owner->filters);
if (restart & AOUT_RESTART_OUTPUT) if (restart & AOUT_RESTART_OUTPUT)
{ /* Reinitializes the output */ { /* Reinitializes the output */
...@@ -149,14 +150,18 @@ static int aout_CheckReady (audio_output_t *aout) ...@@ -149,14 +150,18 @@ static int aout_CheckReady (audio_output_t *aout)
owner->sync.end = VLC_TS_INVALID; owner->sync.end = VLC_TS_INVALID;
owner->sync.resamp_type = AOUT_RESAMPLING_NONE; owner->sync.resamp_type = AOUT_RESAMPLING_NONE;
if (owner->mixer_format.i_format if (owner->mixer_format.i_format)
&& aout_FiltersNew (aout, &owner->input_format, &owner->mixer_format, {
&request_vout)) owner->filters = aout_FiltersNew (aout, &owner->input_format,
&owner->mixer_format,
&request_vout);
if (owner->filters == NULL)
{ {
aout_OutputDelete (aout); aout_OutputDelete (aout);
owner->mixer_format.i_format = 0; owner->mixer_format.i_format = 0;
} }
} }
}
return (owner->mixer_format.i_format) ? 0 : -1; return (owner->mixer_format.i_format) ? 0 : -1;
} }
...@@ -208,7 +213,7 @@ static void aout_StopResampling (audio_output_t *aout) ...@@ -208,7 +213,7 @@ static void aout_StopResampling (audio_output_t *aout)
aout_owner_t *owner = aout_owner (aout); aout_owner_t *owner = aout_owner (aout);
owner->sync.resamp_type = AOUT_RESAMPLING_NONE; owner->sync.resamp_type = AOUT_RESAMPLING_NONE;
aout_FiltersAdjustResampling (aout, 0); aout_FiltersAdjustResampling (owner->filters, 0);
} }
static void aout_DecSilence (audio_output_t *aout, mtime_t length, mtime_t pts) static void aout_DecSilence (audio_output_t *aout, mtime_t length, mtime_t pts)
...@@ -342,7 +347,7 @@ static void aout_DecSynchronize (audio_output_t *aout, mtime_t dec_pts, ...@@ -342,7 +347,7 @@ static void aout_DecSynchronize (audio_output_t *aout, mtime_t dec_pts,
* value, then it is time to switch back the resampling direction. */ * value, then it is time to switch back the resampling direction. */
adj *= -1; adj *= -1;
if (!aout_FiltersAdjustResampling (aout, adj)) if (!aout_FiltersAdjustResampling (owner->filters, adj))
{ /* Everything is back to normal: stop resampling. */ { /* Everything is back to normal: stop resampling. */
owner->sync.resamp_type = AOUT_RESAMPLING_NONE; owner->sync.resamp_type = AOUT_RESAMPLING_NONE;
msg_Dbg (aout, "resampling stopped (drift: %"PRId64" us)", drift); msg_Dbg (aout, "resampling stopped (drift: %"PRId64" us)", drift);
...@@ -384,7 +389,7 @@ int aout_DecPlay (audio_output_t *aout, block_t *block, int input_rate) ...@@ -384,7 +389,7 @@ int aout_DecPlay (audio_output_t *aout, block_t *block, int input_rate)
if (block->i_flags & BLOCK_FLAG_DISCONTINUITY) if (block->i_flags & BLOCK_FLAG_DISCONTINUITY)
owner->sync.discontinuity = true; owner->sync.discontinuity = true;
block = aout_FiltersPlay (aout, block, input_rate); block = aout_FiltersPlay (owner->filters, block, input_rate);
if (block == NULL) if (block == NULL)
goto lost; goto lost;
......
This diff is collapsed.
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