summaryrefslogtreecommitdiffstats
path: root/audio/decode
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-04-05 19:47:51 +0200
committerwm4 <wm4@nowhere>2013-05-12 21:24:54 +0200
commitf7a427676c0fe3c12509e3d9a243301f93626b0a (patch)
tree8dc8a2371a3e561ebb03f0bd17c2d59135c9f872 /audio/decode
parent0042735d7aefb2f05a79ba2eae741a63f22ea0c9 (diff)
downloadmpv-f7a427676c0fe3c12509e3d9a243301f93626b0a.tar.bz2
mpv-f7a427676c0fe3c12509e3d9a243301f93626b0a.tar.xz
audio: add some setters for mp_audio, and require filters to use them
mp_audio has some redundant fields. Setters like mp_audio_set_format() initialize these properly. Also move the mp_audio struct to a the file audio.c. We can remove a mysterious line of code from af.c: in.format |= af_bits2fmt(in.bps * 8); I'm not sure if this was ever actually needed, or if it was some kind of "make it work" quick-fix that works against the way things were supposed to work. All filters etc. now set the format correctly, so if there ever was a need for this code, it's definitely gone.
Diffstat (limited to 'audio/decode')
-rw-r--r--audio/decode/dec_audio.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index c7ae3155ed..6c8804eec9 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -205,16 +205,14 @@ int init_audio_filters(sh_audio_t *sh_audio, int in_samplerate,
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;
- afs->input.format = sh_audio->sample_format;
- af_fix_parameters(&(afs->input));
+ afs->input.rate = in_samplerate;
+ mp_audio_set_num_channels(&afs->input, sh_audio->channels);
+ mp_audio_set_format(&afs->input, sh_audio->sample_format);
// output format: same as ao driver's input format (if missing, fallback to input)
- afs->output.rate = *out_samplerate;
- afs->output.nch = *out_channels;
- afs->output.format = *out_format;
- af_fix_parameters(&(afs->output));
+ afs->output.rate = *out_samplerate;
+ mp_audio_set_num_channels(&afs->output, *out_channels);
+ mp_audio_set_format(&afs->output, *out_format);
// filter config:
memcpy(&afs->cfg, &af_cfg, sizeof(struct af_cfg));
@@ -284,10 +282,10 @@ static int filter_n_bytes(sh_audio_t *sh, struct bstr *outbuf, int len)
.audio = sh->a_buffer,
.len = len,
.rate = sh->samplerate,
- .nch = sh->channels,
- .format = sh->sample_format
};
- af_fix_parameters(&filter_input);
+ mp_audio_set_format(&filter_input, sh->sample_format);
+ mp_audio_set_num_channels(&filter_input, sh->channels);
+
struct mp_audio *filter_output = af_play(sh->afilter, &filter_input);
if (!filter_output)
return -1;