[vlc-devel] [RFC PATCH 2/3] filter: add aout_FiltersDrain
Thomas Guillem
thomas at gllm.fr
Tue Nov 3 12:39:59 CET 2015
---
include/vlc_aout.h | 1 +
include/vlc_filter.h | 1 +
src/audio_output/filters.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++
src/libvlccore.sym | 1 +
4 files changed, 68 insertions(+)
diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index 630be72..0e5c887 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -336,6 +336,7 @@ VLC_API void aout_FiltersDelete(vlc_object_t *, aout_filters_t *);
aout_FiltersDelete(VLC_OBJECT(o),f)
VLC_API bool aout_FiltersAdjustResampling(aout_filters_t *, int);
VLC_API block_t *aout_FiltersPlay(aout_filters_t *, block_t *, int rate);
+VLC_API block_t *aout_FiltersDrain(aout_filters_t *);
VLC_API vout_thread_t * aout_filter_RequestVout( filter_t *, vout_thread_t *p_vout, video_format_t *p_fmt );
diff --git a/include/vlc_filter.h b/include/vlc_filter.h
index f2edd80..513ef0a 100644
--- a/include/vlc_filter.h
+++ b/include/vlc_filter.h
@@ -106,6 +106,7 @@ struct filter_t
struct
{
+ /* block_t can be null when the filter is draining */
block_t * (*pf_filter) ( filter_t *, block_t * );
} audio;
#define pf_audio_filter u.audio.pf_filter
diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index 74c5a6a..decf03b 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -269,6 +269,39 @@ static block_t *aout_FiltersPipelinePlay(filter_t *const *filters,
return block;
}
+
+/**
+ * Drain the chain of filters.
+ */
+static block_t *aout_FiltersPipelineDrain(filter_t *const *filters,
+ unsigned count)
+{
+ block_t *chain = NULL;
+
+ for (unsigned i = 0; i < count; i++)
+ {
+ filter_t *filter = filters[i];
+
+ block_t *block = filter->pf_audio_filter (filter, NULL);
+ if (block)
+ {
+ /* If there is a drained block, filter it through the following
+ * chain of filters */
+ if (i + 1 < count)
+ block = aout_FiltersPipelinePlay (&filters[i + 1],
+ count - i - 1, block);
+ if (block)
+ block_ChainAppend (&chain, block);
+ }
+ }
+
+ if (chain)
+ return block_ChainGather(chain);
+ else
+ return NULL;
+}
+
+
#define AOUT_MAX_FILTERS 10
struct aout_filters
@@ -549,3 +582,35 @@ drop:
block_Release (block);
return NULL;
}
+
+block_t *aout_FiltersDrain (aout_filters_t *filters)
+{
+ /* Drain the filters pipeline */
+ block_t *block = aout_FiltersPipelineDrain (filters->tab, filters->count);
+
+ if (filters->resampler != NULL)
+ {
+ block_t *chain = NULL;
+
+ filters->resampler->fmt_in.audio.i_rate += filters->resampling;
+
+ if (block)
+ {
+ /* Resample the drained block from the filters pipeline */
+ block = aout_FiltersPipelinePlay (&filters->resampler, 1, block);
+ if (block)
+ block_ChainAppend (&chain, block);
+ }
+
+ /* Drain the resampler filter */
+ block = aout_FiltersPipelineDrain (&filters->resampler, 1);
+ if (block)
+ block_ChainAppend (&chain, block);
+
+ filters->resampler->fmt_in.audio.i_rate -= filters->resampling;
+
+ return block_ChainGather (chain);
+ }
+ else
+ return block;
+}
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 185f02e..505e1d3 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -22,6 +22,7 @@ aout_DeviceSet
aout_DevicesList
aout_FiltersNew
aout_FiltersDelete
+aout_FiltersDrain
aout_FiltersPlay
aout_FiltersAdjustResampling
block_Alloc
--
2.1.4
More information about the vlc-devel
mailing list