diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-01-28 11:41:18 +0100 | 
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-01-28 11:41:18 +0100 | 
| commit | 3e829110a40f811a0216e3bc648bc7f2485f3b4d (patch) | |
| tree | 807f931540ce39e8550d4c352e76e8b83c68caea /src | |
| parent | 3cf2aec198526b2decd147a3d5a4c3e70a9708ef (diff) | |
Handle sndffile open failure.
Diffstat (limited to 'src')
| -rw-r--r-- | src/audiocachefile.cc | 11 | 
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)  	{ | 
