mirror of
https://github.com/love2d/love.git
synced 2026-08-19 12:14:20 +02:00
Pause OpenAL when the app is in the background, on Android.
This commit is contained in:
@@ -190,6 +190,9 @@ void Audio::pause(love::audio::Source *source)
|
|||||||
void Audio::pause()
|
void Audio::pause()
|
||||||
{
|
{
|
||||||
pool->pause();
|
pool->pause();
|
||||||
|
#ifdef LOVE_ANDROID
|
||||||
|
alcDevicePauseSOFT(device);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::resume(love::audio::Source *source)
|
void Audio::resume(love::audio::Source *source)
|
||||||
@@ -199,6 +202,9 @@ void Audio::resume(love::audio::Source *source)
|
|||||||
|
|
||||||
void Audio::resume()
|
void Audio::resume()
|
||||||
{
|
{
|
||||||
|
#ifdef LOVE_ANDROID
|
||||||
|
alcDeviceResumeSOFT(device);
|
||||||
|
#endif
|
||||||
pool->resume();
|
pool->resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#else
|
#else
|
||||||
#include <AL/alc.h>
|
#include <AL/alc.h>
|
||||||
#include <AL/al.h>
|
#include <AL/al.h>
|
||||||
|
#include <AL/alext.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "graphics/Graphics.h"
|
#include "graphics/Graphics.h"
|
||||||
#include "window/Window.h"
|
#include "window/Window.h"
|
||||||
#include "common/Exception.h"
|
#include "common/Exception.h"
|
||||||
|
#include "audio/Audio.h"
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@@ -509,6 +510,22 @@ Message *Event::convertJoystickEvent(const SDL_Event &e) const
|
|||||||
msg = new Message("joystickremoved", vargs);
|
msg = new Message("joystickremoved", vargs);
|
||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -802,6 +819,10 @@ std::map<SDL_Keycode, love::keyboard::Keyboard::Key> Event::createKeyMap()
|
|||||||
k[SDLK_EJECT] = Keyboard::KEY_EJECT;
|
k[SDLK_EJECT] = Keyboard::KEY_EJECT;
|
||||||
k[SDLK_SLEEP] = Keyboard::KEY_SLEEP;
|
k[SDLK_SLEEP] = Keyboard::KEY_SLEEP;
|
||||||
|
|
||||||
|
#ifdef LOVE_ANDROID
|
||||||
|
k[SDLK_AC_BACK] = Keyboard::KEY_ESCAPE;
|
||||||
|
#endif
|
||||||
|
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user