[vlc-devel] [PATCHv2 1/9] aout: filters: expose CreateFilter internally
Thomas Guillem
thomas at gllm.fr
Wed Aug 19 21:25:55 CEST 2020
And change the clock argument to a filter_owner_t.
---
src/audio_output/aout_internal.h | 6 ++++++
src/audio_output/filters.c | 30 ++++++++++++++++--------------
2 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 8b563012e25..78db9857d31 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -192,5 +192,11 @@ aout_filters_t *aout_FiltersNewWithClock(vlc_object_t *, const vlc_clock_t *,
void aout_FiltersResetClock(aout_filters_t *filters);
void aout_FiltersSetClockDelay(aout_filters_t *filters, vlc_tick_t delay);
bool aout_FiltersCanResample (aout_filters_t *filters);
+filter_t *aout_filter_Create(vlc_object_t *obj, const filter_owner_t *restrict owner,
+ const char *type, const char *name,
+ const audio_sample_format_t *infmt,
+ const audio_sample_format_t *outfmt,
+ config_chain_t *cfg, bool const_fmt);
+
#endif /* !LIBVLC_AOUT_INTERNAL_H */
diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c
index a297f4c6974..11a77e95b1f 100644
--- a/src/audio_output/filters.c
+++ b/src/audio_output/filters.c
@@ -40,17 +40,18 @@
#include "aout_internal.h"
#include "../video_output/vout_internal.h" /* for vout_Request */
-static filter_t *CreateFilter(vlc_object_t *obj, vlc_clock_t *clock,
- const char *type, const char *name,
- const audio_sample_format_t *infmt,
- const audio_sample_format_t *outfmt,
- config_chain_t *cfg, bool const_fmt)
+filter_t *aout_filter_Create(vlc_object_t *obj, const filter_owner_t *restrict owner,
+ const char *type, const char *name,
+ const audio_sample_format_t *infmt,
+ const audio_sample_format_t *outfmt,
+ config_chain_t *cfg, bool const_fmt)
{
filter_t *filter = vlc_custom_create (obj, sizeof (*filter), type);
if (unlikely(filter == NULL))
return NULL;
- filter->owner.sys = clock;
+ if (owner != NULL)
+ filter->owner = *owner;
filter->p_cfg = cfg;
filter->fmt_in.audio = *infmt;
filter->fmt_in.i_codec = infmt->i_format;
@@ -91,8 +92,8 @@ static filter_t *FindConverter (vlc_object_t *obj,
const audio_sample_format_t *infmt,
const audio_sample_format_t *outfmt)
{
- return CreateFilter(obj, NULL, "audio converter", NULL, infmt, outfmt,
- NULL, true);
+ return aout_filter_Create(obj, NULL, "audio converter", NULL, infmt, outfmt,
+ NULL, true);
}
static filter_t *FindResampler (vlc_object_t *obj,
@@ -100,8 +101,8 @@ static filter_t *FindResampler (vlc_object_t *obj,
const audio_sample_format_t *outfmt)
{
char *modlist = var_InheritString(obj, "audio-resampler");
- filter_t *filter = CreateFilter(obj, NULL, "audio resampler", modlist,
- infmt, outfmt, NULL, true);
+ filter_t *filter = aout_filter_Create(obj, NULL, "audio resampler", modlist,
+ infmt, outfmt, NULL, true);
free(modlist);
return filter;
}
@@ -206,8 +207,8 @@ static int aout_FiltersPipelineCreate(vlc_object_t *obj, filter_t **filters,
config_chain_t *cfg = NULL;
if (headphones)
config_ChainParseOptions(&cfg, "{headphones=true}");
- filter_t *f = CreateFilter(obj, NULL, filter_type, NULL,
- &input, &output, cfg, true);
+ filter_t *f = aout_filter_Create(obj, NULL, filter_type, NULL,
+ &input, &output, cfg, true);
if (cfg)
config_ChainDestroy(cfg);
@@ -415,8 +416,9 @@ static int AppendFilter(vlc_object_t *obj, const char *type, const char *name,
return -1;
}
- filter_t *filter = CreateFilter(obj, filters->clock, type, name,
- infmt, outfmt, cfg, false);
+ const filter_owner_t owner = { .sys = filters->clock };
+ filter_t *filter = aout_filter_Create(obj, &owner, type, name,
+ infmt, outfmt, cfg, false);
if (filter == NULL)
{
msg_Err (obj, "cannot add user %s \"%s\" (skipped)", type, name);
--
2.28.0
More information about the vlc-devel
mailing list