diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index 41859f7fd9..edc9e6e295 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -238,7 +238,17 @@ size_t FFmpeg_Decoder::MyStream::readAVAudioData(void *data, size_t length) void FFmpeg_Decoder::open(const std::string &fname) { close(); - mDataStream = mResourceMgr.openResource(fname); + try + { + mDataStream = mResourceMgr.openResource(fname); + } + catch(Ogre::Exception &e) + { + std::string::size_type pos = fname.rfind('.'); + if(pos == std::string::npos) + throw; + mDataStream = mResourceMgr.openResource(fname.substr(0, pos)+".mp3"); + } if((mFormatCtx=avformat_alloc_context()) == NULL) fail("Failed to allocate context"); diff --git a/apps/openmw/mwsound/mpgsnd_decoder.cpp b/apps/openmw/mwsound/mpgsnd_decoder.cpp index f576833a82..e014008a06 100644 --- a/apps/openmw/mwsound/mpgsnd_decoder.cpp +++ b/apps/openmw/mwsound/mpgsnd_decoder.cpp @@ -81,7 +81,17 @@ off_t MpgSnd_Decoder::ogrempg_lseek(void *user_data, off_t offset, int whence) void MpgSnd_Decoder::open(const std::string &fname) { close(); - mDataStream = mResourceMgr.openResource(fname); + try + { + mDataStream = mResourceMgr.openResource(fname); + } + catch(Ogre::Exception &e) + { + std::string::size_type pos = fname.rfind('.'); + if(pos == std::string::npos) + throw; + mDataStream = mResourceMgr.openResource(fname.substr(0, pos)+".mp3"); + } SF_VIRTUAL_IO streamIO = { ogresf_get_filelen, ogresf_seek, diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index cce1bfefe9..6c415957fb 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -107,14 +107,7 @@ namespace MWSound max = std::max(min, max); } - std::string fname = std::string("Sound\\")+snd->sound; - if(!mResourceMgr->resourceExistsInAnyGroup(fname)) - { - std::string::size_type pos = fname.rfind('.'); - if(pos != std::string::npos) - fname = fname.substr(0, pos)+".mp3"; - } - return fname; + return std::string("Sound/")+snd->sound; } // Add a sound to the list and play it @@ -207,12 +200,6 @@ namespace MWSound { // The range values are not tested std::string filePath = std::string("Sound\\")+filename; - if(!mResourceMgr->resourceExistsInAnyGroup(filePath)) - { - std::string::size_type pos = filePath.rfind('.'); - if(pos != std::string::npos) - filePath = filePath.substr(0, pos)+".mp3"; - } play3d(filePath, ptr, "_say_sound", 1, 1, 100, 20000, false); }