diff --git a/AV.cc b/AV.cc index 5961f75..ba862c6 100644 --- a/AV.cc +++ b/AV.cc @@ -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 ********************/