summaryrefslogtreecommitdiffstats
path: root/audio/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-03-29 22:52:15 +0100
committerwm4 <wm4@nowhere>2013-04-13 04:21:29 +0200
commitfd6302631a537f198ba60ae29c8818111881b0b1 (patch)
tree9e84562f72cf5c9ccea553bdcb1287b383d8abab /audio/decode
parentd2c20f4cfbfe01bdf63c2a76f20d39212598440e (diff)
downloadmpv-fd6302631a537f198ba60ae29c8818111881b0b1.tar.bz2
mpv-fd6302631a537f198ba60ae29c8818111881b0b1.tar.xz
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).
Diffstat (limited to 'audio/decode')
-rw-r--r--audio/decode/dec_audio.c10
1 files changed, 4 insertions, 6 deletions
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 :(
}