automatically [un]pause SDL audio from AV

git-svn-id: svn://anubis/anaglym/trunk@281 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2010-06-22 02:47:16 +00:00
parent d376d7a5b0
commit a7ce3ff6b9
2 changed files with 5 additions and 3 deletions

5
AV.cc
View File

@ -135,6 +135,7 @@ refptr<AV::Sound> AV::createSound()
void AV::playSound(AV::Sound * s) void AV::playSound(AV::Sound * s)
{ {
m_active_sounds.insert(s); m_active_sounds.insert(s);
SDL_PauseAudio(0);
} }
void AV::playCallback(Uint8 * stream, int len) void AV::playCallback(Uint8 * stream, int len)
@ -149,6 +150,10 @@ void AV::playCallback(Uint8 * stream, int len)
m_active_sounds.erase(it); m_active_sounds.erase(it);
} }
} }
if (m_active_sounds.size() == 0)
{
SDL_PauseAudio(1);
}
} }
AV::Sound::Sound(AV & av) AV::Sound::Sound(AV & av)

View File

@ -928,9 +928,6 @@ void Engine::run()
case SDLK_F5: case SDLK_F5:
reloadProgram(); reloadProgram();
break; break;
case SDLK_F6:
SDL_PauseAudio(0);
break;
default: default:
key_down_event(event.key.keysym.sym); key_down_event(event.key.keysym.sym);
} }