Add simulator audio support
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
#include "sdl_audio.h"
|
||||
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#include <atomic>
|
||||
|
||||
error_t sdl_audio_microphone_permission() {
|
||||
@autoreleasepool {
|
||||
switch ([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio]) {
|
||||
case AVAuthorizationStatusAuthorized:
|
||||
return ERROR_NONE;
|
||||
case AVAuthorizationStatusDenied:
|
||||
case AVAuthorizationStatusRestricted:
|
||||
return ERROR_NOT_ALLOWED;
|
||||
case AVAuthorizationStatusNotDetermined: {
|
||||
static std::atomic<bool> requested { false };
|
||||
if (!requested.exchange(true)) {
|
||||
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) {
|
||||
requested.store(false);
|
||||
}];
|
||||
}
|
||||
return ERROR_RESOURCE_BUSY;
|
||||
}
|
||||
}
|
||||
return ERROR_NOT_ALLOWED;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user