summaryrefslogtreecommitdiff
path: root/src/audiocachefile.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-01-28 11:41:18 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2016-01-28 11:41:18 +0100
commit3e829110a40f811a0216e3bc648bc7f2485f3b4d (patch)
tree807f931540ce39e8550d4c352e76e8b83c68caea /src/audiocachefile.cc
parent3cf2aec198526b2decd147a3d5a4c3e70a9708ef (diff)
Handle sndffile open failure.
Diffstat (limited to 'src/audiocachefile.cc')
-rw-r--r--src/audiocachefile.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/audiocachefile.cc b/src/audiocachefile.cc
index 942afd3..039a46d 100644
--- a/src/audiocachefile.cc
+++ b/src/audiocachefile.cc
@@ -30,16 +30,21 @@
#include <hugin.hpp>
+#include <cstring>
+
#include "audiocache.h"
AudioCacheFile::AudioCacheFile(const std::string& filename)
: filename(filename)
{
+ std::memset(&sf_info, 0, sizeof(SF_INFO));
+
fh = sf_open(filename.c_str(), SFM_READ, &sf_info);
if(!fh)
{
ERR(audiofile,"SNDFILE Error (%s): %s\n",
filename.c_str(), sf_strerror(fh));
+ return;
}
if(sf_info.frames == 0)
@@ -75,7 +80,11 @@ size_t AudioCacheFile::getChannelCount()
void AudioCacheFile::readChunk(const CacheChannels& channels,
size_t pos, size_t num_samples)
{
- assert(fh != nullptr); // File handle must never be nullptr
+ //assert(fh != nullptr); // File handle must never be nullptr
+ if(!fh)
+ {
+ return;
+ }
if((int)pos > sf_info.frames)
{