1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 10:23:56 +00:00

Remove redundant SoundManager::lookupSound and loadSound

This commit is contained in:
elsid 2021-01-09 14:11:49 +01:00
parent e4cce88142
commit a6aba83741
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
3 changed files with 11 additions and 24 deletions

View file

@ -60,8 +60,12 @@ namespace MWSound
~SoundBufferPool(); ~SoundBufferPool();
/// Lookup a soundId for its sound data (resource name, local volume,
/// minRange, and maxRange)
Sound_Buffer* lookup(const std::string& soundId) const; Sound_Buffer* lookup(const std::string& soundId) const;
/// Lookup a soundId for its sound data (resource name, local volume,
/// minRange, and maxRange), and ensure it's ready for use.
Sound_Buffer* load(const std::string& soundId); Sound_Buffer* load(const std::string& soundId);
void use(Sound_Buffer& sfx) void use(Sound_Buffer& sfx)

View file

@ -120,20 +120,6 @@ namespace MWSound
return DecoderPtr(new DEFAULT_DECODER (mVFS)); return DecoderPtr(new DEFAULT_DECODER (mVFS));
} }
// Lookup a soundId for its sound data (resource name, local volume,
// minRange, and maxRange)
Sound_Buffer *SoundManager::lookupSound(const std::string &soundId) const
{
return mSoundBuffers.lookup(soundId);
}
// Lookup a soundId for its sound data (resource name, local volume,
// minRange, and maxRange), and ensure it's ready for use.
Sound_Buffer *SoundManager::loadSound(const std::string &soundId)
{
return mSoundBuffers.load(soundId);
}
DecoderPtr SoundManager::loadVoice(const std::string &voicefile) DecoderPtr SoundManager::loadVoice(const std::string &voicefile)
{ {
try try
@ -509,7 +495,7 @@ namespace MWSound
if(!mOutput->isInitialized()) if(!mOutput->isInitialized())
return nullptr; return nullptr;
Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId)); Sound_Buffer *sfx = mSoundBuffers.load(Misc::StringUtils::lowerCase(soundId));
if(!sfx) return nullptr; if(!sfx) return nullptr;
// Only one copy of given sound can be played at time, so stop previous copy // Only one copy of given sound can be played at time, so stop previous copy
@ -545,7 +531,7 @@ namespace MWSound
return nullptr; return nullptr;
// Look up the sound in the ESM data // Look up the sound in the ESM data
Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId)); Sound_Buffer *sfx = mSoundBuffers.load(Misc::StringUtils::lowerCase(soundId));
if(!sfx) return nullptr; if(!sfx) return nullptr;
// Only one copy of given sound can be played at time on ptr, so stop previous copy // Only one copy of given sound can be played at time on ptr, so stop previous copy
@ -597,7 +583,7 @@ namespace MWSound
return nullptr; return nullptr;
// Look up the sound in the ESM data // Look up the sound in the ESM data
Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId)); Sound_Buffer *sfx = mSoundBuffers.load(Misc::StringUtils::lowerCase(soundId));
if(!sfx) return nullptr; if(!sfx) return nullptr;
SoundPtr sound = getSoundRef(); SoundPtr sound = getSoundRef();
@ -645,7 +631,7 @@ namespace MWSound
if(!mOutput->isInitialized()) if(!mOutput->isInitialized())
return; return;
Sound_Buffer *sfx = lookupSound(Misc::StringUtils::lowerCase(soundId)); Sound_Buffer *sfx = mSoundBuffers.lookup(Misc::StringUtils::lowerCase(soundId));
if (!sfx) return; if (!sfx) return;
stopSound(sfx, ptr); stopSound(sfx, ptr);
@ -697,7 +683,7 @@ namespace MWSound
SoundMap::iterator snditer = mActiveSounds.find(ptr); SoundMap::iterator snditer = mActiveSounds.find(ptr);
if(snditer != mActiveSounds.end()) if(snditer != mActiveSounds.end())
{ {
Sound_Buffer *sfx = lookupSound(Misc::StringUtils::lowerCase(soundId)); Sound_Buffer *sfx = mSoundBuffers.lookup(Misc::StringUtils::lowerCase(soundId));
if (sfx == nullptr) if (sfx == nullptr)
return; return;
for(SoundBufferRefPair &sndbuf : snditer->second) for(SoundBufferRefPair &sndbuf : snditer->second)
@ -713,7 +699,7 @@ namespace MWSound
SoundMap::const_iterator snditer = mActiveSounds.find(ptr); SoundMap::const_iterator snditer = mActiveSounds.find(ptr);
if(snditer != mActiveSounds.end()) if(snditer != mActiveSounds.end())
{ {
Sound_Buffer *sfx = lookupSound(Misc::StringUtils::lowerCase(soundId)); Sound_Buffer *sfx = mSoundBuffers.lookup(Misc::StringUtils::lowerCase(soundId));
return std::find_if(snditer->second.cbegin(), snditer->second.cend(), return std::find_if(snditer->second.cbegin(), snditer->second.cend(),
[this,sfx](const SoundBufferRefPair &snd) -> bool [this,sfx](const SoundBufferRefPair &snd) -> bool
{ return snd.second == sfx && mOutput->isSoundPlaying(snd.first.get()); } { return snd.second == sfx && mOutput->isSoundPlaying(snd.first.get()); }
@ -826,7 +812,7 @@ namespace MWSound
bool soundIdChanged = false; bool soundIdChanged = false;
Sound_Buffer* sfx = lookupSound(update.mId); Sound_Buffer* sfx = mSoundBuffers.lookup(update.mId);
if (mLastCell != cell) if (mLastCell != cell)
{ {
const auto snditer = mActiveSounds.find(MWWorld::ConstPtr()); const auto snditer = mActiveSounds.find(MWWorld::ConstPtr());

View file

@ -99,9 +99,6 @@ namespace MWSound
Sound_Buffer *insertSound(const std::string &soundId, const ESM::Sound *sound); Sound_Buffer *insertSound(const std::string &soundId, const ESM::Sound *sound);
Sound_Buffer *lookupSound(const std::string &soundId) const;
Sound_Buffer *loadSound(const std::string &soundId);
// returns a decoder to start streaming, or nullptr if the sound was not found // returns a decoder to start streaming, or nullptr if the sound was not found
DecoderPtr loadVoice(const std::string &voicefile); DecoderPtr loadVoice(const std::string &voicefile);