From 84fd682e4e1d0ec923bd1276fa192ac7a5952dc5 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 1 Jun 2015 00:40:05 +0200 Subject: [PATCH] Fix for unnecessary exceptions when opening sounds This would throw often during normal play, even though the throws are caught and ignored, can be annoying when the debugger is set to 'catch throw'. --- apps/openmw/mwsound/openal_output.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 6862bb889d..a984fffa97 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -5,6 +5,8 @@ #include +#include + #include #include "openal_output.hpp" @@ -782,17 +784,15 @@ const CachedSound& OpenAL_Output::getBuffer(const std::string &fname) int srate; DecoderPtr decoder = mManager.getDecoder(); - try + // Workaround: Bethesda at some point converted some of the files to mp3, but the references were kept as .wav. + std::string file = fname; + if (!decoder->mResourceMgr->exists(file)) { - decoder->open(fname); - } - catch(std::exception&) - { - std::string::size_type pos = fname.rfind('.'); - if(pos == std::string::npos) - throw; - decoder->open(fname.substr(0, pos)+".mp3"); + std::string::size_type pos = file.rfind('.'); + if(pos != std::string::npos) + file = file.substr(0, pos)+".mp3"; } + decoder->open(file); decoder->getInfo(&srate, &chans, &type); format = getALFormat(chans, type);