From 96301e934d7600975922c5f373a488a532d77aad Mon Sep 17 00:00:00 2001 From: Ruslan Mustakov Date: Mon, 7 May 2018 15:44:07 +0700 Subject: 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. --- drivers/coreaudio/audio_driver_coreaudio.cpp | 13 ++++++++++++- drivers/coreaudio/audio_driver_coreaudio.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'drivers/coreaudio') diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp index c84469f26f..6e451eabcd 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.cpp +++ b/drivers/coreaudio/audio_driver_coreaudio.cpp @@ -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; }; diff --git a/drivers/coreaudio/audio_driver_coreaudio.h b/drivers/coreaudio/audio_driver_coreaudio.h index 9891920263..c44e225521 100644 --- a/drivers/coreaudio/audio_driver_coreaudio.h +++ b/drivers/coreaudio/audio_driver_coreaudio.h @@ -90,6 +90,7 @@ public: virtual void finish(); bool try_lock(); + void stop(); AudioDriverCoreAudio(); ~AudioDriverCoreAudio(); -- cgit v1.2.3