From 3b8dfddb4cb6e9431da659b10c5b31a9f17c81b5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 22 Jul 2013 14:43:58 +0200 Subject: audio/filter: use new option API Make the VF/VO/AO option parser available to audio filters. No audio filter uses this yet, but it's still a quite intrusive change. In particular, the commands for manipulating filters at runtime completely change. We delete the old code, and use the same infrastructure as for video filters. (This forces complete reinitialization of the filter chain, which hopefully isn't a problem for any use cases. The old code forced reinitialization too, but it could potentially allow a filter to cache things; e.g. consider loaded ladspa plugins and such.) --- audio/decode/dec_audio.c | 17 +++++------------ audio/decode/dec_audio.h | 2 -- 2 files changed, 5 insertions(+), 14 deletions(-) (limited to 'audio/decode') diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index 48a3512ee6..a73027e224 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -54,8 +54,6 @@ static const struct ad_functions * const ad_drivers[] = { NULL }; -struct af_cfg af_cfg = {0}; // Configuration for audio filters - static int init_audio_codec(sh_audio_t *sh_audio, const char *decoder) { assert(!sh_audio->initialized); @@ -180,7 +178,6 @@ void uninit_audio(sh_audio_t *sh_audio) { if (sh_audio->afilter) { mp_msg(MSGT_DECAUDIO, MSGL_V, "Uninit audio filters...\n"); - af_uninit(sh_audio->afilter); af_destroy(sh_audio->afilter); sh_audio->afilter = NULL; } @@ -199,9 +196,10 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate, int *out_samplerate, struct mp_chmap *out_channels, int *out_format) { + if (!sh_audio->afilter) + sh_audio->afilter = af_new(sh_audio->opts); struct af_stream *afs = sh_audio->afilter; - if (!afs) - afs = af_new(sh_audio->opts); + // input format: same as codec's output format: afs->input.rate = in_samplerate; mp_audio_set_channels(&afs->input, &sh_audio->channels); @@ -212,9 +210,6 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate, mp_audio_set_channels(&afs->output, out_channels); mp_audio_set_format(&afs->output, *out_format); - // filter config: - memcpy(&afs->cfg, &af_cfg, sizeof(struct af_cfg)); - char *s_from = mp_audio_config_to_str(&afs->input); char *s_to = mp_audio_config_to_str(&afs->output); mp_tmsg(MSGT_DECAUDIO, MSGL_V, @@ -223,9 +218,9 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate, talloc_free(s_to); // let's autoprobe it! - if (0 != af_init(afs)) { - sh_audio->afilter = NULL; + if (af_init(afs) != 0) { af_destroy(afs); + sh_audio->afilter = NULL; return 0; // failed :( } @@ -233,8 +228,6 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate, *out_channels = afs->output.channels; *out_format = afs->output.format; - // ok! - sh_audio->afilter = (void *) afs; return 1; } diff --git a/audio/decode/dec_audio.h b/audio/decode/dec_audio.h index 7a044e2040..b46f4282fb 100644 --- a/audio/decode/dec_audio.h +++ b/audio/decode/dec_audio.h @@ -37,6 +37,4 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate, int *out_samplerate, struct mp_chmap *out_channels, int *out_format); -extern struct af_cfg af_cfg; - #endif /* MPLAYER_DEC_AUDIO_H */ -- cgit v1.2.3