From 3c8c5139c1ff23bb27f155a800f3f9fe359121d8 Mon Sep 17 00:00:00 2001 From: WangHe Date: Mon, 10 Sep 2018 16:23:40 +0800 Subject: [PATCH] add error check for AVAudioSession setActive. (#19000) --- cocos/audio/apple/AudioEngine-inl.mm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cocos/audio/apple/AudioEngine-inl.mm b/cocos/audio/apple/AudioEngine-inl.mm index 8c5def6a0f..81b8b86a89 100644 --- a/cocos/audio/apple/AudioEngine-inl.mm +++ b/cocos/audio/apple/AudioEngine-inl.mm @@ -158,6 +158,11 @@ void AudioEngineInterruptionListenerCallback(void* user_data, UInt32 interruptio ALOGD("AVAudioSessionInterruptionTypeEnded, application == UIApplicationStateActive, alcMakeContextCurrent(s_ALContext)"); NSError *error = nil; [[AVAudioSession sharedInstance] setActive:YES error:&error]; + if(error != nil){ + ALOGE("AVAudioSessionInterruptionTypeEnded, AVAudioSession setActive fail, %d",(int)error.code); + return; + } + alcMakeContextCurrent(s_ALContext); if (Director::getInstance()->isPaused()) { @@ -196,6 +201,10 @@ void AudioEngineInterruptionListenerCallback(void* user_data, UInt32 interruptio return; } [[AVAudioSession sharedInstance] setActive:YES error:&error]; + if(error != nil){ + ALOGE("UIApplicationDidBecomeActiveNotification, AVAudioSession setActive fail, %d",(int)error.code); + return; + } alcMakeContextCurrent(s_ALContext); } else if (isAudioSessionInterrupted)