diff options
| author | Ruslan Mustakov | 2018-05-07 15:44:07 +0700 |
|---|---|---|
| committer | Ruslan Mustakov | 2018-05-07 15:48:46 +0700 |
| commit | 96301e934d7600975922c5f373a488a532d77aad (patch) | |
| tree | 7a521d7a508e2e872944ef691df45771f1735318 /drivers/coreaudio/audio_driver_coreaudio.cpp | |
| parent | e15305721da0e4478b62efcda3e79f1c04e7a901 (diff) | |
| download | godot-96301e9.tar.gz godot-96301e9.tar.zst godot-96301e9.zip | |
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.
Diffstat (limited to 'drivers/coreaudio/audio_driver_coreaudio.cpp')
| -rw-r--r-- | drivers/coreaudio/audio_driver_coreaudio.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/coreaudio/audio_driver_coreaudio.cpp b/drivers/coreaudio/audio_driver_coreaudio.cpp index c84469f26..6e451eabc 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; }; |
