From fd6302631a537f198ba60ae29c8818111881b0b1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 29 Mar 2013 22:52:15 +0100 Subject: af: streamline format negotiation Add dummy input and output filters to remove special cases in the format negotiation code (af_fix_format_conversion() etc.). The output of the filter chain is now negotiated in exactly the same way as normal filters. Negotiate setting the sample rate in the same way as other audio parameters. As a side effect, the resampler is inserted at the start of the filter chain instead of the end, but that shouldn't matter much, especially since conversion and channel mixing are conflated into the same filter (due to libavresample's API). --- audio/decode/dec_audio.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'audio/decode') diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index 9d0e51629c..c7ae3155ed 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -183,7 +183,7 @@ 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); - free(sh_audio->afilter); + af_destroy(sh_audio->afilter); sh_audio->afilter = NULL; } if (sh_audio->initialized) { @@ -202,10 +202,8 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate, int *out_samplerate, int *out_channels, int *out_format) { struct af_stream *afs = sh_audio->afilter; - if (!afs) { - afs = calloc(1, sizeof(struct af_stream)); - afs->opts = sh_audio->opts; - } + if (!afs) + afs = af_new(sh_audio->opts); // input format: same as codec's output format: afs->input.rate = in_samplerate; afs->input.nch = sh_audio->channels; @@ -230,7 +228,7 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate, // let's autoprobe it! if (0 != af_init(afs)) { sh_audio->afilter = NULL; - free(afs); + af_destroy(afs); return 0; // failed :( } -- cgit v1.2.3