Compare commits

...

5 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
36b4f765fd 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>
2026-02-07 03:46:24 +00:00
copilot-swe-agent[bot]
370b467b71 Address code review feedback: fix memory lifecycle and improve error message
- Move capture session lifecycle to main thread
- Add strong capture of captureSession in asyncAfter block to prevent premature deallocation
- Improve error message to inform user about potential impact and suggested action

Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com>
2026-02-07 03:45:47 +00:00
copilot-swe-agent[bot]
780c396541 Add detailed comments explaining microphone permission fix
Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com>
2026-02-07 03:45:08 +00:00
copilot-swe-agent[bot]
db5a1f29e7 Fix macOS microphone permission registration
Instantiate AVCaptureSession when requesting audio permissions to ensure the app properly registers in System Settings > Privacy & Security > Microphone. This fix addresses the issue where RustDesk was not appearing in the microphone permissions list on macOS.

Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com>
2026-02-07 03:44:39 +00:00
copilot-swe-agent[bot]
b7d25ef389 Initial plan 2026-02-07 03:34:56 +00:00

View File

@@ -209,7 +209,39 @@ class MainFlutterWindow: NSWindow {
break
}
case "requestRecordAudio":
// Request microphone access and trigger system registration
// On macOS 13+, apps only appear in System Settings > Privacy & Security > Microphone
// after they actually attempt to use the microphone, not just request permission.
// We create a brief capture session to ensure proper registration.
AVCaptureDevice.requestAccess(for: .audio, completionHandler: { granted in
if granted {
// Instantiate an audio capture session to trigger macOS registration
// This needs to run on main thread to ensure proper lifecycle
DispatchQueue.main.async {
if let audioDevice = AVCaptureDevice.default(for: .audio) {
do {
let audioInput = try AVCaptureDeviceInput(device: audioDevice)
let captureSession = AVCaptureSession()
captureSession.beginConfiguration()
if captureSession.canAddInput(audioInput) {
captureSession.addInput(audioInput)
}
captureSession.commitConfiguration()
// Start and immediately stop the session to trigger registration
captureSession.startRunning()
// Minimum delay required for macOS to register the app in System Settings
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()
}
} catch {
NSLog("[RustDesk] Failed to create audio capture session: %@", error.localizedDescription)
NSLog("[RustDesk] The app may not appear in System Settings > Privacy & Security > Microphone")
}
}
}
}
DispatchQueue.main.async {
result(granted)
}