minimize time in mutex
git-svn-id: svn://anubis/anaglym/trunk@294 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
854f14bf82
commit
9cdf2a4243
10
AV.cc
10
AV.cc
@ -151,11 +151,12 @@ void AV::stopSound(AV::Sound * s)
|
|||||||
{
|
{
|
||||||
SDL_mutexP(m_active_sounds_mutex);
|
SDL_mutexP(m_active_sounds_mutex);
|
||||||
m_active_sounds.erase(s);
|
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_PauseAudio(1);
|
||||||
}
|
}
|
||||||
SDL_mutexV(m_active_sounds_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AV::playCallback(Uint8 * stream, int len)
|
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]));
|
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_PauseAudio(1);
|
||||||
}
|
}
|
||||||
SDL_mutexV(m_active_sounds_mutex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************** AV::Sound ********************/
|
/******************** AV::Sound ********************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user