summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2017-04-29 19:31:12 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2017-04-29 19:31:12 +0200
commit297f057c4af7155a1a3aa7eeaef543744d44834f (patch)
tree84c7066b3eb1d751b582b58c06bf7feeec399ce3 /src
parente117b30cd9a3729a9eabbdd4ef6aef1f432754eb (diff)
Fix crash on 'underrun' when c.font is not yet allocated but the preload cache has been used up.
Diffstat (limited to 'src')
-rw-r--r--src/audiocache.cc10
1 files changed, 10 insertions, 0 deletions
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;
}