From f7a427676c0fe3c12509e3d9a243301f93626b0a Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 5 Apr 2013 19:47:51 +0200 Subject: 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. --- audio/decode/dec_audio.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'audio/decode') 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; -- cgit v1.2.3