Skip to content

Instantly share code, notes, and snippets.

@Fahrradkette
Last active December 20, 2015 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fahrradkette/6049300 to your computer and use it in GitHub Desktop.
Save Fahrradkette/6049300 to your computer and use it in GitHub Desktop.
returns a list of available devices if (on windows vista and 7) the ALC_ENUMERATE_ALL_EXT is present. If only ALC_ENUMERATION_EXT is present it returns (on windows vista and 7) the default device. It may returns all the devices on a unix. If no extension is present it returns the default device. We might change it so it returns null instead.
public static readonly string [] OpenAlGetDeviceList
{
get
{
string[] DeviceList;
if (Alc.alcIsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATE_ALL_EXT") == Alc.ALC_TRUE)
{
DeviceList = Alc.alcGetStringv(IntPtr.Zero, Alc.ALC_ALL_DEVICES_SPECIFIER);
if (Al.alGetError() != Al.AL_NO_ERROR)
throw new InvalidOperationException("Can't get OpenAL device list.");
// maybe just return null and log the error
return DeviceList;
}
else if (Alc.alcIsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATION_EXT") == Alc.ALC_TRUE)
{
DeviceList = Alc.alcGetStringv(IntPtr.Zero, Alc.ALC_DEVICE_SPECIFIER);
if (Al.alGetError() != Al.AL_NO_ERROR)
throw new InvalidOperationException("Can't get OpenAL device list.");
return DeviceList;
}
else
{
DeviceList = Alc.alcGetStringv(IntPtr.Zero, Alc.ALC_DEFAULT_DEVICE_SPECIFIER);
if (Al.alGetError() != Al.AL_NO_ERROR)
throw new InvalidOperationException("Can't get OpenAL default device name.");
return DeviceList;
// or simply return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment