forked from teamnwah/openmw-tes3coop
Workaround for sound crash
This commit is contained in:
parent
4b2e2f7503
commit
bf32845d07
1 changed files with 23 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
||||||
#include "sndmanager.hpp"
|
#include "sndmanager.hpp"
|
||||||
|
|
||||||
#include "../misc/list.hpp"
|
#include "../misc/list.hpp"
|
||||||
|
#include <set>
|
||||||
#include <boost/weak_ptr.hpp>
|
#include <boost/weak_ptr.hpp>
|
||||||
|
|
||||||
using namespace OEngine::Sound;
|
using namespace OEngine::Sound;
|
||||||
|
@ -126,8 +127,8 @@ public:
|
||||||
struct SoundManager::SoundManagerList
|
struct SoundManager::SoundManagerList
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// A linked list of ManagedSound objects.
|
// A list of ManagedSound objects.
|
||||||
typedef Misc::List<ManagedSound> SoundList;
|
typedef std::set<ManagedSound*> SoundList;
|
||||||
SoundList list;
|
SoundList list;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -140,24 +141,38 @@ public:
|
||||||
// Remove a sound from the list
|
// Remove a sound from the list
|
||||||
void remove(ManagedSound *snd)
|
void remove(ManagedSound *snd)
|
||||||
{
|
{
|
||||||
list.remove(snd);
|
SoundList::iterator it = list.find(snd);
|
||||||
|
if (it != list.end())
|
||||||
|
list.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number of sounds in the list
|
// Number of sounds in the list
|
||||||
int numSounds() { return list.getNum(); }
|
int numSounds() { return (int)list.size(); }
|
||||||
|
|
||||||
// Update all sounds
|
// Update all sounds
|
||||||
void updateAll()
|
void updateAll()
|
||||||
{
|
{
|
||||||
for(ManagedSound *s = list.getHead(); s != NULL; s=s->next)
|
// Iterate over a copy of the list since sounds may remove themselves
|
||||||
s->update();
|
// from the master list during the iteration
|
||||||
|
SoundList tmp = list;
|
||||||
|
for (SoundList::iterator it = tmp.begin(); it != tmp.end(); ++it)
|
||||||
|
{
|
||||||
|
ManagedSound* pSound = *it;
|
||||||
|
pSound->update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detach and unlock all sounds
|
// Detach and unlock all sounds
|
||||||
void detachAll()
|
void detachAll()
|
||||||
{
|
{
|
||||||
for(ManagedSound *s = list.getHead(); s != NULL; s=s->next)
|
// Iterate over a copy of the list since sounds may remove themselves
|
||||||
s->detach();
|
// from the master list during the iteration
|
||||||
|
SoundList tmp = list;
|
||||||
|
for (SoundList::iterator it = tmp.begin(); it != tmp.end(); ++it)
|
||||||
|
{
|
||||||
|
ManagedSound* pSound = *it;
|
||||||
|
pSound->detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue