Skip to content

Commit d0eba94

Browse files
authored
Fix recording perms check for manual audio (#780)
We don't need to check recording perms & audio session for manual rendering mode since it doesn't use the device (mic).
1 parent e5ca3d9 commit d0eba94

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
patch type="fixed" "Only check audio recording perms for device rendering mode"

Sources/LiveKit/Audio/AudioDeviceModuleDelegateAdapter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class AudioDeviceModuleDelegateAdapter: NSObject, LKRTCAudioDeviceModuleDelegate
4545
let entryPoint = audioManager.buildEngineObserverChain()
4646
let result = entryPoint?.engineWillEnable(engine, isPlayoutEnabled: isPlayoutEnabled, isRecordingEnabled: isRecordingEnabled) ?? 0
4747

48-
// At this point mic perms / session should be configured for recording.
49-
if result == 0, isRecordingEnabled {
48+
// At this point mic perms / session should be configured for recording (only if device rendering mode).
49+
if result == 0, !engine.isInManualRenderingMode, isRecordingEnabled {
5050
// This will block WebRTC's worker thread, but when instantiating AVAudioInput node it will block by showing a dialog anyways.
5151
// Attempt to acquire mic perms at this point to return an error at SDK level.
5252
let isAuthorized = LiveKitSDK.ensureDeviceAccessSync(for: [.audio])

Sources/LiveKit/Audio/Manager/AudioManager.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,16 +407,18 @@ extension AudioManager {
407407

408408
// SDK side AudioEngine error codes
409409
let kAudioEngineErrorFailedToConfigureAudioSession = -4100
410+
let kAudioEngineErrorAudioSessionCategoryRecordingRequired = -4102
410411

411412
let kAudioEngineErrorInsufficientDevicePermission = -4101
412-
let kAudioEngineErrorAudioSessionCategoryRecordingRequired = -4102
413413

414414
extension AudioManager {
415415
func checkAdmResult(code: Int) throws {
416416
if code == kAudioEngineErrorFailedToConfigureAudioSession {
417417
throw LiveKitError(.audioSession, message: "Failed to configure audio session")
418418
} else if code == kAudioEngineErrorInsufficientDevicePermission {
419419
throw LiveKitError(.deviceAccessDenied, message: "Device permissions are not granted")
420+
} else if code == kAudioEngineErrorAudioSessionCategoryRecordingRequired {
421+
throw LiveKitError(.audioSession, message: "Recording category required for audio session")
420422
} else if code != 0 {
421423
throw LiveKitError(.audioEngine, message: "Audio engine returned error code: \(code)")
422424
}

0 commit comments

Comments
 (0)