added mutex around m_active_sounds
git-svn-id: svn://anubis/anaglym/trunk@283 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
f782e5dc77
commit
a3559623ed
8
AV.cc
8
AV.cc
@ -60,10 +60,14 @@ AV::AV()
|
|||||||
cerr << "SDL_OpenAudio() error." << endl;
|
cerr << "SDL_OpenAudio() error." << endl;
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_active_sounds_mutex = SDL_CreateMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
AV::~AV()
|
AV::~AV()
|
||||||
{
|
{
|
||||||
|
SDL_PauseAudio(1);
|
||||||
|
SDL_DestroyMutex(m_active_sounds_mutex);
|
||||||
SDL_CloseAudio();
|
SDL_CloseAudio();
|
||||||
Sound_Quit();
|
Sound_Quit();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
@ -134,13 +138,16 @@ refptr<AV::Sound> AV::createSound()
|
|||||||
|
|
||||||
void AV::playSound(AV::Sound * s)
|
void AV::playSound(AV::Sound * s)
|
||||||
{
|
{
|
||||||
|
SDL_mutexP(m_active_sounds_mutex);
|
||||||
m_active_sounds.insert(s);
|
m_active_sounds.insert(s);
|
||||||
|
SDL_mutexV(m_active_sounds_mutex);
|
||||||
SDL_PauseAudio(0);
|
SDL_PauseAudio(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AV::playCallback(Uint8 * stream, int len)
|
void AV::playCallback(Uint8 * stream, int len)
|
||||||
{
|
{
|
||||||
memset(stream, 0, len);
|
memset(stream, 0, len);
|
||||||
|
SDL_mutexP(m_active_sounds_mutex);
|
||||||
for (std::set<Sound *>::iterator it = m_active_sounds.begin();
|
for (std::set<Sound *>::iterator it = m_active_sounds.begin();
|
||||||
it != m_active_sounds.end();
|
it != m_active_sounds.end();
|
||||||
it++)
|
it++)
|
||||||
@ -154,6 +161,7 @@ void AV::playCallback(Uint8 * stream, int len)
|
|||||||
{
|
{
|
||||||
SDL_PauseAudio(1);
|
SDL_PauseAudio(1);
|
||||||
}
|
}
|
||||||
|
SDL_mutexV(m_active_sounds_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
AV::Sound::Sound(AV & av)
|
AV::Sound::Sound(AV & av)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user