forked from teamnwah/openmw-tes3coop
Merge pull request #861 from scrawl/soundcrash
Fix crash when running out of sound sources
This commit is contained in:
commit
4553db7b43
1 changed files with 28 additions and 10 deletions
|
@ -410,10 +410,17 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
const osg::Vec3f pos = world->getActorHeadTransform(ptr).getTrans();
|
const osg::Vec3f pos = world->getActorHeadTransform(ptr).getTrans();
|
||||||
SoundLoudnessPair &old = mActiveSaySounds[ptr];
|
|
||||||
if(old.first.get()) mOutput->finishStream(old.first);
|
SaySoundMap::iterator oldIt = mActiveSaySounds.find(ptr);
|
||||||
old = std::make_pair(playVoice(decoder, pos, (ptr == MWMechanics::getPlayer())),
|
if (oldIt != mActiveSaySounds.end())
|
||||||
loudness);
|
{
|
||||||
|
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)
|
catch(std::exception &e)
|
||||||
|
@ -452,9 +459,15 @@ namespace MWSound
|
||||||
mPendingSaySounds[MWWorld::Ptr()] = std::make_pair(decoder, loudness);
|
mPendingSaySounds[MWWorld::Ptr()] = std::make_pair(decoder, loudness);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SoundLoudnessPair &old = mActiveSaySounds[MWWorld::Ptr()];
|
SaySoundMap::iterator oldIt = mActiveSaySounds.find(MWWorld::Ptr());
|
||||||
if(old.first.get()) mOutput->finishStream(old.first);
|
if (oldIt != mActiveSaySounds.end())
|
||||||
old = std::make_pair(playVoice(decoder, osg::Vec3f(), true), loudness);
|
{
|
||||||
|
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)
|
catch(std::exception &e)
|
||||||
|
@ -901,8 +914,13 @@ namespace MWSound
|
||||||
MWBase::SoundStreamPtr sound;
|
MWBase::SoundStreamPtr sound;
|
||||||
MWWorld::Ptr ptr = penditer->first;
|
MWWorld::Ptr ptr = penditer->first;
|
||||||
|
|
||||||
SoundLoudnessPair &old = mActiveSaySounds[ptr];
|
SaySoundMap::iterator old = mActiveSaySounds.find(ptr);
|
||||||
if(old.first.get()) mOutput->finishStream(old.first);
|
if (old != mActiveSaySounds.end())
|
||||||
|
{
|
||||||
|
mOutput->finishStream(old->second.first);
|
||||||
|
mActiveSaySounds.erase(old);
|
||||||
|
}
|
||||||
|
|
||||||
if(ptr == MWWorld::Ptr())
|
if(ptr == MWWorld::Ptr())
|
||||||
sound = playVoice(decoder, osg::Vec3f(), true);
|
sound = playVoice(decoder, osg::Vec3f(), true);
|
||||||
else
|
else
|
||||||
|
@ -911,7 +929,7 @@ namespace MWSound
|
||||||
const osg::Vec3f pos = world->getActorHeadTransform(ptr).getTrans();
|
const osg::Vec3f pos = world->getActorHeadTransform(ptr).getTrans();
|
||||||
sound = playVoice(decoder, pos, (ptr == MWMechanics::getPlayer()));
|
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) {
|
catch(std::exception &e) {
|
||||||
std::cerr<< "Sound Error: "<<e.what() <<std::endl;
|
std::cerr<< "Sound Error: "<<e.what() <<std::endl;
|
||||||
|
|
Loading…
Reference in a new issue