Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mac build V3 #20703

Merged
merged 30 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 9 additions & 28 deletions cocos/audio/mac/CDAudioManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,9 @@ + (void) configure: (tAudioManagerMode) mode {

-(BOOL) isOtherAudioPlaying {
UInt32 isPlaying = 0;
UInt32 varSize = sizeof(isPlaying);
AudioSessionGetProperty (kAudioSessionProperty_OtherAudioIsPlaying, &varSize, &isPlaying);
//UInt32 varSize = sizeof(isPlaying);
//AudioSessionGetProperty (kAudioSessionProperty_OtherAudioIsPlaying, &varSize, &isPlaying);
isPlaying = [[AVAudioSession sharedInstance] isOtherAudioPlaying];
return (isPlaying != 0);
}

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

//Initialise the audio session
AVAudioSession* session = [AVAudioSession sharedInstance];
session.delegate = self;

//AVAudioSession* session = [AVAudioSession sharedInstance];
//session.delegate = self;
[[AVAudioSession sharedInstance] setActive:YES error:nil];
_mode = mode;
backgroundMusicCompletionSelector = nil;
_isObservingAppEvents = FALSE;
Expand Down Expand Up @@ -474,33 +475,13 @@ -(BOOL) isBackgroundMusicPlaying {
//however, on a 3gs running 3.1.2 no route change is generated when the user switches the
//ringer mute switch to off (i.e. enables sound) therefore polling is the only reliable way to
//determine ringer switch state
-(BOOL) isDeviceMuted {
-(BOOL) isDeviceMuted {

#if TARGET_IPHONE_SIMULATOR
//Calling audio route stuff on the simulator causes problems
return NO;
#else
CFStringRef newAudioRoute;
UInt32 propertySize = sizeof (CFStringRef);

AudioSessionGetProperty (
kAudioSessionProperty_AudioRoute,
&propertySize,
&newAudioRoute
);

if (newAudioRoute == NULL) {
//Don't expect this to happen but playing safe otherwise a null in the CFStringCompare will cause a crash
return YES;
} else {
CFComparisonResult newDeviceIsMuted = CFStringCompare (
newAudioRoute,
(CFStringRef) @"",
0
);

return (newDeviceIsMuted == kCFCompareEqualTo);
}
#else
return NO;
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions cocos/audio/mac/CDXMacOSXSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
#import <Foundation/Foundation.h>
#import <AppKit/NSSound.h>

enum AudioSessionProperties {
kAudioSessionProperty_OtherAudioIsPlaying,
kAudioSessionProperty_AudioRoute
};
// enum AudioSessionProperties {
// kAudioSessionProperty_OtherAudioIsPlaying,
// kAudioSessionProperty_AudioRoute
// };
#ifdef __cplusplus
extern "C" {
#endif
Expand Down