Improve code quality: use named constant and clearer error logs

- Extract 0.1 second delay to named constant 'registrationDelay' with explanatory comment
- Split error message into separate log lines for better readability

Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-07 03:46:24 +00:00
parent 370b467b71
commit 36b4f765fd

View File

@@ -229,12 +229,15 @@ class MainFlutterWindow: NSWindow {
captureSession.commitConfiguration() captureSession.commitConfiguration()
// Start and immediately stop the session to trigger registration // Start and immediately stop the session to trigger registration
captureSession.startRunning() captureSession.startRunning()
// Keep a strong reference and stop after a brief moment // Minimum delay required for macOS to register the app in System Settings
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [captureSession] in let registrationDelay: TimeInterval = 0.1
// Keep a strong reference and stop after the registration delay
DispatchQueue.main.asyncAfter(deadline: .now() + registrationDelay) { [captureSession] in
captureSession.stopRunning() captureSession.stopRunning()
} }
} catch { } catch {
NSLog("[RustDesk] Error creating audio capture session for permission registration: %@. The app may not appear in System Settings > Privacy & Security > Microphone. Please verify permissions manually.", error.localizedDescription) NSLog("[RustDesk] Failed to create audio capture session: %@", error.localizedDescription)
NSLog("[RustDesk] The app may not appear in System Settings > Privacy & Security > Microphone")
} }
} }
} }