How to check if MMDevice is captured exclusively?

258 Views Asked by At

I am able to capture default microphone exclusively using similar code as described here https://learn.microsoft.com/en-us/windows/win32/coreaudio/exclusive-mode-streams

I also need to check if an audio device is already captured exclusively by some app. As a possible solution I tried to catpure audio device in shared mode and if it is already caputred exclusively I am getting this error: AUDCLNT_E_DEVICE_IN_USE

This seems to work but I am wondering if we can check if device is captured exclusively, without capturing it, maybe by reading some propery of the audio device.

1

There are 1 best solutions below

1
On

I suggest you could try to use IAudioSessionEvents::OnSessionDisconnected method

DisconnectReasonExclusiveModeOverride:The (shared-mode) audio session was disconnected to make the audio endpoint device available for an exclusive-mode connection.