質問

I'm using a 3-rd party DLL which can enumerate the audio devices (providing name and guid-id) and set an audio device to the default one (by the id).

How can I get the current audio device (which is used by OS)? I need either name or device id.

This question seems to have no useful answers.

This one as well.

役に立ちましたか?

解決

You can use DirectShow for this.

private IBaseFilter CreateFilter(Guid category, string name)
{
    object source = null;
    Guid guid = typeof(IBaseFilter).GUID;
    foreach (DsDevice device in DsDevice.GetDevicesOfCat(category))
    {
        if ( device.Name == name )
        {
            device.Mon.BindToObject(null, null, ref guid, out source);
            break;
        }
    }
    return (IBaseFilter)source;
}
// Get device like this:
IBaseFilter defaultSoundDevice = CreateFilter( FilterCategory.AudioInputDevice, "Default DirectSound Device" );

Update #2:

DsDevice[] audioRenderers;
audioRenderers = DsDevice.GetDevicesOfCat(FilterCategory.AudioInputDevice);
foreach (DsDevice device in audioRenderers)
{
    MessageBox.Show(device.Name);
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top