Is there a way to find out whether a microphone/recording device is currently being used by an application in Windows?
I am aware that by using NAudio one can easily get a list of all recording devices as follows:
public void getAudioDevices()
{
DeviceNameByID = new Dictionary<string, string>();
var enumerator = new NAudio.CoreAudioApi.MMDeviceEnumerator();
// Allows you to enumerate rendering devices in certain states
var endpoints = enumerator.EnumerateAudioEndPoints(
DataFlow.Capture,
DeviceState.Active);
foreach (var endpoint in endpoints)
{
float volumeLevel = endpoint.AudioEndpointVolume.MasterVolumeLevelScalar;
Debug.WriteLine($"Volume: {volumeLevel}");
DeviceNameByID[endpoint.ID] = endpoint.DeviceFriendlyName;
Debug.WriteLine($"{endpoint.ID}: {endpoint.DeviceFriendlyName} - {endpoint.State}");
}
NotificationClient nClient = new NotificationClient();
// Aswell as hook to the actual event
enumerator.RegisterEndpointNotificationCallback(nClient);
}
but I am not sure as to how/if one can get any knowledge on their current usage.