From 0da6975960aab345a1a8b30e6a95659cc936a1da Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 11 Apr 2014 10:21:02 +0100 Subject: [PATCH] Flush decoded_audio buffer on seek. --- src/lib/audio_decoder.cc | 12 ++++++++++-- src/lib/audio_decoder.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 6486d176a..17a534aa4 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -37,11 +37,18 @@ using boost::shared_ptr; AudioDecoder::AudioDecoder (shared_ptr content) : _audio_content (content) - , _decoded_audio (shared_ptr (new AudioBuffers (content->audio_channels(), 0)), 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 ())); } + + reset_decoded_audio (); +} + +void +AudioDecoder::reset_decoded_audio () +{ + _decoded_audio = ContentAudio (shared_ptr (new AudioBuffers (_audio_content->audio_channels(), 0)), 0); } shared_ptr @@ -106,7 +113,7 @@ AudioDecoder::audio (shared_ptr data, ContentTime time) _audio_position = time.frames (_audio_content->output_audio_frame_rate ()); } - assert (_audio_position >= (_decoded_audio.frame + _decoded_audio.audio->frames())); + assert (_audio_position.get() >= (_decoded_audio.frame + _decoded_audio.audio->frames())); /* Resize _decoded_audio to fit the new data */ int const new_size = _audio_position.get() + data->frames() - _decoded_audio.frame; @@ -139,4 +146,5 @@ void AudioDecoder::seek (ContentTime, bool) { _audio_position.reset (); + reset_decoded_audio (); } diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h index c83c356b7..0b0d306f6 100644 --- a/src/lib/audio_decoder.h +++ b/src/lib/audio_decoder.h @@ -57,6 +57,7 @@ protected: void seek (ContentTime time, bool accurate); void audio (boost::shared_ptr, ContentTime); void flush (); + void reset_decoded_audio (); boost::shared_ptr _audio_content; boost::shared_ptr _resampler; -- 2.30.2