cAudio 2.3.0
3d Audio Engine
Loading...
Searching...
No Matches
cOpenALAudioDeviceList.cpp
1// Copyright (c) 2008-2011 Raynaldo (Wildicv) Rivera, Joshua (Dark_Kilauea) Jones, Murat (wolfmanfx) Sari
2// This file is part of the "cAudio Engine"
3// For conditions of distribution and use, see copyright notice in cAudio.h
4
5#include "cOpenALAudioDeviceList.h"
6#include "cOpenALUtil.h"
7
8namespace cAudio
9{
10 cOpenALAudioDeviceList::cOpenALAudioDeviceList(IDeviceType deviceType)
11 {
12 DeviceType = deviceType;
13 ALCenum specifier = 0;
14 ALCenum defaultDevice = 0;
15
16 if(DeviceType == DT_RECORDING)
17 {
18 specifier = ALC_CAPTURE_DEVICE_SPECIFIER;
19 defaultDevice = ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER;
20 }
21 else
22 {
23#if ALC_ENUMERATE_ALL_EXT
24 if( alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") == AL_TRUE )
25 {
26 specifier = ALC_ALL_DEVICES_SPECIFIER;
27 defaultDevice = ALC_DEFAULT_ALL_DEVICES_SPECIFIER;
28 }
29 else
30#endif
31 if( alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE )
32 {
33 specifier = ALC_DEVICE_SPECIFIER;
34 defaultDevice = ALC_DEFAULT_DEVICE_SPECIFIER;
35 }
36 }
37
38 if (specifier != 0 && defaultDevice != 0)
39 {
40 const char* deviceList = alcGetString(NULL, specifier);
41 if (deviceList)
42 {
43 while(*deviceList)
44 {
45 cAudioString device(fromUTF8(deviceList));
46 AvailableDevices.push_back(device);
47 deviceList += strlen(deviceList) + 1;
48 }
49 }
50
51 // Get the name of the 'default' capture device
52 DefaultDevice = fromUTF8(alcGetString(NULL, defaultDevice));
53 }
54 }
55
56 cOpenALAudioDeviceList::~cOpenALAudioDeviceList() {}
57
58 cAudioString cOpenALAudioDeviceList::getDefaultDeviceName()
59 {
60 return DefaultDevice;
61 }
62
63 unsigned int cOpenALAudioDeviceList::getDeviceCount()
64 {
65 return (unsigned int)AvailableDevices.size();
66 }
67
68 cAudioString cOpenALAudioDeviceList::getDeviceName(unsigned int idx)
69 {
70 if (AvailableDevices.size() > idx)
71 {
72 return AvailableDevices[idx];
73 }
74 return cAudioString(_CTEXT(""));
75 }
76
77 cAudioString cOpenALAudioDeviceList::getDeviceDescription(unsigned int idx)
78 {
79 return getDeviceName(idx); // In OpenAL deviceName is human readable
80 }
81
82 bool cOpenALAudioDeviceList::isSupported()
83 {
84 if(DeviceType == DT_RECORDING)
85 {
86 return alcIsExtensionPresent(NULL, "ALC_EXT_CAPTURE") == AL_TRUE && AvailableDevices.size() > 0;
87 }
88 return AvailableDevices.size() > 0;
89 }
90}
Main namespace for the entire cAudio library.
Definition: cAudioCapture.h:16