Resume audio on iOS after phone call or alarm

When a phone call or an alarm triggers on iOS, the application receives
an "audio interruption" and it's up to the application to resume
playback when the interruption ends. I added handling for audio
interruptions same as if the game is focused out and then back in.
This commit is contained in:
Ruslan Mustakov
2018-05-07 15:44:07 +07:00
parent e15305721d
commit 96301e934d
4 changed files with 72 additions and 22 deletions

View File

@ -217,13 +217,24 @@ void AudioDriverCoreAudio::start() {
if (!active) {
OSStatus result = AudioOutputUnitStart(audio_unit);
if (result != noErr) {
ERR_PRINT("AudioOutputUnitStart failed");
ERR_PRINT(("AudioOutputUnitStart failed, code: " + itos(result)).utf8().get_data());
} else {
active = true;
}
}
};
void AudioDriverCoreAudio::stop() {
if (active) {
OSStatus result = AudioOutputUnitStop(audio_unit);
if (result != noErr) {
ERR_PRINT(("AudioOutputUnitStop failed, code: " + itos(result)).utf8().get_data());
} else {
active = false;
}
}
}
int AudioDriverCoreAudio::get_mix_rate() const {
return mix_rate;
};

View File

@ -90,6 +90,7 @@ public:
virtual void finish();
bool try_lock();
void stop();
AudioDriverCoreAudio();
~AudioDriverCoreAudio();