minimize time in mutex

git-svn-id: svn://anubis/anaglym/trunk@294 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2010-07-27 15:01:01 +00:00
parent 854f14bf82
commit 9cdf2a4243

10
AV.cc
View File

@ -151,11 +151,12 @@ void AV::stopSound(AV::Sound * s)
{
SDL_mutexP(m_active_sounds_mutex);
m_active_sounds.erase(s);
if (m_active_sounds.size() == 0)
int sz = m_active_sounds.size();
SDL_mutexV(m_active_sounds_mutex);
if (sz == 0)
{
SDL_PauseAudio(1);
}
SDL_mutexV(m_active_sounds_mutex);
}
void AV::playCallback(Uint8 * stream, int len)
@ -190,11 +191,12 @@ void AV::playCallback(Uint8 * stream, int len)
min(SHRT_MAX, stream16[i] + (int)(volume * m_sound_buffer[i]));
}
}
if (m_active_sounds.size() == 0)
int sz = m_active_sounds.size();
SDL_mutexV(m_active_sounds_mutex);
if (sz == 0)
{
SDL_PauseAudio(1);
}
SDL_mutexV(m_active_sounds_mutex);
}
/******************** AV::Sound ********************/