Skip to content

Commit 387f56a

Browse files
Fix mac build V3 (#20703)
1 parent 674fc07 commit 387f56a

File tree

2 files changed

+13
-32
lines changed

2 files changed

+13
-32
lines changed

cocos/audio/mac/CDAudioManager.m

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,9 @@ + (void) configure: (tAudioManagerMode) mode {
325325

326326
-(BOOL) isOtherAudioPlaying {
327327
UInt32 isPlaying = 0;
328-
UInt32 varSize = sizeof(isPlaying);
329-
AudioSessionGetProperty (kAudioSessionProperty_OtherAudioIsPlaying, &varSize, &isPlaying);
328+
//UInt32 varSize = sizeof(isPlaying);
329+
//AudioSessionGetProperty (kAudioSessionProperty_OtherAudioIsPlaying, &varSize, &isPlaying);
330+
isPlaying = [[AVAudioSession sharedInstance] isOtherAudioPlaying];
330331
return (isPlaying != 0);
331332
}
332333

@@ -405,9 +406,9 @@ - (id) init: (tAudioManagerMode) mode {
405406
if ((self = [super init])) {
406407

407408
//Initialise the audio session
408-
AVAudioSession* session = [AVAudioSession sharedInstance];
409-
session.delegate = self;
410-
409+
//AVAudioSession* session = [AVAudioSession sharedInstance];
410+
//session.delegate = self;
411+
[[AVAudioSession sharedInstance] setActive:YES error:nil];
411412
_mode = mode;
412413
backgroundMusicCompletionSelector = nil;
413414
_isObservingAppEvents = FALSE;
@@ -474,33 +475,13 @@ -(BOOL) isBackgroundMusicPlaying {
474475
//however, on a 3gs running 3.1.2 no route change is generated when the user switches the
475476
//ringer mute switch to off (i.e. enables sound) therefore polling is the only reliable way to
476477
//determine ringer switch state
477-
-(BOOL) isDeviceMuted {
478+
-(BOOL) isDeviceMuted {
478479

479480
#if TARGET_IPHONE_SIMULATOR
480481
//Calling audio route stuff on the simulator causes problems
481482
return NO;
482-
#else
483-
CFStringRef newAudioRoute;
484-
UInt32 propertySize = sizeof (CFStringRef);
485-
486-
AudioSessionGetProperty (
487-
kAudioSessionProperty_AudioRoute,
488-
&propertySize,
489-
&newAudioRoute
490-
);
491-
492-
if (newAudioRoute == NULL) {
493-
//Don't expect this to happen but playing safe otherwise a null in the CFStringCompare will cause a crash
494-
return YES;
495-
} else {
496-
CFComparisonResult newDeviceIsMuted = CFStringCompare (
497-
newAudioRoute,
498-
(CFStringRef) @"",
499-
0
500-
);
501-
502-
return (newDeviceIsMuted == kCFCompareEqualTo);
503-
}
483+
#else
484+
return NO;
504485
#endif
505486
}
506487

cocos/audio/mac/CDXMacOSXSupport.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
#import <Foundation/Foundation.h>
4141
#import <AppKit/NSSound.h>
4242

43-
enum AudioSessionProperties {
44-
kAudioSessionProperty_OtherAudioIsPlaying,
45-
kAudioSessionProperty_AudioRoute
46-
};
43+
// enum AudioSessionProperties {
44+
// kAudioSessionProperty_OtherAudioIsPlaying,
45+
// kAudioSessionProperty_AudioRoute
46+
// };
4747
#ifdef __cplusplus
4848
extern "C" {
4949
#endif

0 commit comments

Comments
 (0)