Don't automatically call pass() without first checking to see if we have
authorCarl Hetherington <cth@carlh.net>
Tue, 9 Sep 2014 23:51:31 +0000 (00:51 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 9 Sep 2014 23:51:31 +0000 (00:51 +0100)
what we need; otherwise we can keep calling pass() unnecessarily which
causes a build-up of data which is eventually trimmed to save memory.

src/lib/audio_decoder.cc

index f425cf2808cfbf70d53f3ff2bf097a24ab0ba035..12580c5f64972fd64498697e1f5dce7b4635af3d 100644 (file)
@@ -79,10 +79,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 */
        }