From b534d9d1f46dae16362f6637c11f035399e4703b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deal=28=E6=B6=93=E2=82=AC=E7=BB=BE=E8=B7=A8=E4=BC=92=29?= Date: Fri, 2 Jun 2023 17:15:01 +0800 Subject: [PATCH] Improve code style --- core/audio/AudioEngineImpl.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/audio/AudioEngineImpl.cpp b/core/audio/AudioEngineImpl.cpp index ef72fdc0f3..083e9f1907 100644 --- a/core/audio/AudioEngineImpl.cpp +++ b/core/audio/AudioEngineImpl.cpp @@ -80,6 +80,12 @@ static void ccALResumeDevice() #if AX_TARGET_PLATFORM == AX_PLATFORM_IOS +# if TARGET_OS_SIMULATOR + #define AVAUDIOSESSION_DEFAULT_CATEGORY AVAudioSessionCategoryPlayback // Fix can't hear sound in ios simulator 16.0 +# else + #define AVAUDIOSESSION_DEFAULT_CATEGORY AVAudioSessionCategoryAmbient +# endif + @interface AudioEngineSessionHandler : NSObject { } @@ -114,12 +120,7 @@ static void ccALResumeDevice() name:UIApplicationWillResignActiveNotification object:nil]; -# if TARGET_OS_SIMULATOR - const auto category = AVAudioSessionCategoryPlayback; // Fix can't hear sound in ios simulator 16.0 -# else - const auto category = AVAudioSessionCategoryAmbient; -# endif - BOOL success = [[AVAudioSession sharedInstance] setCategory:category error:nil]; + BOOL success = [[AVAudioSession sharedInstance] setCategory:AVAUDIOSESSION_DEFAULT_CATEGORY error:nil]; if (!success) ALOGE("Fail to set audio session."); } @@ -200,7 +201,7 @@ static void ccALResumeDevice() resumeOnBecomingActive = false; ALOGD("UIApplicationDidBecomeActiveNotification, alcMakeContextCurrent(s_ALContext)"); NSError* error = nil; - BOOL success = [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:&error]; + BOOL success = [[AVAudioSession sharedInstance] setCategory:AVAUDIOSESSION_DEFAULT_CATEGORY error:&error]; if (!success) { ALOGE("Fail to set audio session.");