25 |
|
|
26 |
namespace LinuxSampler { |
namespace LinuxSampler { |
27 |
|
|
28 |
|
// *************** ParameterActive *************** |
29 |
|
// * |
30 |
|
|
31 |
|
AudioOutputDevice::ParameterActive::ParameterActive() : DeviceCreationParameterBool() { |
32 |
|
InitWithDefault(); |
33 |
|
} |
34 |
|
|
35 |
|
AudioOutputDevice::ParameterActive::ParameterActive(String s) : DeviceCreationParameterBool(s) { |
36 |
|
} |
37 |
|
|
38 |
|
String AudioOutputDevice::ParameterActive::Description() { |
39 |
|
return "Enable / disable device"; |
40 |
|
} |
41 |
|
|
42 |
|
bool AudioOutputDevice::ParameterActive::Fix() { |
43 |
|
return false; |
44 |
|
} |
45 |
|
|
46 |
|
bool AudioOutputDevice::ParameterActive::Mandatory() { |
47 |
|
return false; |
48 |
|
} |
49 |
|
|
50 |
|
std::map<String,DeviceCreationParameter*> AudioOutputDevice::ParameterActive::DependsAsParameters() { |
51 |
|
return std::map<String,DeviceCreationParameter*>(); |
52 |
|
} |
53 |
|
|
54 |
|
optional<bool> AudioOutputDevice::ParameterActive::DefaultAsBool(std::map<String,String> Parameters) { |
55 |
|
return true; |
56 |
|
} |
57 |
|
|
58 |
|
void AudioOutputDevice::ParameterActive::OnSetValue(bool b) throw (LinuxSamplerException) { |
59 |
|
if (b) ((AudioOutputDevice*)pDevice)->Play(); |
60 |
|
else ((AudioOutputDevice*)pDevice)->Stop(); |
61 |
|
} |
62 |
|
|
63 |
|
String AudioOutputDevice::ParameterActive::Name() { |
64 |
|
return "ACTIVE"; |
65 |
|
} |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
// *************** ParameterSampleRate *************** |
70 |
|
// * |
71 |
|
|
72 |
|
AudioOutputDevice::ParameterSampleRate::ParameterSampleRate() : DeviceCreationParameterInt() { |
73 |
|
InitWithDefault(); |
74 |
|
} |
75 |
|
|
76 |
|
AudioOutputDevice::ParameterSampleRate::ParameterSampleRate(String s) : DeviceCreationParameterInt(s) { |
77 |
|
} |
78 |
|
|
79 |
|
String AudioOutputDevice::ParameterSampleRate::Description() { |
80 |
|
return "Output sample rate"; |
81 |
|
} |
82 |
|
|
83 |
|
bool AudioOutputDevice::ParameterSampleRate::Fix() { |
84 |
|
return true; |
85 |
|
} |
86 |
|
|
87 |
|
bool AudioOutputDevice::ParameterSampleRate::Mandatory() { |
88 |
|
return false; |
89 |
|
} |
90 |
|
|
91 |
|
std::map<String,DeviceCreationParameter*> AudioOutputDevice::ParameterSampleRate::DependsAsParameters() { |
92 |
|
return std::map<String,DeviceCreationParameter*>(); |
93 |
|
} |
94 |
|
|
95 |
|
optional<int> AudioOutputDevice::ParameterSampleRate::DefaultAsInt(std::map<String,String> Parameters) { |
96 |
|
return 44100; |
97 |
|
} |
98 |
|
|
99 |
|
optional<int> AudioOutputDevice::ParameterSampleRate::RangeMinAsInt(std::map<String,String> Parameters) { |
100 |
|
return optional<int>::nothing; |
101 |
|
} |
102 |
|
|
103 |
|
optional<int> AudioOutputDevice::ParameterSampleRate::RangeMaxAsInt(std::map<String,String> Parameters) { |
104 |
|
return optional<int>::nothing; |
105 |
|
} |
106 |
|
|
107 |
|
std::vector<int> AudioOutputDevice::ParameterSampleRate::PossibilitiesAsInt(std::map<String,String> Parameters) { |
108 |
|
return std::vector<int>(); |
109 |
|
} |
110 |
|
|
111 |
|
void AudioOutputDevice::ParameterSampleRate::OnSetValue(int i) throw (LinuxSamplerException) { |
112 |
|
/* cannot happen, as parameter is fix */ |
113 |
|
} |
114 |
|
|
115 |
|
String AudioOutputDevice::ParameterSampleRate::Name() { |
116 |
|
return "SAMPLERATE"; |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
// *************** ParameterChannels *************** |
122 |
|
// * |
123 |
|
|
124 |
|
AudioOutputDevice::ParameterChannels::ParameterChannels() : DeviceCreationParameterInt() { |
125 |
|
InitWithDefault(); |
126 |
|
} |
127 |
|
|
128 |
|
AudioOutputDevice::ParameterChannels::ParameterChannels(String s) : DeviceCreationParameterInt(s) { |
129 |
|
} |
130 |
|
|
131 |
|
String AudioOutputDevice::ParameterChannels::Description() { |
132 |
|
return "Number of output channels"; |
133 |
|
} |
134 |
|
|
135 |
|
bool AudioOutputDevice::ParameterChannels::Fix() { |
136 |
|
return false; |
137 |
|
} |
138 |
|
|
139 |
|
bool AudioOutputDevice::ParameterChannels::Mandatory() { |
140 |
|
return false; |
141 |
|
} |
142 |
|
|
143 |
|
std::map<String,DeviceCreationParameter*> AudioOutputDevice::ParameterChannels::DependsAsParameters() { |
144 |
|
return std::map<String,DeviceCreationParameter*>(); |
145 |
|
} |
146 |
|
|
147 |
|
optional<int> AudioOutputDevice::ParameterChannels::DefaultAsInt(std::map<String,String> Parameters) { |
148 |
|
return 2; |
149 |
|
} |
150 |
|
|
151 |
|
optional<int> AudioOutputDevice::ParameterChannels::RangeMinAsInt(std::map<String,String> Parameters) { |
152 |
|
return optional<int>::nothing; |
153 |
|
} |
154 |
|
|
155 |
|
optional<int> AudioOutputDevice::ParameterChannels::RangeMaxAsInt(std::map<String,String> Parameters) { |
156 |
|
return optional<int>::nothing; |
157 |
|
} |
158 |
|
|
159 |
|
std::vector<int> AudioOutputDevice::ParameterChannels::PossibilitiesAsInt(std::map<String,String> Parameters) { |
160 |
|
return std::vector<int>(); |
161 |
|
} |
162 |
|
|
163 |
|
void AudioOutputDevice::ParameterChannels::OnSetValue(int i) throw (LinuxSamplerException) { |
164 |
|
((AudioOutputDevice*)pDevice)->AcquireChannels(i); |
165 |
|
} |
166 |
|
|
167 |
|
String AudioOutputDevice::ParameterChannels::Name() { |
168 |
|
return "CHANNELS"; |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
// *************** AudioOutputDevice *************** |
174 |
|
// * |
175 |
|
|
176 |
AudioOutputDevice::AudioOutputDevice(std::map<String,DeviceCreationParameter*> DriverParameters) { |
AudioOutputDevice::AudioOutputDevice(std::map<String,DeviceCreationParameter*> DriverParameters) { |
177 |
this->Parameters = DriverParameters; |
this->Parameters = DriverParameters; |
178 |
} |
} |
179 |
|
|
180 |
AudioOutputDevice::~AudioOutputDevice() { |
AudioOutputDevice::~AudioOutputDevice() { |
181 |
std::map<String,DeviceCreationParameter*>::iterator iter = Parameters.begin(); |
// delete all audio channels |
182 |
while (iter != Parameters.end()) { |
{ |
183 |
Parameters.erase(iter); |
std::vector<AudioChannel*>::iterator iter = Channels.begin(); |
184 |
delete iter->second; |
while (iter != Channels.end()) { |
185 |
iter++; |
Channels.erase(iter); |
186 |
|
delete *iter; |
187 |
|
iter++; |
188 |
|
} |
189 |
|
|
190 |
|
} |
191 |
|
|
192 |
|
// delete all device parameters |
193 |
|
{ |
194 |
|
std::map<String,DeviceCreationParameter*>::iterator iter = Parameters.begin(); |
195 |
|
while (iter != Parameters.end()) { |
196 |
|
Parameters.erase(iter); |
197 |
|
delete iter->second; |
198 |
|
iter++; |
199 |
|
} |
200 |
} |
} |
201 |
} |
} |
202 |
|
|
218 |
return (ChannelIndex < Channels.size()) ? Channels[ChannelIndex] : NULL; |
return (ChannelIndex < Channels.size()) ? Channels[ChannelIndex] : NULL; |
219 |
} |
} |
220 |
|
|
221 |
|
void AudioOutputDevice::AcquireChannels(uint Channels) { |
222 |
|
if (Channels > this->Channels.size()) { |
223 |
|
for (int c = this->Channels.size(); c < Channels; c++) { |
224 |
|
this->Channels.push_back(CreateChannel(c)); |
225 |
|
} |
226 |
|
} |
227 |
|
} |
228 |
|
|
229 |
std::map<String,DeviceCreationParameter*> AudioOutputDevice::DeviceParameters() { |
std::map<String,DeviceCreationParameter*> AudioOutputDevice::DeviceParameters() { |
230 |
return Parameters; |
return Parameters; |
231 |
} |
} |