Skip to content

Commit 3373055

Browse files
committed
Remove mic perms block
1 parent 0001d84 commit 3373055

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

modules/audio_device/audio_engine_device.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,7 @@ class AudioEngineDevice : public AudioDeviceModule, public AudioSessionObserver
478478
std::vector<std::string> input_device_labels_;
479479
#endif
480480

481-
bool IsMicrophonePermissionGranted();
482-
bool EnsureMicrophonePermissionSync();
481+
bool IsMicrophonePermissionAuthorized();
483482

484483
#if !TARGET_OS_OSX
485484
bool IsAudioSessionCategoryValid(NSString* category, bool is_input_enabled,

modules/audio_device/audio_engine_device.mm

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,8 +1876,8 @@
18761876
if (state.DidEnableInput()) {
18771877
LOGI() << "Checking microphone permission...";
18781878
// Attempt to acquire mic permissions at this point to return an erorr early.
1879-
bool isAuthorized = EnsureMicrophonePermissionSync();
1880-
LOGI() << "AudioEngine pre-enable check, device permission: "
1879+
bool isAuthorized = IsMicrophonePermissionAuthorized();
1880+
LOGI() << "AudioEngine pre-enable check, mic permission authorized: "
18811881
<< (isAuthorized ? "true" : "false");
18821882
if (!isAuthorized) {
18831883
return rollback(kAudioEngineErrorInsufficientDevicePermission);
@@ -2705,38 +2705,11 @@
27052705
// ----------------------------------------------------------------------------------------------------
27062706
// Private - Microphone permission
27072707

2708-
bool AudioEngineDevice::IsMicrophonePermissionGranted() {
2708+
bool AudioEngineDevice::IsMicrophonePermissionAuthorized() {
27092709
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
27102710
return status == AVAuthorizationStatusAuthorized;
27112711
}
27122712

2713-
bool AudioEngineDevice::EnsureMicrophonePermissionSync() {
2714-
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
2715-
2716-
if (status == AVAuthorizationStatusAuthorized) {
2717-
return true;
2718-
}
2719-
2720-
if (status == AVAuthorizationStatusNotDetermined) {
2721-
// Request permission synchronously - this will block WebRTC's worker thread
2722-
// but this is acceptable since instantiating AVAudioInputNode would block anyway
2723-
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
2724-
__block BOOL granted = NO;
2725-
2726-
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio
2727-
completionHandler:^(BOOL granted_inner) {
2728-
granted = granted_inner;
2729-
dispatch_semaphore_signal(semaphore);
2730-
}];
2731-
2732-
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
2733-
return granted;
2734-
}
2735-
2736-
// Status is denied or restricted
2737-
return false;
2738-
}
2739-
27402713
// ----------------------------------------------------------------------------------------------------
27412714
// Private - Audio session
27422715

0 commit comments

Comments
 (0)