1 |
/*************************************************************************** |
2 |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
5 |
* Copyright (C) 2009 - 2013 Grigor Iliev * |
6 |
* * |
7 |
* This program is free software; you can redistribute it and/or modify * |
8 |
* it under the terms of the GNU General Public License as published by * |
9 |
* the Free Software Foundation; either version 2 of the License, or * |
10 |
* (at your option) any later version. * |
11 |
* * |
12 |
* This program is distributed in the hope that it will be useful, * |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
15 |
* GNU General Public License for more details. * |
16 |
* * |
17 |
* You should have received a copy of the GNU General Public License * |
18 |
* along with this program; if not, write to the Free Software * |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
20 |
* MA 02111-1307 USA * |
21 |
***************************************************************************/ |
22 |
|
23 |
#include "AudioOutputDeviceCoreAudio.h" |
24 |
|
25 |
#include "../../common/global_private.h" |
26 |
|
27 |
namespace LinuxSampler { |
28 |
|
29 |
void AudioOutputDeviceCoreAudio::AudioQueueListener ( |
30 |
void *inUserData, AudioQueueRef inAQ, AudioQueuePropertyID inID |
31 |
) { |
32 |
switch(inID) { |
33 |
case kAudioQueueProperty_IsRunning: |
34 |
|
35 |
break; |
36 |
case kAudioQueueProperty_CurrentDevice: |
37 |
|
38 |
break; |
39 |
} |
40 |
} |
41 |
|
42 |
void AudioOutputDeviceCoreAudio::HandleOutputBuffer ( |
43 |
void *aqData, |
44 |
AudioQueueRef inAQ, |
45 |
AudioQueueBufferRef inBuffer |
46 |
) { |
47 |
AQPlayerState* pAqData = (AQPlayerState*) aqData; |
48 |
if (atomic_read(&(pAqData->mIsRunning)) == 0) { |
49 |
AudioQueueFlush(pAqData->mQueue); |
50 |
AudioQueueStop (pAqData->mQueue, true); |
51 |
return; |
52 |
} |
53 |
|
54 |
if(atomic_read(&(pAqData->pDevice->restartQueue))) return; |
55 |
|
56 |
uint bufferSize = pAqData->pDevice->uiBufferSize; |
57 |
|
58 |
// let all connected engines render 'fragmentSize' sample points |
59 |
pAqData->pDevice->RenderAudio(bufferSize); |
60 |
|
61 |
Float32* pDataBuf = (Float32*)(inBuffer->mAudioData); |
62 |
|
63 |
uint uiCoreAudioChannels = pAqData->pDevice->uiCoreAudioChannels; |
64 |
for (int c = 0; c < uiCoreAudioChannels; c++) { |
65 |
float* in = pAqData->pDevice->Channels[c]->Buffer(); |
66 |
for (int i = 0, o = c; i < bufferSize; i++ , o += uiCoreAudioChannels) { |
67 |
pDataBuf[o] = in[i]; |
68 |
} |
69 |
} |
70 |
|
71 |
inBuffer->mAudioDataByteSize = (uiCoreAudioChannels * 4) * bufferSize; |
72 |
|
73 |
OSStatus res = AudioQueueEnqueueBuffer(pAqData->mQueue, inBuffer, 0, NULL); |
74 |
if(res) std::cerr << "AudioQueueEnqueueBuffer: Error " << res << std::endl; |
75 |
} |
76 |
|
77 |
void AudioOutputDeviceCoreAudio::DeviceChanged() { |
78 |
dmsg(1,("Restarting audio queue...")); |
79 |
atomic_set(&restartQueue, 1); |
80 |
} |
81 |
|
82 |
AudioOutputDeviceCoreAudio::AudioOutputDeviceCoreAudio ( |
83 |
std::map<String,DeviceCreationParameter*> Parameters |
84 |
) : AudioOutputDevice(Parameters), Thread(true, true, 1, 0), CurrentDevice(0) { |
85 |
|
86 |
dmsg(2,("AudioOutputDeviceCoreAudio::AudioOutputDeviceCoreAudio()\n")); |
87 |
if(CAAudioDeviceListModel::GetModel()->GetOutputDeviceCount() < 1) { |
88 |
throw Exception("No audio output device found"); |
89 |
} |
90 |
atomic_set(&pausedNew, 0); |
91 |
pausedOld = 0; |
92 |
atomic_set(&restartQueue, 0); |
93 |
|
94 |
uiCoreAudioChannels = ((DeviceCreationParameterInt*)Parameters["CHANNELS"])->ValueAsInt(); |
95 |
uint samplerate = ((DeviceCreationParameterInt*)Parameters["SAMPLERATE"])->ValueAsInt(); |
96 |
uiBufferNumber = ((DeviceCreationParameterInt*)Parameters["BUFFERS"])->ValueAsInt(); |
97 |
uiBufferSize = ((DeviceCreationParameterInt*)Parameters["BUFFERSIZE"])->ValueAsInt(); |
98 |
int device = 0; |
99 |
try { device = ((ParameterDevice*)Parameters["DEVICE"])->GetDeviceIndex(); } |
100 |
catch(Exception x) { } |
101 |
|
102 |
CurrentDevice = CAAudioDeviceListModel::GetModel()->GetOutputDevice(device); |
103 |
CurrentDevice.AddListener(this); |
104 |
|
105 |
memset (&aqPlayerState.mDataFormat, 0, sizeof(AudioStreamBasicDescription)); |
106 |
|
107 |
aqPlayerState.mDataFormat.mSampleRate = samplerate; |
108 |
aqPlayerState.mDataFormat.mFormatID = kAudioFormatLinearPCM; |
109 |
|
110 |
aqPlayerState.mDataFormat.mFormatFlags = |
111 |
kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked; |
112 |
|
113 |
int samplesize = 4; |
114 |
aqPlayerState.mDataFormat.mBytesPerPacket = uiCoreAudioChannels * samplesize; |
115 |
aqPlayerState.mDataFormat.mFramesPerPacket = 1; |
116 |
aqPlayerState.mDataFormat.mBytesPerFrame = uiCoreAudioChannels * samplesize; |
117 |
aqPlayerState.mDataFormat.mChannelsPerFrame = uiCoreAudioChannels; |
118 |
aqPlayerState.mDataFormat.mBitsPerChannel = 8 * samplesize; |
119 |
aqPlayerState.mDataFormat.mReserved = 0; |
120 |
|
121 |
aqPlayerState.mBuffers = new AudioQueueBufferRef[uiBufferNumber]; |
122 |
|
123 |
aqPlayerState.bufferByteSize = |
124 |
MaxSamplesPerCycle() * aqPlayerState.mDataFormat.mBytesPerFrame; |
125 |
|
126 |
aqPlayerState.mNumPacketsToRead = MaxSamplesPerCycle(); |
127 |
|
128 |
aqPlayerState.pDevice = this; |
129 |
aqPlayerState.mQueue = NULL; |
130 |
|
131 |
uint fragmentSize = MaxSamplesPerCycle(); |
132 |
// create audio channels for this audio device to which the sampler engines can write to |
133 |
for (int i = 0; i < uiCoreAudioChannels; i++) { |
134 |
this->Channels.push_back(new AudioChannel(i, fragmentSize)); |
135 |
} |
136 |
|
137 |
StartThread(); |
138 |
|
139 |
if (!((DeviceCreationParameterBool*)Parameters["ACTIVE"])->ValueAsBool()) { |
140 |
Stop(); |
141 |
} |
142 |
} |
143 |
|
144 |
AudioOutputDeviceCoreAudio::~AudioOutputDeviceCoreAudio() { |
145 |
atomic_set(&(aqPlayerState.mIsRunning), 0); |
146 |
{ |
147 |
LockGuard lock(destroyMutex); |
148 |
AudioQueueDispose(aqPlayerState.mQueue, true); |
149 |
} |
150 |
delete [] aqPlayerState.mBuffers; |
151 |
|
152 |
CurrentDevice.RemoveListener(this); |
153 |
} |
154 |
|
155 |
String AudioOutputDeviceCoreAudio::Name() { |
156 |
return "COREAUDIO"; |
157 |
} |
158 |
|
159 |
String AudioOutputDeviceCoreAudio::Description() { |
160 |
return "Apple CoreAudio"; |
161 |
} |
162 |
|
163 |
String AudioOutputDeviceCoreAudio::Version() { |
164 |
String s = "$Revision$"; |
165 |
return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword |
166 |
} |
167 |
|
168 |
void AudioOutputDeviceCoreAudio::Play() { |
169 |
atomic_set(&pausedNew, 0); |
170 |
} |
171 |
|
172 |
bool AudioOutputDeviceCoreAudio::IsPlaying() { |
173 |
return !atomic_read(&pausedNew); |
174 |
} |
175 |
|
176 |
void AudioOutputDeviceCoreAudio::Stop() { |
177 |
atomic_set(&pausedNew, 1); |
178 |
} |
179 |
|
180 |
uint AudioOutputDeviceCoreAudio::MaxSamplesPerCycle() { |
181 |
return uiBufferSize; |
182 |
} |
183 |
|
184 |
uint AudioOutputDeviceCoreAudio::SampleRate() { |
185 |
return aqPlayerState.mDataFormat.mSampleRate; |
186 |
} |
187 |
|
188 |
String AudioOutputDeviceCoreAudio::Driver() { |
189 |
return Name(); |
190 |
} |
191 |
|
192 |
AudioChannel* AudioOutputDeviceCoreAudio::CreateChannel(uint ChannelNr) { |
193 |
// just create a mix channel |
194 |
return new AudioChannel(ChannelNr, Channel(ChannelNr % uiCoreAudioChannels)); |
195 |
} |
196 |
|
197 |
void AudioOutputDeviceCoreAudio::FillBuffers() { |
198 |
for (int i = 0; i < uiBufferNumber; ++i) { |
199 |
HandleOutputBuffer ( |
200 |
&aqPlayerState, |
201 |
aqPlayerState.mQueue, |
202 |
aqPlayerState.mBuffers[i] |
203 |
); |
204 |
} |
205 |
} |
206 |
|
207 |
void AudioOutputDeviceCoreAudio::PrimeAudioQueue() { |
208 |
OSStatus res = AudioQueuePrime(aqPlayerState.mQueue, 0, NULL); |
209 |
if(res) { |
210 |
String s = String("AudioQueuePrime: Error ") + ToString(res); |
211 |
throw Exception(s); |
212 |
} |
213 |
} |
214 |
|
215 |
void AudioOutputDeviceCoreAudio::CreateAndStartAudioQueue() throw(Exception) { |
216 |
OSStatus res = AudioQueueNewOutput ( |
217 |
&aqPlayerState.mDataFormat, |
218 |
HandleOutputBuffer, |
219 |
&aqPlayerState, |
220 |
CFRunLoopGetCurrent(), |
221 |
kCFRunLoopCommonModes, |
222 |
0, |
223 |
&aqPlayerState.mQueue |
224 |
); |
225 |
|
226 |
if(res) { |
227 |
String s = String("AudioQueueNewOutput: Error ") + ToString(res); |
228 |
throw Exception(s); |
229 |
} |
230 |
|
231 |
CFStringRef devUID = CFStringCreateWithCString ( |
232 |
NULL, CurrentDevice.GetUID().c_str(), kCFStringEncodingASCII |
233 |
); |
234 |
res = AudioQueueSetProperty ( |
235 |
aqPlayerState.mQueue, |
236 |
kAudioQueueProperty_CurrentDevice, |
237 |
&devUID, sizeof(CFStringRef) |
238 |
); |
239 |
CFRelease(devUID); |
240 |
|
241 |
if(res) { |
242 |
String s = String("Failed to set audio device: ") + ToString(res); |
243 |
throw Exception(s); |
244 |
} |
245 |
|
246 |
for (int i = 0; i < uiBufferNumber; ++i) { |
247 |
res = AudioQueueAllocateBuffer ( |
248 |
aqPlayerState.mQueue, |
249 |
aqPlayerState.bufferByteSize, |
250 |
&aqPlayerState.mBuffers[i] |
251 |
); |
252 |
|
253 |
if(res) { |
254 |
String s = String("AudioQueueAllocateBuffer: Error "); |
255 |
throw Exception(s + ToString(res)); |
256 |
} |
257 |
} |
258 |
|
259 |
res = AudioQueueAddPropertyListener ( |
260 |
aqPlayerState.mQueue, |
261 |
kAudioQueueProperty_CurrentDevice, |
262 |
AudioQueueListener, |
263 |
NULL |
264 |
); |
265 |
if(res) std::cerr << "Failed to register device change listener: " << res << std::endl; |
266 |
|
267 |
res = AudioQueueAddPropertyListener ( |
268 |
aqPlayerState.mQueue, |
269 |
kAudioQueueProperty_IsRunning, |
270 |
AudioQueueListener, |
271 |
NULL |
272 |
); |
273 |
if(res) std::cerr << "Failed to register running listener: " << res << std::endl; |
274 |
|
275 |
Float32 gain = 1.0; |
276 |
|
277 |
res = AudioQueueSetParameter ( |
278 |
aqPlayerState.mQueue, |
279 |
kAudioQueueParam_Volume, |
280 |
gain |
281 |
); |
282 |
|
283 |
if(res) std::cerr << "AudioQueueSetParameter: Error " << res << std::endl; |
284 |
|
285 |
atomic_set(&(aqPlayerState.mIsRunning), 1); |
286 |
FillBuffers(); |
287 |
PrimeAudioQueue(); |
288 |
|
289 |
res = AudioQueueStart(aqPlayerState.mQueue, NULL); |
290 |
if(res) { |
291 |
String s = String("AudioQueueStart: Error ") + ToString(res); |
292 |
throw Exception(s); |
293 |
} |
294 |
} |
295 |
|
296 |
void AudioOutputDeviceCoreAudio::DestroyAudioQueue() { |
297 |
AudioQueueFlush(aqPlayerState.mQueue); |
298 |
AudioQueueStop (aqPlayerState.mQueue, true); |
299 |
AudioQueueDispose(aqPlayerState.mQueue, true); |
300 |
aqPlayerState.mQueue = NULL; |
301 |
} |
302 |
|
303 |
/** |
304 |
* Entry point for the thread. |
305 |
*/ |
306 |
int AudioOutputDeviceCoreAudio::Main() { |
307 |
dmsg(1,("CoreAudio thread started\n")); |
308 |
OSStatus res; |
309 |
if(aqPlayerState.mQueue == NULL) { |
310 |
/* |
311 |
* Need to be run from this thread because of CFRunLoopGetCurrent() |
312 |
* which returns the CFRunLoop object for the current thread. |
313 |
*/ |
314 |
try { CreateAndStartAudioQueue(); } |
315 |
catch(Exception e) { |
316 |
std::cerr << "Failed to star audio queue: " + e.Message() << std::endl; |
317 |
return 0; |
318 |
} |
319 |
} |
320 |
|
321 |
{ |
322 |
LockGuard lock(destroyMutex); |
323 |
do { |
324 |
if(atomic_read(&pausedNew) != pausedOld) { |
325 |
pausedOld = atomic_read(&pausedNew); |
326 |
|
327 |
if(pausedOld) { |
328 |
res = AudioQueuePause(aqPlayerState.mQueue); |
329 |
if(res) std::cerr << "AudioQueuePause: Error " << res << std::endl; |
330 |
} else { |
331 |
res = AudioQueuePrime(aqPlayerState.mQueue, 0, NULL); |
332 |
if(res) std::cerr << "AudioQueuePrime: Error " << res << std::endl; |
333 |
res = AudioQueueStart(aqPlayerState.mQueue, NULL); |
334 |
if(res) std::cerr << "AudioQueueStart: Error " << res << std::endl; |
335 |
} |
336 |
} |
337 |
|
338 |
if(atomic_read(&restartQueue)) { |
339 |
DestroyAudioQueue(); |
340 |
CreateAndStartAudioQueue(); |
341 |
atomic_set(&restartQueue, 0); |
342 |
dmsg(1,("Audio queue restarted")); |
343 |
} |
344 |
|
345 |
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.2, false); |
346 |
} while (atomic_read(&(aqPlayerState.mIsRunning))); |
347 |
} |
348 |
|
349 |
dmsg(2,("CoreAudio thread stopped\n")); |
350 |
|
351 |
pthread_exit(NULL); |
352 |
return 0; |
353 |
} |
354 |
|
355 |
|
356 |
// *************** ParameterDevice *************** |
357 |
// * |
358 |
|
359 |
AudioOutputDeviceCoreAudio::ParameterDevice::ParameterDevice() : DeviceCreationParameterString() { |
360 |
InitWithDefault(); // use default device |
361 |
} |
362 |
|
363 |
AudioOutputDeviceCoreAudio::ParameterDevice::ParameterDevice(String s) |
364 |
throw (Exception) : DeviceCreationParameterString(s) { |
365 |
} |
366 |
|
367 |
String AudioOutputDeviceCoreAudio::ParameterDevice::Description() { |
368 |
return "Output device to be used"; |
369 |
} |
370 |
|
371 |
bool AudioOutputDeviceCoreAudio::ParameterDevice::Fix() { |
372 |
return true; |
373 |
} |
374 |
|
375 |
bool AudioOutputDeviceCoreAudio::ParameterDevice::Mandatory() { |
376 |
return false; |
377 |
} |
378 |
|
379 |
std::map<String,DeviceCreationParameter*> |
380 |
AudioOutputDeviceCoreAudio::ParameterDevice::DependsAsParameters() { |
381 |
return std::map<String,DeviceCreationParameter*>(); // no dependencies |
382 |
} |
383 |
|
384 |
optional<String> |
385 |
AudioOutputDeviceCoreAudio::ParameterDevice::DefaultAsString(std::map<String,String> Parameters) { |
386 |
CAAudioDeviceListModel* devs = CAAudioDeviceListModel::GetModel(); |
387 |
if (devs->GetOutputDeviceCount() < 1) { |
388 |
throw Exception("AudioOutputDeviceCoreAudio: Can't find any output device"); |
389 |
} |
390 |
UInt32 idx = devs->GetOutputDeviceIndex(devs->GetDefaultOutputDeviceID()); |
391 |
return CreateDeviceName(idx); |
392 |
} |
393 |
|
394 |
std::vector<String> |
395 |
AudioOutputDeviceCoreAudio::ParameterDevice::PossibilitiesAsString(std::map<String,String> Parameters) { |
396 |
std::vector<String> deviceNames; |
397 |
|
398 |
CAAudioDeviceListModel* devs = CAAudioDeviceListModel::GetModel(); |
399 |
for(int i = 0; i < devs->GetOutputDeviceCount(); i++) { |
400 |
if(devs->GetOutputDevice(i).GetChannelNumber() < 1) continue; |
401 |
|
402 |
deviceNames.push_back(CreateDeviceName(i)); |
403 |
} |
404 |
|
405 |
return deviceNames; |
406 |
} |
407 |
|
408 |
String AudioOutputDeviceCoreAudio::ParameterDevice::CreateDeviceName(int devIndex) { |
409 |
CAAudioDeviceListModel* devs = CAAudioDeviceListModel::GetModel(); |
410 |
// Note that the space " " is used as delimiter to obtain the |
411 |
// device index. See GetDeviceIndex() |
412 |
return ToString(devIndex + 1) + " " + devs->GetOutputDevice(devIndex).GetName(); |
413 |
} |
414 |
|
415 |
void AudioOutputDeviceCoreAudio::ParameterDevice::OnSetValue(String s) throw (Exception) { |
416 |
// not posssible, as parameter is fix |
417 |
} |
418 |
|
419 |
String AudioOutputDeviceCoreAudio::ParameterDevice::Name() { |
420 |
return "DEVICE"; |
421 |
} |
422 |
|
423 |
int AudioOutputDeviceCoreAudio::ParameterDevice::GetDeviceIndex() { |
424 |
String s = ValueAsString(); |
425 |
if(s.empty()) return -1; |
426 |
int n = s.find(' '); |
427 |
s = s.substr(0, n); |
428 |
return ToInt(s) - 1; |
429 |
} |
430 |
|
431 |
// *************** ParameterSampleRate *************** |
432 |
// * |
433 |
|
434 |
AudioOutputDeviceCoreAudio::ParameterSampleRate::ParameterSampleRate() : |
435 |
AudioOutputDevice::ParameterSampleRate::ParameterSampleRate() { |
436 |
|
437 |
} |
438 |
|
439 |
AudioOutputDeviceCoreAudio::ParameterSampleRate::ParameterSampleRate(String s) : |
440 |
AudioOutputDevice::ParameterSampleRate::ParameterSampleRate(s) { |
441 |
|
442 |
} |
443 |
|
444 |
std::map<String,DeviceCreationParameter*> |
445 |
AudioOutputDeviceCoreAudio::ParameterSampleRate::DependsAsParameters() { |
446 |
static ParameterDevice device; |
447 |
std::map<String,DeviceCreationParameter*> dependencies; |
448 |
dependencies[device.Name()] = &device; |
449 |
return dependencies; |
450 |
} |
451 |
|
452 |
optional<int> |
453 |
AudioOutputDeviceCoreAudio::ParameterSampleRate::DefaultAsInt(std::map<String,String> Parameters) { |
454 |
dmsg(2,("AudioOutputDeviceCoreAudio::ParameterSampleRate::DefaultAsInt()\n")); |
455 |
ParameterDevice dev(Parameters["DEVICE"]); |
456 |
int samplerate = 44100; |
457 |
|
458 |
try { |
459 |
int idx = dev.GetDeviceIndex(); |
460 |
|
461 |
CAAudioDeviceListModel* devs = CAAudioDeviceListModel::GetModel(); |
462 |
samplerate = devs->GetOutputDevice(idx).GetDefaultSamplerate(); |
463 |
} catch(Exception e) { } |
464 |
|
465 |
return samplerate; |
466 |
} |
467 |
|
468 |
std::vector<int> |
469 |
AudioOutputDeviceCoreAudio::ParameterSampleRate::PossibilitiesAsInt(std::map<String,String> Parameters) { |
470 |
ParameterDevice dev(Parameters["DEVICE"]); |
471 |
std::vector<int> srates; |
472 |
|
473 |
try { |
474 |
int idx = dev.GetDeviceIndex(); |
475 |
CAAudioDeviceListModel* devs = CAAudioDeviceListModel::GetModel(); |
476 |
srates = devs->GetOutputDevice(idx).GetNominalSamplerates(); |
477 |
} catch(Exception x) { } |
478 |
|
479 |
return srates; |
480 |
} |
481 |
|
482 |
|
483 |
// *************** ParameterChannels *************** |
484 |
// * |
485 |
|
486 |
AudioOutputDeviceCoreAudio::ParameterChannels::ParameterChannels() : |
487 |
AudioOutputDevice::ParameterChannels::ParameterChannels() { |
488 |
|
489 |
} |
490 |
|
491 |
AudioOutputDeviceCoreAudio::ParameterChannels::ParameterChannels(String s) : |
492 |
AudioOutputDevice::ParameterChannels::ParameterChannels(s) { |
493 |
|
494 |
} |
495 |
|
496 |
optional<int> |
497 |
AudioOutputDeviceCoreAudio::ParameterChannels::DefaultAsInt(std::map<String,String> Parameters) { |
498 |
dmsg(2,("AudioOutputDeviceCoreAudio::ParameterChannels::DefaultAsInt()\n")); |
499 |
ParameterDevice dev(Parameters["DEVICE"]); |
500 |
int chns = 2; |
501 |
|
502 |
try { |
503 |
int idx = dev.GetDeviceIndex(); |
504 |
CAAudioDeviceListModel* devs = CAAudioDeviceListModel::GetModel(); |
505 |
chns = devs->GetOutputDevice(idx).GetChannelNumber(); |
506 |
} catch(Exception e) { } |
507 |
|
508 |
return chns; |
509 |
} |
510 |
|
511 |
std::vector<int> |
512 |
AudioOutputDeviceCoreAudio::ParameterChannels::PossibilitiesAsInt(std::map<String,String> Parameters) { |
513 |
ParameterDevice dev(Parameters["DEVICE"]); |
514 |
std::vector<int> chns; |
515 |
|
516 |
try { |
517 |
int idx = dev.GetDeviceIndex(); |
518 |
CAAudioDeviceListModel* devs = CAAudioDeviceListModel::GetModel(); |
519 |
for(int i = 1; i <= devs->GetOutputDevice(idx).GetChannelNumber(); i++) { |
520 |
chns.push_back(i); |
521 |
} |
522 |
} catch(Exception x) { } |
523 |
|
524 |
return chns; |
525 |
} |
526 |
|
527 |
// *************** ParameterBuffers *************** |
528 |
// * |
529 |
|
530 |
AudioOutputDeviceCoreAudio::ParameterBuffers::ParameterBuffers() : DeviceCreationParameterInt() { |
531 |
InitWithDefault(); |
532 |
} |
533 |
|
534 |
AudioOutputDeviceCoreAudio::ParameterBuffers::ParameterBuffers(String s) |
535 |
throw (Exception) : DeviceCreationParameterInt(s) { |
536 |
} |
537 |
|
538 |
String AudioOutputDeviceCoreAudio::ParameterBuffers::Description() { |
539 |
return "Number of audio buffer"; |
540 |
} |
541 |
|
542 |
bool AudioOutputDeviceCoreAudio::ParameterBuffers::Fix() { |
543 |
return true; |
544 |
} |
545 |
|
546 |
bool AudioOutputDeviceCoreAudio::ParameterBuffers::Mandatory() { |
547 |
return false; |
548 |
} |
549 |
|
550 |
std::map<String,DeviceCreationParameter*> |
551 |
AudioOutputDeviceCoreAudio::ParameterBuffers::DependsAsParameters() { |
552 |
return std::map<String,DeviceCreationParameter*>(); |
553 |
} |
554 |
|
555 |
optional<int> |
556 |
AudioOutputDeviceCoreAudio::ParameterBuffers::DefaultAsInt(std::map<String,String> Parameters) { |
557 |
return 3; |
558 |
} |
559 |
|
560 |
optional<int> |
561 |
AudioOutputDeviceCoreAudio::ParameterBuffers::RangeMinAsInt(std::map<String,String> Parameters) { |
562 |
return 2; |
563 |
} |
564 |
|
565 |
optional<int> |
566 |
AudioOutputDeviceCoreAudio::ParameterBuffers::RangeMaxAsInt(std::map<String,String> Parameters) { |
567 |
return 16; |
568 |
} |
569 |
|
570 |
std::vector<int> |
571 |
AudioOutputDeviceCoreAudio::ParameterBuffers::PossibilitiesAsInt(std::map<String,String> Parameters) { |
572 |
return std::vector<int>(); |
573 |
} |
574 |
|
575 |
void AudioOutputDeviceCoreAudio::ParameterBuffers::OnSetValue(int i) throw (Exception) { |
576 |
// not posssible, as parameter is fix |
577 |
} |
578 |
|
579 |
String AudioOutputDeviceCoreAudio::ParameterBuffers::Name() { |
580 |
return "BUFFERS"; |
581 |
} |
582 |
|
583 |
// *************** ParameterBufferSize *************** |
584 |
// * |
585 |
|
586 |
AudioOutputDeviceCoreAudio::ParameterBufferSize::ParameterBufferSize() : DeviceCreationParameterInt() { |
587 |
InitWithDefault(); |
588 |
} |
589 |
|
590 |
AudioOutputDeviceCoreAudio::ParameterBufferSize::ParameterBufferSize(String s) |
591 |
throw (Exception) : DeviceCreationParameterInt(s) { |
592 |
} |
593 |
|
594 |
String AudioOutputDeviceCoreAudio::ParameterBufferSize::Description() { |
595 |
return "Size of the audio buffer in sample frames"; |
596 |
} |
597 |
|
598 |
bool AudioOutputDeviceCoreAudio::ParameterBufferSize::Fix() { |
599 |
return true; |
600 |
} |
601 |
|
602 |
bool AudioOutputDeviceCoreAudio::ParameterBufferSize::Mandatory() { |
603 |
return false; |
604 |
} |
605 |
|
606 |
std::map<String,DeviceCreationParameter*> |
607 |
AudioOutputDeviceCoreAudio::ParameterBufferSize::DependsAsParameters() { |
608 |
return std::map<String,DeviceCreationParameter*>(); |
609 |
} |
610 |
|
611 |
optional<int> |
612 |
AudioOutputDeviceCoreAudio::ParameterBufferSize::DefaultAsInt(std::map<String,String> Parameters) { |
613 |
return 256; |
614 |
} |
615 |
|
616 |
optional<int> |
617 |
AudioOutputDeviceCoreAudio::ParameterBufferSize::RangeMinAsInt(std::map<String,String> Parameters) { |
618 |
return 32; |
619 |
} |
620 |
|
621 |
optional<int> |
622 |
AudioOutputDeviceCoreAudio::ParameterBufferSize::RangeMaxAsInt(std::map<String,String> Parameters) { |
623 |
return 4096; |
624 |
} |
625 |
|
626 |
std::vector<int> |
627 |
AudioOutputDeviceCoreAudio::ParameterBufferSize::PossibilitiesAsInt(std::map<String,String> Parameters) { |
628 |
return std::vector<int>(); |
629 |
} |
630 |
|
631 |
void AudioOutputDeviceCoreAudio::ParameterBufferSize::OnSetValue(int i) throw (Exception) { |
632 |
// not posssible, as parameter is fix |
633 |
} |
634 |
|
635 |
String AudioOutputDeviceCoreAudio::ParameterBufferSize::Name() { |
636 |
return "BUFFERSIZE"; |
637 |
} |
638 |
} // namespace LinuxSampler |