summaryrefslogtreecommitdiffstats
path: root/audio/decode/dec_audio.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-23 21:25:05 +0100
committerwm4 <wm4@nowhere>2013-11-23 21:25:05 +0100
commite174d31fdda78374600878699ef911fd09f55a26 (patch)
tree63cd9b7023e1a198dbbea097887a16a793f2f9b5 /audio/decode/dec_audio.c
parent0f5ec05d8f4ae02262dc79a895bce3b465b376f2 (diff)
downloadmpv-e174d31fdda78374600878699ef911fd09f55a26.tar.bz2
mpv-e174d31fdda78374600878699ef911fd09f55a26.tar.xz
audio: don't write decoded audio format to sh_audio
sh_audio is supposed to contain file headers, not whatever was decoded. Fix this, and write the decoded format to separate fields in the decoder context, the dec_audio.decoded field. (Note that this field is really only needed to communicate the audio format from decoder driver to the generic code, so no other code accesses it.)
Diffstat (limited to 'audio/decode/dec_audio.c')
-rw-r--r--audio/decode/dec_audio.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index 39ee3d5695..566bade875 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -66,9 +66,7 @@ static const struct ad_functions * const ad_drivers[] = {
// Drop audio buffer and reinit it (after format change)
static void reinit_audio_buffer(struct dec_audio *da)
{
- struct sh_audio *sh = da->header->audio;
- mp_audio_buffer_reinit_fmt(da->decode_buffer, sh->sample_format,
- &sh->channels, sh->samplerate);
+ mp_audio_buffer_reinit(da->decode_buffer, &da->decoded);
mp_audio_buffer_preallocate_min(da->decode_buffer, DECODE_BUFFER_SAMPLES);
}
@@ -100,9 +98,8 @@ static int init_audio_codec(struct dec_audio *d_audio, const char *decoder)
d_audio->initialized = 1;
- struct sh_audio *sh = d_audio->header->audio;
- if (mp_chmap_is_empty(&sh->channels) || !sh->samplerate ||
- !sh->sample_format)
+ if (!d_audio->decoded.channels.num || !d_audio->decoded.rate ||
+ !d_audio->decoded.format)
{
mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Audio decoder did not specify "
"audio format!\n");
@@ -177,12 +174,12 @@ int audio_init_best_codec(struct dec_audio *d_audio, char *audio_decoders)
d_audio->decoder_desc);
mp_msg(MSGT_DECAUDIO, MSGL_V,
"AUDIO: %d Hz, %d ch, %s\n",
- d_audio->header->audio->samplerate, d_audio->header->audio->channels.num,
- af_fmt_to_str(d_audio->header->audio->sample_format));
+ d_audio->decoded.rate, d_audio->decoded.channels.num,
+ af_fmt_to_str(d_audio->decoded.format));
mp_msg(MSGT_IDENTIFY, MSGL_INFO,
"ID_AUDIO_BITRATE=%d\nID_AUDIO_RATE=%d\n" "ID_AUDIO_NCH=%d\n",
- d_audio->i_bps * 8, d_audio->header->audio->samplerate,
- d_audio->header->audio->channels.num);
+ d_audio->i_bps * 8, d_audio->decoded.rate,
+ d_audio->decoded.channels.num);
} else {
mp_msg(MSGT_DECAUDIO, MSGL_ERR,
"Failed to initialize an audio decoder for codec '%s'.\n",
@@ -269,11 +266,7 @@ static int filter_n_bytes(struct dec_audio *da, struct mp_audio_buffer *outbuf,
// Commit the data just read as valid data
mp_audio_buffer_finish_write(da->decode_buffer, buffer.samples);
// Format change
- struct sh_audio *sh = da->header->audio;
- if (sh->samplerate != config.rate ||
- !mp_chmap_equals(&sh->channels, &config.channels) ||
- sh->sample_format != config.format)
- {
+ if (!mp_audio_config_equals(&da->decoded, &config)) {
// If there are still samples left in the buffer, let them drain
// first, and don't signal a format change to the caller yet.
if (mp_audio_buffer_samples(da->decode_buffer) > 0)