From 297f057c4af7155a1a3aa7eeaef543744d44834f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 29 Apr 2017 19:31:12 +0200 Subject: Fix crash on 'underrun' when c.font is not yet allocated but the preload cache has been used up. --- src/audiocache.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/audiocache.cc b/src/audiocache.cc index b01d752..73ceadb 100644 --- a/src/audiocache.cc +++ b/src/audiocache.cc @@ -98,6 +98,7 @@ sample_t* AudioCache::open(const AudioFile& file, // Next call to 'next()' will read from this point. c.localpos = initial_samples_needed; + c.ready = false; c.front = nullptr; // This is allocated when needed. c.back = nullptr; // This is allocated when needed. @@ -186,6 +187,14 @@ sample_t* AudioCache::next(cacheid_t id, std::size_t& size) // We are playing from cache: if(c.localpos < chunk_size) { + if(c.front == nullptr) + { + // Just return silence. + settings.number_of_underruns.fetch_add(1); + assert(nodata); + return nodata; + } + sample_t* s = c.front + c.localpos; c.localpos += framesize; return s; @@ -197,6 +206,7 @@ sample_t* AudioCache::next(cacheid_t id, std::size_t& size) { // Just return silence. settings.number_of_underruns.fetch_add(1); + assert(nodata); return nodata; } -- cgit v1.2.3