Closed avandun closed 8 years ago
XAudio 2.8 uses the deviceid of an mmdevice. Use the MMDeviceEnumerator to enumerate devices.
Hi, the devices I have are:
and this is the code:
List<MMDevice> _devices = new List<MMDevice>();
using (var mmdeviceEnumerator = new MMDeviceEnumerator())
{
using (
var mmdeviceCollection = mmdeviceEnumerator.EnumAudioEndpoints(DataFlow.Render, DeviceState.Active))
{
foreach (var device in mmdeviceCollection)
{
_devices.Add(device);
}
}
}
using (var xaudio2 = XAudio2.CreateXAudio2())
using (var masteringVoice = xaudio2.CreateMasteringVoice(0 ,0,_devices[0].DeviceID))
this results in an exception although the device exists and has a com handler.
so what's the mistake I made ?
Maybe a hint which can help in finding the bug.
I am currently not able to take a look at the code, but which version of XAudio causes this bug. Note that XAudio2.7 (on Windows XP, Vista, 7) uses the an index instead of the MMDeviceID. For XAudio2_7 you have to use the XAudio2_7.GetDeviceCount() Method an the GetDeviceDetails Method instead of the MMDeviceModel.
Should be fixed with the provided example.
For XAudio 2.8 the functions GetDeviceCount and GetDeviceDetails are not available anymore. This is also in the CSCore lib. I have checked for other solutions to query the devices but haven't found one in the lib. A solution is proposed here: http://blogs.msdn.com/b/chuckw/archive/2012/04/02/xaudio2-and-windows-8-consumer-preview.aspx It's a pity that my C++ skill are too rusty to fix it myself. This would enhance the CScore lib and make it possible to query the devices in 2.8 version. Hope to see it soon.