diff --git a/simgear/sound/readwav.cxx b/simgear/sound/readwav.cxx index ffb0da0d..c0724cce 100644 --- a/simgear/sound/readwav.cxx +++ b/simgear/sound/readwav.cxx @@ -380,7 +380,8 @@ namespace simgear ALvoid* loadWAVFromFile(const SGPath& path, unsigned int& format, ALsizei& size, ALfloat& freqf, unsigned int& block_align) { if (!path.exists()) { - throw sg_io_exception("loadWAVFromFile: file not found", path); + SG_LOG(SG_IO, SG_DEV_ALERT, "loadWAVFromFile: file not found:" << path); + return nullptr; } Buffer b; @@ -395,13 +396,15 @@ ALvoid* loadWAVFromFile(const SGPath& path, unsigned int& format, ALsizei& size, fd = gzopen(ps.c_str(), "rb"); #endif if (!fd) { - throw sg_io_exception("loadWAVFromFile: unable to open file", path); + SG_LOG(SG_IO, SG_DEV_ALERT, "loadWAVFromFile: unable to open file:" << path); + return nullptr; } try { loadWavFile(fd, &b); } catch (sg_exception& e) { - throw sg_io_exception(e.getFormattedMessage() + "\nfor: " + path.str()); + SG_LOG(SG_IO, SG_DEV_ALERT, "loadWAVFromFile:" << e.getFormattedMessage() << "\nfor: " << path); + return nullptr; } ALvoid* data = b.data; diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx index a64f9c6d..51855dbb 100644 --- a/simgear/sound/soundmgr_openal.cxx +++ b/simgear/sound/soundmgr_openal.cxx @@ -813,13 +813,14 @@ bool SGSoundMgr::load( const std::string &samplepath, auto data = simgear::loadWAVFromFile(samplepath, format, size, freqf, blocksz); freq = (ALsizei)freqf; - if (data == nullptr) { - throw sg_io_exception("Failed to load wav file", sg_location(samplepath)); + if (!data) { + return false; } if (format == AL_FORMAT_STEREO8 || format == AL_FORMAT_STEREO16) { free(data); - throw sg_io_exception("Warning: STEREO files are not supported for 3D audio effects: " + samplepath); + SG_LOG(SG_IO, SG_DEV_ALERT, "Warning: STEREO files are not supported for 3D audio effects: " << samplepath); + return false; } *dbuf = (void *)data;