mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 09:49:40 +00:00
Prepare all Sound_Buffers when retrieving the first one
This commit is contained in:
parent
4b448c74d2
commit
5c53ee42a1
1 changed files with 17 additions and 1 deletions
|
@ -185,9 +185,23 @@ namespace MWSound
|
|||
// minRange, and maxRange), and ensure it's ready for use.
|
||||
Sound_Buffer *SoundManager::loadSound(const std::string &soundId)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#define LIKELY(x) __builtin_expect((bool)(x), true)
|
||||
#define UNLIKELY(x) __builtin_expect((bool)(x), false)
|
||||
#else
|
||||
#define LIKELY(x) (bool)(x)
|
||||
#define UNLIKELY(x) (bool)(x)
|
||||
#endif
|
||||
if(UNLIKELY(mBufferNameMap.empty()))
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
for(const ESM::Sound &sound : world->getStore().get<ESM::Sound>())
|
||||
insertSound(Misc::StringUtils::lowerCase(sound.mId), &sound);
|
||||
}
|
||||
|
||||
Sound_Buffer *sfx;
|
||||
NameBufferMap::const_iterator snd = mBufferNameMap.find(soundId);
|
||||
if(snd != mBufferNameMap.end())
|
||||
if(LIKELY(snd != mBufferNameMap.end()))
|
||||
sfx = snd->second;
|
||||
else
|
||||
{
|
||||
|
@ -196,6 +210,8 @@ namespace MWSound
|
|||
if(!sound) return nullptr;
|
||||
sfx = insertSound(soundId, sound);
|
||||
}
|
||||
#undef LIKELY
|
||||
#undef UNLIKELY
|
||||
|
||||
if(!sfx->mHandle)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue