mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
adds iOS audio interruption handling and recovery
This commit is contained in:
@@ -26,6 +26,10 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef LOVE_IOS
|
||||
#include "common/ios.h"
|
||||
#endif
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace audio
|
||||
@@ -189,10 +193,18 @@ Audio::Audio()
|
||||
|
||||
poolThread = new PoolThread(pool);
|
||||
poolThread->start();
|
||||
|
||||
#ifdef LOVE_IOS
|
||||
love::ios::initAudioSessionInterruptionHandler();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Audio::~Audio()
|
||||
{
|
||||
#ifdef LOVE_IOS
|
||||
love::ios::destroyAudioSessionInterruptionHandler();
|
||||
#endif
|
||||
poolThread->setFinish();
|
||||
poolThread->wait();
|
||||
|
||||
@@ -293,6 +305,17 @@ std::vector<love::audio::Source*> Audio::pause()
|
||||
return Source::pause(pool);
|
||||
}
|
||||
|
||||
void Audio::pauseContext()
|
||||
{
|
||||
alcMakeContextCurrent(nullptr);
|
||||
}
|
||||
|
||||
void Audio::resumeContext()
|
||||
{
|
||||
if (context && alcGetCurrentContext() != context)
|
||||
alcMakeContextCurrent(context);
|
||||
}
|
||||
|
||||
void Audio::setVolume(float volume)
|
||||
{
|
||||
alListenerf(AL_GAIN, volume);
|
||||
|
||||
@@ -95,6 +95,8 @@ public:
|
||||
void pause(love::audio::Source *source);
|
||||
void pause(const std::vector<love::audio::Source*> &sources);
|
||||
std::vector<love::audio::Source*> pause();
|
||||
void pauseContext();
|
||||
void resumeContext();
|
||||
void setVolume(float volume);
|
||||
float getVolume() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user