From fd77e4b09c8ca80c8e449ad7266afaa494f98500 Mon Sep 17 00:00:00 2001 From: Alejandro Marzini Date: Tue, 29 Jun 2010 01:08:36 +0000 Subject: Modularized Linuxmoto port. svn-id: r50474 --- backends/mixer/sdl/sdl-mixer.cpp | 19 ++++++++++++++++++- backends/mixer/sdl/sdl-mixer.h | 5 +++++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'backends/mixer') diff --git a/backends/mixer/sdl/sdl-mixer.cpp b/backends/mixer/sdl/sdl-mixer.cpp index aa87fcb345..2317a03335 100644 --- a/backends/mixer/sdl/sdl-mixer.cpp +++ b/backends/mixer/sdl/sdl-mixer.cpp @@ -35,7 +35,8 @@ SdlMixerManager::SdlMixerManager() : - _mixer(0) { + _mixer(0), + _audioSuspended(false) { } @@ -120,4 +121,20 @@ void SdlMixerManager::sdlCallback(void *this_, byte *samples, int len) { manager->callbackHandler(samples, len); } +void SdlMixerManager::suspendAudio() { + SDL_CloseAudio(); + _audioSuspended = true; +} + +int SdlMixerManager::resumeAudio() { + if (!_audioSuspended) + return -2; + if (SDL_OpenAudio(&_obtainedRate, NULL) < 0){ + return -1; + } + SDL_PauseAudio(0); + _audioSuspended = false; + return 0; +} + #endif diff --git a/backends/mixer/sdl/sdl-mixer.h b/backends/mixer/sdl/sdl-mixer.h index e4e8263f38..f58260fef2 100644 --- a/backends/mixer/sdl/sdl-mixer.h +++ b/backends/mixer/sdl/sdl-mixer.h @@ -43,9 +43,14 @@ public: Audio::Mixer *getMixer() { return (Audio::Mixer *)_mixer; } + // Used by LinuxMoto Port + virtual void suspendAudio(); + virtual int resumeAudio(); + protected: Audio::MixerImpl *_mixer; SDL_AudioSpec _obtainedRate; + bool _audioSuspended; virtual SDL_AudioSpec getAudioSpec(); virtual void startAudio(); -- cgit v1.2.3