From 0b2223212b20910717d63d65517b4a8abe5d2bd4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 18 Dec 2013 23:43:55 +0000 Subject: Attempt to move resampling into AudioDecoder. --- src/lib/audio_decoder.cc | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/lib/audio_decoder.cc') diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 7ff8529c6..aecf39644 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -35,12 +35,33 @@ using boost::shared_ptr; AudioDecoder::AudioDecoder (shared_ptr film, shared_ptr content) : Decoder (film) , _audio_content (content) + , _last_audio (0) { - + if (content->output_audio_frame_rate() != content->content_audio_frame_rate() && content->audio_channels ()) { + _resampler.reset (new Resampler (content->content_audio_frame_rate(), content->output_audio_frame_rate(), content->audio_channels ())); + } } void AudioDecoder::audio (shared_ptr data, ContentTime time) { + if (_resampler) { + data = _resampler->run (data); + } + _pending.push_back (shared_ptr (new DecodedAudio (data, time))); + _last_audio = time + (data->frames() * TIME_HZ / _audio_content->output_audio_frame_rate()); +} + +void +AudioDecoder::flush () +{ + if (!_resampler) { + return; + } + + shared_ptr b = _resampler->flush (); + if (b) { + audio (b, _last_audio); + } } -- cgit v1.2.3