5 #include "cOpenALAudioDeviceList.h"
6 #include "cOpenALUtil.h"
10 cOpenALAudioDeviceList::cOpenALAudioDeviceList(IDeviceType deviceType)
12 DeviceType = deviceType;
13 ALCenum specifier = 0;
14 ALCenum defaultDevice = 0;
16 if(DeviceType == DT_RECORDING)
18 specifier = ALC_CAPTURE_DEVICE_SPECIFIER;
19 defaultDevice = ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER;
23 #if ALC_ENUMERATE_ALL_EXT
24 if( alcIsExtensionPresent(NULL,
"ALC_ENUMERATE_ALL_EXT") == AL_TRUE )
26 specifier = ALC_ALL_DEVICES_SPECIFIER;
27 defaultDevice = ALC_DEFAULT_ALL_DEVICES_SPECIFIER;
31 if( alcIsExtensionPresent(NULL,
"ALC_ENUMERATION_EXT") == AL_TRUE )
33 specifier = ALC_DEVICE_SPECIFIER;
34 defaultDevice = ALC_DEFAULT_DEVICE_SPECIFIER;
38 if (specifier != 0 && defaultDevice != 0)
40 const char* deviceList = alcGetString(NULL, specifier);
45 cAudioString device(fromUTF8(deviceList));
46 AvailableDevices.push_back(device);
47 deviceList += strlen(deviceList) + 1;
52 DefaultDevice = fromUTF8(alcGetString(NULL, defaultDevice));
56 cOpenALAudioDeviceList::~cOpenALAudioDeviceList() {}
58 cAudioString cOpenALAudioDeviceList::getDefaultDeviceName()
63 unsigned int cOpenALAudioDeviceList::getDeviceCount()
65 return (
unsigned int)AvailableDevices.size();
68 cAudioString cOpenALAudioDeviceList::getDeviceName(
unsigned int idx)
70 if (AvailableDevices.size() > idx)
72 return AvailableDevices[idx];
74 return cAudioString(_CTEXT(
""));
77 cAudioString cOpenALAudioDeviceList::getDeviceDescription(
unsigned int idx)
79 return getDeviceName(idx);
82 bool cOpenALAudioDeviceList::isSupported()
84 if(DeviceType == DT_RECORDING)
86 return alcIsExtensionPresent(NULL,
"ALC_EXT_CAPTURE") == AL_TRUE && AvailableDevices.size() > 0;
88 return AvailableDevices.size() > 0;