Add simulator audio support

This commit is contained in:
Adolfo Reyna
2026-09-23 19:13:39 -04:00
parent 982bba70b2
commit dcfd4e9bcc
15 changed files with 905 additions and 11 deletions
@@ -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;
}
}