X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Faudio_decoder.cc;h=f3251f306bf47284a71bc1d53917631e917c827b;hb=1c13441a19aa387ddd8ac0c972207ccbbe3114d8;hp=f425cf2808cfbf70d53f3ff2bf097a24ab0ba035;hpb=cc27c2716f755305d67f1e1ba828ecf37f8405dd;p=dcpomatic.git diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index f425cf280..f3251f306 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -17,6 +17,7 @@ */ +#include #include "audio_decoder.h" #include "audio_buffers.h" #include "audio_processor.h" @@ -79,10 +80,10 @@ AudioDecoder::get_audio (AudioFrame frame, AudioFrame length, bool accurate) */ if (accurate) { /* Keep stuffing data into _decoded_audio until we have enough data, or the subclass does not want to give us any more */ - while (!pass() && (_decoded_audio.frame > frame || (_decoded_audio.frame + _decoded_audio.audio->frames()) < end)) {} + while ((_decoded_audio.frame > frame || (_decoded_audio.frame + _decoded_audio.audio->frames()) < end) && !pass ()) {} decoded_offset = frame - _decoded_audio.frame; } else { - while (!pass() && _decoded_audio.audio->frames() < length) {} + while (_decoded_audio.audio->frames() < length && !pass ()) {} /* Use decoded_offset of 0, as we don't really care what frames we return */ } @@ -173,6 +174,13 @@ AudioDecoder::audio (shared_ptr data, ContentTime time) void AudioDecoder::add (shared_ptr data) { + if (!_audio_position) { + /* This should only happen when there is a seek followed by a flush, but + we need to cope with it. + */ + return; + } + /* Resize _decoded_audio to fit the new data */ int new_size = 0; if (_decoded_audio.audio->frames() == 0) {