Pause OpenAL when the app is in the background, on Android.

This commit is contained in:
Martin Felis
2015-08-13 19:46:11 -03:00
parent f6448116cc
commit 637a3a9d62
3 changed files with 28 additions and 0 deletions
+6
View File
@@ -190,6 +190,9 @@ void Audio::pause(love::audio::Source *source)
void Audio::pause()
{
pool->pause();
#ifdef LOVE_ANDROID
alcDevicePauseSOFT(device);
#endif
}
void Audio::resume(love::audio::Source *source)
@@ -199,6 +202,9 @@ void Audio::resume(love::audio::Source *source)
void Audio::resume()
{
#ifdef LOVE_ANDROID
alcDeviceResumeSOFT(device);
#endif
pool->resume();
}
+1
View File
@@ -47,6 +47,7 @@
#else
#include <AL/alc.h>
#include <AL/al.h>
#include <AL/alext.h>
#endif
namespace love
+21
View File
@@ -29,6 +29,7 @@
#include "graphics/Graphics.h"
#include "window/Window.h"
#include "common/Exception.h"
#include "audio/Audio.h"
#include "common/config.h"
#include <cmath>
@@ -509,6 +510,22 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
msg = new Message("joystickremoved", vargs);
}
break;
#ifdef LOVE_ANDROID
case SDL_WINDOWEVENT_MINIMIZED:
{
auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO);
if (audio)
audio->pause();
}
break;
case SDL_WINDOWEVENT_RESTORED:
{
auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO);
if (audio)
audio->resume();
}
break;
#endif
default:
break;
}
@@ -802,6 +819,10 @@ std::map<SDL_Keycode, love::keyboard::Keyboard::Key> Event::createKeyMap()
k[SDLK_EJECT] = Keyboard::KEY_EJECT;
k[SDLK_SLEEP] = Keyboard::KEY_SLEEP;
#ifdef LOVE_ANDROID
k[SDLK_AC_BACK] = Keyboard::KEY_ESCAPE;
#endif
return k;
}