Avoiding microphone permission popup on macOS Sonoma

I am working on an app that uses Core Audio through JUCE library for audio. The problem I'm trying to solve is that when the app is using a full duplex audio interface such as one from Focusrite Scarlett series for output, the app shows a dialog requesting permission to use microphone.

The root cause of the issue is that by default, Core Audio opens full duplex devices for both input and output. On previous macOS versions, I was able to work around the problem by disabling the input stream before starting the IOProc by setting AudioHardwareIOProcStreamUsage to all zero for input. On macOS Sonoma this disables input so that the microphone indicator is not shown, but the permission popup is still shown. What other reasons there are to show the popup?

I have noticed that Chrome and Slack have the same problem that they show the microphone popup when trying to play sounds on the Focusrite, but for example Deezer manages without the popup.

I managed to narrow the point where popup is shown down to AudioDeviceCreateIOProcID. Unfortunately this means a chicken and egg problem, because the IOProcID is needed for setting stream usage.

The documentation on AudioHardwareIOProcStreamUsage is frustratingly vague:

Also, when getting the value of the property, one must fill out the mIOProc field of the AudioHardwareIOProcStreamUsage with the address of the of the IOProc whose stream usage is to be retrieved.

sounds like the mIOProc would be pointer to the IOProc function, not IOProcID, but trying to use the function pointer to set stream usage before creating IOProcID produces just kAudioHardwareIllegalOperationError.

I asked the developer support, and they confirmed that the permission dialog is always shown when calling AudioDeviceCreateIOProcID for devices that have inputs when the app has audio input entitlement. If the app does not need audio capture, the dialog can be avoided by setting com.apple.security.device.audio-input to false in entitlements file.

Avoiding microphone permission popup on macOS Sonoma
 
 
Q