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
+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;
}