mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Fix crash when running out of sound sources
This commit is contained in:
parent
c70790ecb7
commit
6a749e77f2
1 changed files with 28 additions and 10 deletions
|
@ -410,10 +410,17 @@ namespace MWSound
|
|||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
const osg::Vec3f pos = world->getActorHeadTransform(ptr).getTrans();
|
||||
SoundLoudnessPair &old = mActiveSaySounds[ptr];
|
||||
if(old.first.get()) mOutput->finishStream(old.first);
|
||||
old = std::make_pair(playVoice(decoder, pos, (ptr == MWMechanics::getPlayer())),
|
||||
loudness);
|
||||
|
||||
SaySoundMap::iterator oldIt = mActiveSaySounds.find(ptr);
|
||||
if (oldIt != mActiveSaySounds.end())
|
||||
{
|
||||
mOutput->finishStream(oldIt->second.first);
|
||||
mActiveSaySounds.erase(oldIt);
|
||||
}
|
||||
|
||||
MWBase::SoundStreamPtr sound = playVoice(decoder, pos, (ptr == MWMechanics::getPlayer()));
|
||||
|
||||
mActiveSaySounds.insert(std::make_pair(ptr, std::make_pair(sound, loudness)));
|
||||
}
|
||||
}
|
||||
catch(std::exception &e)
|
||||
|
@ -452,9 +459,15 @@ namespace MWSound
|
|||
mPendingSaySounds[MWWorld::Ptr()] = std::make_pair(decoder, loudness);
|
||||
else
|
||||
{
|
||||
SoundLoudnessPair &old = mActiveSaySounds[MWWorld::Ptr()];
|
||||
if(old.first.get()) mOutput->finishStream(old.first);
|
||||
old = std::make_pair(playVoice(decoder, osg::Vec3f(), true), loudness);
|
||||
SaySoundMap::iterator oldIt = mActiveSaySounds.find(MWWorld::Ptr());
|
||||
if (oldIt != mActiveSaySounds.end())
|
||||
{
|
||||
mOutput->finishStream(oldIt->second.first);
|
||||
mActiveSaySounds.erase(oldIt);
|
||||
}
|
||||
|
||||
mActiveSaySounds.insert(std::make_pair(MWWorld::Ptr(),
|
||||
std::make_pair(playVoice(decoder, osg::Vec3f(), true), loudness)));
|
||||
}
|
||||
}
|
||||
catch(std::exception &e)
|
||||
|
@ -908,8 +921,13 @@ namespace MWSound
|
|||
MWBase::SoundStreamPtr sound;
|
||||
MWWorld::Ptr ptr = penditer->first;
|
||||
|
||||
SoundLoudnessPair &old = mActiveSaySounds[ptr];
|
||||
if(old.first.get()) mOutput->finishStream(old.first);
|
||||
SaySoundMap::iterator old = mActiveSaySounds.find(ptr);
|
||||
if (old != mActiveSaySounds.end())
|
||||
{
|
||||
mOutput->finishStream(old->second.first);
|
||||
mActiveSaySounds.erase(old);
|
||||
}
|
||||
|
||||
if(ptr == MWWorld::Ptr())
|
||||
sound = playVoice(decoder, osg::Vec3f(), true);
|
||||
else
|
||||
|
@ -918,7 +936,7 @@ namespace MWSound
|
|||
const osg::Vec3f pos = world->getActorHeadTransform(ptr).getTrans();
|
||||
sound = playVoice(decoder, pos, (ptr == MWMechanics::getPlayer()));
|
||||
}
|
||||
old = std::make_pair(sound, loudness);
|
||||
mActiveSaySounds.insert(std::make_pair(ptr, std::make_pair(sound, loudness)));
|
||||
}
|
||||
catch(std::exception &e) {
|
||||
std::cerr<< "Sound Error: "<<e.what() <<std::endl;
|
||||
|
|
Loading…
Reference in a new issue