mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 00:45:32 +00:00
Check for stopped active sounds too and remove them
This commit is contained in:
parent
6c45d6668b
commit
04638516b2
1 changed files with 28 additions and 14 deletions
|
@ -133,13 +133,11 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Sound *sound;
|
|
||||||
const ESM::Position &pos = ptr.getCellRef().pos;
|
const ESM::Position &pos = ptr.getCellRef().pos;
|
||||||
sound = mOutput->playSound3D(file, pos.pos, volume, pitch, min, max, loop);
|
SoundPtr sound(mOutput->playSound3D(file, pos.pos, volume, pitch, min, max, loop));
|
||||||
if(untracked)
|
|
||||||
mLooseSounds[id] = SoundPtr(sound);
|
if(untracked) mLooseSounds[id] = sound;
|
||||||
else
|
else mActiveSounds[ptr][id] = sound;
|
||||||
mActiveSounds[ptr][id] = SoundPtr(sound);
|
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +155,7 @@ namespace MWSound
|
||||||
if(iditer == snditer->second.end())
|
if(iditer == snditer->second.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return iditer->second->isPlaying();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -320,7 +318,7 @@ namespace MWSound
|
||||||
if(iditer != snditer->second.end())
|
if(iditer != snditer->second.end())
|
||||||
{
|
{
|
||||||
snditer->second.erase(iditer);
|
snditer->second.erase(iditer);
|
||||||
if(snditer->second.size() == 0)
|
if(snditer->second.empty())
|
||||||
mActiveSounds.erase(snditer);
|
mActiveSounds.erase(snditer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -450,16 +448,32 @@ namespace MWSound
|
||||||
float up[3] = { nUp[0], -nUp[2], nUp[1] };
|
float up[3] = { nUp[0], -nUp[2], nUp[1] };
|
||||||
mOutput->updateListener(pos, at, up);
|
mOutput->updateListener(pos, at, up);
|
||||||
|
|
||||||
// Check if any "untracked" sounds are finished playing, and trash
|
// Check if any sounds are finished playing, and trash them
|
||||||
// them
|
SoundMap::iterator snditer = mActiveSounds.begin();
|
||||||
IDMap::iterator snditer = mLooseSounds.begin();
|
while(snditer != mActiveSounds.end())
|
||||||
while(snditer != mLooseSounds.end())
|
|
||||||
{
|
{
|
||||||
if(!snditer->second->isPlaying())
|
IDMap::iterator iditer = snditer->second.begin();
|
||||||
mLooseSounds.erase(snditer++);
|
while(iditer != snditer->second.end())
|
||||||
|
{
|
||||||
|
if(!iditer->second->isPlaying())
|
||||||
|
snditer->second.erase(iditer++);
|
||||||
|
else
|
||||||
|
iditer++;
|
||||||
|
}
|
||||||
|
if(snditer->second.empty())
|
||||||
|
mActiveSounds.erase(snditer++);
|
||||||
else
|
else
|
||||||
snditer++;
|
snditer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IDMap::iterator iditer = mLooseSounds.begin();
|
||||||
|
while(iditer != mLooseSounds.end())
|
||||||
|
{
|
||||||
|
if(!iditer->second->isPlaying())
|
||||||
|
mLooseSounds.erase(iditer++);
|
||||||
|
else
|
||||||
|
iditer++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRegionSound(duration);
|
updateRegionSound(duration);
|
||||||
|
|
Loading…
Reference in a new issue