mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Properly pause all audio processing in Android when minimized.
This uses ALC_SOFT_pause_device extension which is available since OpenAL-soft 1.16. We guarantee almost 100% availability of this extension since we've been using OpenAL-soft in Android since beginning. Fixes #1828
This commit is contained in:
@@ -627,20 +627,9 @@ Message *Event::convertWindowEvent(const SDL_Event &e)
|
||||
if (auto audio = Module::getInstance<audio::Audio>(Module::M_AUDIO))
|
||||
{
|
||||
if (e.window.event == SDL_WINDOWEVENT_MINIMIZED)
|
||||
{
|
||||
for (auto &src : pausedSources)
|
||||
src->release();
|
||||
pausedSources = audio->pause();
|
||||
for (auto &src : pausedSources)
|
||||
src->retain();
|
||||
}
|
||||
audio->pauseContext();
|
||||
else if (e.window.event == SDL_WINDOWEVENT_RESTORED)
|
||||
{
|
||||
audio->play(pausedSources);
|
||||
for (auto &src : pausedSources)
|
||||
src->release();
|
||||
pausedSources.resize(0);
|
||||
}
|
||||
audio->resumeContext();
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -78,10 +78,6 @@ private:
|
||||
static std::map<SDL_Keycode, love::keyboard::Keyboard::Key> createKeyMap();
|
||||
static std::map<SDL_Keycode, love::keyboard::Keyboard::Key> keys;
|
||||
|
||||
#ifdef LOVE_ANDROID
|
||||
std::vector<love::audio::Source*> pausedSources;
|
||||
#endif
|
||||
|
||||
}; // Event
|
||||
|
||||
} // sdl
|
||||
|
||||
Reference in New Issue
Block a user