[vlc-devel] [RFC PATCH 2/5] aout: add aout_FiltersFailed
Thomas Guillem
thomas at gllm.fr
Thu Feb 28 16:59:51 CET 2019
Returns true if the aout filter chain failed.
---
include/vlc_aout.h | 1 +
src/audio_output/filters.c | 39 +++++++++++++++++++++++++++++---------
src/libvlccore.sym | 1 +
3 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index 11209ee0ce..a2d6d25cad 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -506,6 +506,7 @@ VLC_API block_t *aout_FiltersPlay(aout_filters_t *, block_t *, float rate);
VLC_API block_t *aout_FiltersDrain(aout_filters_t *);
VLC_API void aout_FiltersFlush(aout_filters_t *);
VLC_API void aout_FiltersChangeViewpoint(aout_filters_t *, const vlc_viewpoint_t *vp);
+VLC_API bool aout_FiltersFailed(aout_filters_t *);
VLC_API vout_thread_t *aout_filter_GetVout(filter_t *, const video_format_t *);
diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index b62cf93f04..9c0308e1d5 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -275,7 +275,8 @@ error:
* Filters an audio buffer through a chain of filters.
*/
static block_t *aout_FiltersPipelinePlay(filter_t *const *filters,
- unsigned count, block_t *block)
+ unsigned count, block_t *block,
+ bool *error)
{
/* TODO: use filter chain */
for (unsigned i = 0; (i < count) && (block != NULL); i++)
@@ -285,6 +286,11 @@ static block_t *aout_FiltersPipelinePlay(filter_t *const *filters,
/* Please note that p_block->i_nb_samples & i_buffer
* shall be set by the filter plug-in. */
block = filter->pf_audio_filter (filter, block);
+ if (!block && filter->error)
+ {
+ *error = true;
+ return NULL;
+ }
}
return block;
}
@@ -294,7 +300,7 @@ static block_t *aout_FiltersPipelinePlay(filter_t *const *filters,
* Drain the chain of filters.
*/
static block_t *aout_FiltersPipelineDrain(filter_t *const *filters,
- unsigned count)
+ unsigned count, bool *error)
{
block_t *chain = NULL;
@@ -309,10 +315,12 @@ static block_t *aout_FiltersPipelineDrain(filter_t *const *filters,
* chain of filters */
if (i + 1 < count)
block = aout_FiltersPipelinePlay (&filters[i + 1],
- count - i - 1, block);
+ count - i - 1, block, error);
if (block)
block_ChainAppend (&chain, block);
}
+ else if (filter->error)
+ *error = true;
}
if (chain)
@@ -351,6 +359,7 @@ struct aout_filters
unsigned count; /**< Number of filters */
filter_t *tab[AOUT_MAX_FILTERS]; /**< Configured user filters
(e.g. equalization) and their conversions */
+ bool failed;
};
/** Callback for visualization selection */
@@ -506,6 +515,7 @@ aout_filters_t *aout_FiltersNew(vlc_object_t *obj,
filters->resampler = NULL;
filters->resampling = 0;
filters->count = 0;
+ filters->failed = false;
/* Prepare format structure */
aout_FormatPrint (obj, "input", infmt);
@@ -698,12 +708,14 @@ block_t *aout_FiltersPlay(aout_filters_t *filters, block_t *block, float rate)
rate_filter->fmt_in.audio.i_rate = lroundf(nominal_rate * rate);
}
- block = aout_FiltersPipelinePlay (filters->tab, filters->count, block);
- if (filters->resampler != NULL)
+ block = aout_FiltersPipelinePlay (filters->tab, filters->count, block,
+ &filters->failed);
+ if (filters->resampler != NULL && !filters->failed)
{ /* NOTE: the resampler needs to run even if resampling is 0.
* The decoder and output rates can still be different. */
filters->resampler->fmt_in.audio.i_rate += filters->resampling;
- block = aout_FiltersPipelinePlay (&filters->resampler, 1, block);
+ block = aout_FiltersPipelinePlay (&filters->resampler, 1, block,
+ &filters->failed);
filters->resampler->fmt_in.audio.i_rate -= filters->resampling;
}
@@ -722,7 +734,8 @@ drop:
block_t *aout_FiltersDrain (aout_filters_t *filters)
{
/* Drain the filters pipeline */
- block_t *block = aout_FiltersPipelineDrain (filters->tab, filters->count);
+ block_t *block = aout_FiltersPipelineDrain (filters->tab, filters->count,
+ &filters->failed);
if (filters->resampler != NULL)
{
@@ -733,13 +746,15 @@ block_t *aout_FiltersDrain (aout_filters_t *filters)
if (block)
{
/* Resample the drained block from the filters pipeline */
- block = aout_FiltersPipelinePlay (&filters->resampler, 1, block);
+ block = aout_FiltersPipelinePlay (&filters->resampler, 1, block,
+ &filters->failed);
if (block)
block_ChainAppend (&chain, block);
}
/* Drain the resampler filter */
- block = aout_FiltersPipelineDrain (&filters->resampler, 1);
+ block = aout_FiltersPipelineDrain (&filters->resampler, 1,
+ &filters->failed);
if (block)
block_ChainAppend (&chain, block);
@@ -757,6 +772,7 @@ void aout_FiltersFlush (aout_filters_t *filters)
if (filters->resampler != NULL)
aout_FiltersPipelineFlush (&filters->resampler, 1);
+ filters->failed = false;
}
void aout_FiltersChangeViewpoint (aout_filters_t *filters,
@@ -764,3 +780,8 @@ void aout_FiltersChangeViewpoint (aout_filters_t *filters,
{
aout_FiltersPipelineChangeViewpoint (filters->tab, filters->count, vp);
}
+
+bool aout_FiltersFailed(aout_filters_t *filters)
+{
+ return filters->failed;
+}
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index a861c988e5..15d83e3a2a 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -25,6 +25,7 @@ aout_FiltersNew
aout_FiltersChangeViewpoint
aout_FiltersDelete
aout_FiltersDrain
+aout_FiltersFailed
aout_FiltersFlush
aout_FiltersPlay
aout_FiltersAdjustResampling
--
2.20.1
More information about the vlc-devel
mailing list