macOS asks for permission to use the microphone when accessing the default output device
When I run the following code from the terminal on macOS (using cargo run)
use cpal::traits::HostTrait as _;
fn main() {
let _ = cpal::default_host().default_output_device();
}
I get a microphone permission prompt from macOS:
If you want to reproduce this and the permission prompt does not appear you may have already granted or denied permissions to your terminal. You can easily reset them using tccutil. For example tccutil reset Microphone com.apple.Terminal for macOS' builtin terminal.
This issue was originally reported to Bevy: https://github.com/bevyengine/bevy/issues/13989
I tested this on macOS Ventura (13.6.7).
Note that this is currently resulting in most (all?) Bevy games on macOS asking for microphone permissions 😅
Are there some settings we can pass to cpal to work around this?
Any progress on this issue, please?
So I tried your minimal example on my machine with macOS 15.7.2, and before that ran tccutil reset Microphone com.apple.Terminal. Can't reproduce it on latest master... has it since been fixed or is it still occurring for you?
It it does still occur for you, from a code review it could be that is_default_device is the culprit. Please try PR #1070 and report back.
I could not reproduce (using the provided snippet) in Sonoma 14.4.1 either (using the builtin terminal)... I will try some of the Bevy examples to see if that triggers the issue.
EDIT: Tested both cpal 0.16 and 0.15 versions. Bevy examples did not trigger this for me either.
That would be excellent news :) Unfortunately I no longer have any computer running macOS, so I cannot test it on the same hardware that reproduced the behavior in Bevy apps.
I've merged that PR without feedback, because I hope to include it in v0.17. From a code review I believe this should cure it, should it still occur - @mnmaita and myself couldn't reproduce it anymore on the provided minimal example. If it still isn't fix for your cases, feel free to reopen.