Skip to content

feat(coreaudio): add macOS system audio permission helpers#1124

Open
thewh1teagle wants to merge 1 commit intoRustAudio:masterfrom
thewh1teagle:feat/macos-system-audio-permission
Open

feat(coreaudio): add macOS system audio permission helpers#1124
thewh1teagle wants to merge 1 commit intoRustAudio:masterfrom
thewh1teagle:feat/macos-system-audio-permission

Conversation

@thewh1teagle
Copy link
Contributor

I was using cpal 0.18.0 (master) for loopback recording on macOS and needed to check and request the System Audio Recording permission before recording. Without it, recording succeeds but
captures only silence.

Added three public functions on macOS:

  • cpal::check_system_audio_permission() — silent check, no UI
  • cpal::request_system_audio_permission() — shows system prompt, blocking
  • cpal::open_system_audio_settings() — opens Privacy & Security > System Audio Recording

Uses the private TCC framework (kTCCServiceAudioCapture) via libloading. block2 and objc2-core-foundation were already transitive dependencies so no significant dep overhead.

Related

@thewh1teagle thewh1teagle force-pushed the feat/macos-system-audio-permission branch from 94bbe7e to b262f4e Compare March 5, 2026 05:25
@thewh1teagle thewh1teagle force-pushed the feat/macos-system-audio-permission branch from b262f4e to cfeaede Compare March 5, 2026 05:39
@SuperKenVery
Copy link
Contributor

I think it might be better if we check permission when recording from an output device, and if we don't have it, request it.

Do you think it's better? cc @roderickvd

If you agree, I can file a PR agains your branch!

@thewh1teagle
Copy link
Contributor Author

Feel free to create a PR against my branch or open another PR with me as a co-author :)

@roderickvd
Copy link
Member

Thinking out loud:

Since requesting permissions is a blocking operation showing a system-modal dialog, how about taking a middle road? In LoopbackDevice::from_device() we only check_system_audio_permission() which is non-blocking. If we don't have permissions, we return a new error variant. This catches the silent-silence bug without any blocking UI side-effects.

Then, we keep request_system_audio_permission() and open_system_audio_settings() as public API, so that a user can explicitly decide to request a blocking modal.

Going forward I would like to expose host-specific functionality with extension traits. Please refer to #1074 for an ongoing discussion how to do that for ASIO (getting the API right for all hosts) as well as an outlook on how to expose new error variants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants