forked from plugdata-team/JUCE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAUPlugInDispatch.cpp
773 lines (674 loc) · 20.9 KB
/
AUPlugInDispatch.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
/*!
@file AudioUnitSDK/AUPlugInDispatch.cpp
@copyright © 2000-2021 Apple Inc. All rights reserved.
*/
#include <AudioUnitSDK/AUBase.h>
#include <AudioUnitSDK/AUPlugInDispatch.h>
#include <AudioUnitSDK/AUUtility.h>
#include <AudioUnitSDK/ComponentBase.h>
#include <cmath>
#include <cstddef>
#define CATCH_EXCEPTIONS_IN_RENDER_METHODS TARGET_OS_OSX // NOLINT
#define HAVE_MUSICDEVICE_PREPARE_RELEASE TARGET_OS_OSX // NOLINT
namespace ausdk {
// ------------------------------------------------------------------------------------------------
static auto AUInstance(void* self)
{
return reinterpret_cast<AUBase*>( // NOLINT reinterpret_cast
&(static_cast<AudioComponentPlugInInstance*>(self)->mInstanceStorage));
}
// ------------------------------------------------------------------------------------------------
class AUInstanceGuard {
public:
explicit AUInstanceGuard(void* self) : mGuard(AUInstance(self)->GetMutex()) {}
private:
const AUEntryGuard mGuard;
};
// ------------------------------------------------------------------------------------------------
static bool IsValidParameterValue(AudioUnitParameterValue value) { return std::isfinite(value); }
static bool AreValidParameterEvents(const AudioUnitParameterEvent* events, UInt32 numEvents)
{
if (events == nullptr) {
return true;
}
for (UInt32 i = 0; i < numEvents; ++i) {
const auto& event = events[i]; // NOLINT
switch (event.eventType) {
case kParameterEvent_Immediate: {
if (!IsValidParameterValue(event.eventValues.immediate.value)) { // NOLINT
return false;
}
break;
}
case kParameterEvent_Ramped: {
if (!IsValidParameterValue(event.eventValues.ramp.startValue) || // NOLINT
!IsValidParameterValue(event.eventValues.ramp.endValue)) { // NOLINT
return false;
}
break;
}
default:
break;
}
}
return true;
}
// ------------------------------------------------------------------------------------------------
static OSStatus AUMethodInitialize(void* self)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
result = AUInstance(self)->DoInitialize();
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodUninitialize(void* self)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
AUInstance(self)->DoCleanup();
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodGetPropertyInfo(void* self, AudioUnitPropertyID prop, AudioUnitScope scope,
AudioUnitElement elem, UInt32* outDataSize, Boolean* outWritable)
{
OSStatus result = noErr;
try {
UInt32 dataSize = 0; // 13517289 GetPropetyInfo was returning an uninitialized value when
// there is an error. This is a problem for auval.
bool writable = false;
const AUInstanceGuard guard(self);
result = AUInstance(self)->DispatchGetPropertyInfo(prop, scope, elem, dataSize, writable);
if (outDataSize != nullptr) {
*outDataSize = dataSize;
}
if (outWritable != nullptr) {
*outWritable = static_cast<Boolean>(writable);
}
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodGetProperty(void* self, AudioUnitPropertyID inID, AudioUnitScope inScope,
AudioUnitElement inElement, void* outData, UInt32* ioDataSize)
{
OSStatus result = noErr;
try {
bool writable = false;
const AUInstanceGuard guard(self);
if (ioDataSize == nullptr) {
AUSDK_LogError("AudioUnitGetProperty: null size pointer");
return kAudio_ParamError;
}
if (outData == nullptr) {
UInt32 dataSize = 0;
result = AUInstance(self)->DispatchGetPropertyInfo(
inID, inScope, inElement, dataSize, writable);
*ioDataSize = dataSize;
return result;
}
const auto clientBufferSize = *ioDataSize;
if (clientBufferSize == 0) {
AUSDK_LogError("AudioUnitGetProperty: *ioDataSize == 0 on entry");
return kAudio_ParamError;
}
UInt32 actualPropertySize = 0;
result = AUInstance(self)->DispatchGetPropertyInfo(
inID, inScope, inElement, actualPropertySize, writable);
if (result != noErr) {
return result;
}
std::vector<std::byte> tempBuffer;
void* destBuffer = nullptr;
if (clientBufferSize < actualPropertySize) {
tempBuffer.resize(actualPropertySize);
destBuffer = tempBuffer.data();
} else {
destBuffer = outData;
}
result = AUInstance(self)->DispatchGetProperty(inID, inScope, inElement, destBuffer);
if (result == noErr) {
if (clientBufferSize < actualPropertySize && !tempBuffer.empty()) {
memcpy(outData, tempBuffer.data(), clientBufferSize);
// ioDataSize remains correct, the number of bytes we wrote
} else {
*ioDataSize = actualPropertySize;
}
} else {
*ioDataSize = 0;
}
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodSetProperty(void* self, AudioUnitPropertyID inID, AudioUnitScope inScope,
AudioUnitElement inElement, const void* inData, UInt32 inDataSize)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
if ((inData != nullptr) && (inDataSize != 0u)) {
result =
AUInstance(self)->DispatchSetProperty(inID, inScope, inElement, inData, inDataSize);
} else {
if (inData == nullptr && inDataSize == 0) {
result = AUInstance(self)->DispatchRemovePropertyValue(inID, inScope, inElement);
} else {
if (inData == nullptr) {
AUSDK_LogError("AudioUnitSetProperty: inData == NULL");
return kAudio_ParamError;
}
if (inDataSize == 0) {
AUSDK_LogError("AudioUnitSetProperty: inDataSize == 0");
return kAudio_ParamError;
}
}
}
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodAddPropertyListener(
void* self, AudioUnitPropertyID prop, AudioUnitPropertyListenerProc proc, void* userData)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
result = AUInstance(self)->AddPropertyListener(prop, proc, userData);
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodRemovePropertyListener(
void* self, AudioUnitPropertyID prop, AudioUnitPropertyListenerProc proc)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
result = AUInstance(self)->RemovePropertyListener(prop, proc, nullptr, false);
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodRemovePropertyListenerWithUserData(
void* self, AudioUnitPropertyID prop, AudioUnitPropertyListenerProc proc, void* userData)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
result = AUInstance(self)->RemovePropertyListener(prop, proc, userData, true);
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodAddRenderNotify(void* self, AURenderCallback proc, void* userData)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
result = AUInstance(self)->SetRenderNotification(proc, userData);
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodRemoveRenderNotify(void* self, AURenderCallback proc, void* userData)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
result = AUInstance(self)->RemoveRenderNotification(proc, userData);
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodGetParameter(void* self, AudioUnitParameterID param, AudioUnitScope scope,
AudioUnitElement elem, AudioUnitParameterValue* value)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
result = (value == nullptr ? kAudio_ParamError
: AUInstance(self)->GetParameter(param, scope, elem, *value));
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodSetParameter(void* self, AudioUnitParameterID param, AudioUnitScope scope,
AudioUnitElement elem, AudioUnitParameterValue value, UInt32 bufferOffset)
{
if (!IsValidParameterValue(value)) {
return kAudioUnitErr_InvalidParameterValue;
}
OSStatus result = noErr;
try {
// this is a (potentially) realtime method; no lock
result = AUInstance(self)->SetParameter(param, scope, elem, value, bufferOffset);
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodScheduleParameters(
void* self, const AudioUnitParameterEvent* events, UInt32 numEvents)
{
if (!AreValidParameterEvents(events, numEvents)) {
return kAudioUnitErr_InvalidParameterValue;
}
OSStatus result = noErr;
try {
// this is a (potentially) realtime method; no lock
result = AUInstance(self)->ScheduleParameter(events, numEvents);
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodRender(void* self, AudioUnitRenderActionFlags* ioActionFlags,
const AudioTimeStamp* inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberFrames,
AudioBufferList* ioData)
{
OSStatus result = noErr;
#if CATCH_EXCEPTIONS_IN_RENDER_METHODS
try {
#endif
// this is a processing method; no lock
AudioUnitRenderActionFlags tempFlags{};
if (inTimeStamp == nullptr || ioData == nullptr) {
result = kAudio_ParamError;
} else {
if (ioActionFlags == nullptr) {
tempFlags = 0;
ioActionFlags = &tempFlags;
}
result = AUInstance(self)->DoRender(
*ioActionFlags, *inTimeStamp, inOutputBusNumber, inNumberFrames, *ioData);
}
#if CATCH_EXCEPTIONS_IN_RENDER_METHODS
}
AUSDK_Catch(result)
#endif
return result;
}
static OSStatus AUMethodComplexRender(void* self, AudioUnitRenderActionFlags* ioActionFlags,
const AudioTimeStamp* inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberOfPackets,
UInt32* outNumberOfPackets, AudioStreamPacketDescription* outPacketDescriptions,
AudioBufferList* ioData, void* outMetadata, UInt32* outMetadataByteSize)
{
OSStatus result = noErr;
#if CATCH_EXCEPTIONS_IN_RENDER_METHODS
try {
#endif
// this is a processing method; no lock
AudioUnitRenderActionFlags tempFlags{};
if (inTimeStamp == nullptr || ioData == nullptr) {
result = kAudio_ParamError;
} else {
if (ioActionFlags == nullptr) {
tempFlags = 0;
ioActionFlags = &tempFlags;
}
result = AUInstance(self)->ComplexRender(*ioActionFlags, *inTimeStamp,
inOutputBusNumber, inNumberOfPackets, outNumberOfPackets, outPacketDescriptions,
*ioData, outMetadata, outMetadataByteSize);
}
#if CATCH_EXCEPTIONS_IN_RENDER_METHODS
}
AUSDK_Catch(result)
#endif
return result;
}
static OSStatus AUMethodReset(void* self, AudioUnitScope scope, AudioUnitElement elem)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
result = AUInstance(self)->Reset(scope, elem);
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodProcess(void* self, AudioUnitRenderActionFlags* ioActionFlags,
const AudioTimeStamp* inTimeStamp, UInt32 inNumberFrames, AudioBufferList* ioData)
{
OSStatus result = noErr;
#if CATCH_EXCEPTIONS_IN_RENDER_METHODS
try {
#endif
// this is a processing method; no lock
bool doParamCheck = true;
AudioUnitRenderActionFlags tempFlags{};
if (ioActionFlags == nullptr) {
tempFlags = 0;
ioActionFlags = &tempFlags;
} else {
if ((*ioActionFlags & kAudioUnitRenderAction_DoNotCheckRenderArgs) != 0u) {
doParamCheck = false;
}
}
if (doParamCheck && (inTimeStamp == nullptr || ioData == nullptr)) {
result = kAudio_ParamError;
} else {
result =
AUInstance(self)->DoProcess(*ioActionFlags, *inTimeStamp, inNumberFrames, *ioData);
}
#if CATCH_EXCEPTIONS_IN_RENDER_METHODS
}
AUSDK_Catch(result)
#endif
return result;
}
static OSStatus AUMethodProcessMultiple(void* self, AudioUnitRenderActionFlags* ioActionFlags,
const AudioTimeStamp* inTimeStamp, UInt32 inNumberFrames, UInt32 inNumberInputBufferLists,
const AudioBufferList** inInputBufferLists, UInt32 inNumberOutputBufferLists,
AudioBufferList** ioOutputBufferLists)
{
OSStatus result = noErr;
#if CATCH_EXCEPTIONS_IN_RENDER_METHODS
try {
#endif
// this is a processing method; no lock
bool doParamCheck = true;
AudioUnitRenderActionFlags tempFlags{};
if (ioActionFlags == nullptr) {
tempFlags = 0;
ioActionFlags = &tempFlags;
} else {
if ((*ioActionFlags & kAudioUnitRenderAction_DoNotCheckRenderArgs) != 0u) {
doParamCheck = false;
}
}
if (doParamCheck && (inTimeStamp == nullptr || inInputBufferLists == nullptr ||
ioOutputBufferLists == nullptr)) {
result = kAudio_ParamError;
} else {
result = AUInstance(self)->DoProcessMultiple(*ioActionFlags, *inTimeStamp,
inNumberFrames, inNumberInputBufferLists, inInputBufferLists,
inNumberOutputBufferLists, ioOutputBufferLists);
}
#if CATCH_EXCEPTIONS_IN_RENDER_METHODS
}
AUSDK_Catch(result)
#endif
return result;
}
// ------------------------------------------------------------------------------------------------
static OSStatus AUMethodStart(void* self)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
result = AUInstance(self)->Start();
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodStop(void* self)
{
OSStatus result = noErr;
try {
const AUInstanceGuard guard(self);
result = AUInstance(self)->Stop();
}
AUSDK_Catch(result)
return result;
}
// ------------------------------------------------------------------------------------------------
// I don't know what I'm doing here; conflicts with the multiple inheritence in MusicDeviceBase.
static OSStatus AUMethodMIDIEvent(
void* self, UInt32 inStatus, UInt32 inData1, UInt32 inData2, UInt32 inOffsetSampleFrame)
{
OSStatus result = noErr;
try {
// this is a potential render-time method; no lock
result = AUInstance(self)->MIDIEvent(inStatus, inData1, inData2, inOffsetSampleFrame);
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodSysEx(void* self, const UInt8* inData, UInt32 inLength)
{
OSStatus result = noErr;
try {
// this is a potential render-time method; no lock
result = AUInstance(self)->SysEx(inData, inLength);
}
AUSDK_Catch(result)
return result;
}
#if AUSDK_MIDI2_AVAILABLE
static OSStatus AUMethodMIDIEventList(
void* self, UInt32 inOffsetSampleFrame, const struct MIDIEventList* eventList)
{
if (eventList == nullptr) {
return kAudio_ParamError;
}
OSStatus result = noErr;
try {
// this is a potential render-time method; no lock
// Note that a MIDIEventList is variably-sized and can be backed by less memory than
// required, so it is Undefined Behavior to form a reference to it; we must only use
// pointers.
result = AUInstance(self)->MIDIEventList(inOffsetSampleFrame, eventList);
}
AUSDK_Catch(result)
return result;
}
#endif
static OSStatus AUMethodStartNote(void* self, MusicDeviceInstrumentID inInstrument,
MusicDeviceGroupID inGroupID, NoteInstanceID* outNoteInstanceID, UInt32 inOffsetSampleFrame,
const MusicDeviceNoteParams* inParams)
{
OSStatus result = noErr;
try {
// this is a potential render-time method; no lock
if (inParams == nullptr) {
result = kAudio_ParamError;
} else {
result = AUInstance(self)->StartNote(
inInstrument, inGroupID, outNoteInstanceID, inOffsetSampleFrame, *inParams);
}
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodStopNote(void* self, MusicDeviceGroupID inGroupID,
NoteInstanceID inNoteInstanceID, UInt32 inOffsetSampleFrame)
{
OSStatus result = noErr;
try {
// this is a potential render-time method; no lock
result = AUInstance(self)->StopNote(inGroupID, inNoteInstanceID, inOffsetSampleFrame);
}
AUSDK_Catch(result)
return result;
}
#if HAVE_MUSICDEVICE_PREPARE_RELEASE
static OSStatus AUMethodPrepareInstrument(void* self, MusicDeviceInstrumentID inInstrument)
{
OSStatus result = noErr;
try {
// this is a potential render-time method; no lock
result = AUInstance(self)->PrepareInstrument(inInstrument); // NOLINT static via instance
}
AUSDK_Catch(result)
return result;
}
static OSStatus AUMethodReleaseInstrument(void* self, MusicDeviceInstrumentID inInstrument)
{
OSStatus result = noErr;
try {
// this is a potential render-time method; no lock
result = AUInstance(self)->ReleaseInstrument(inInstrument); // NOLINT static via instance
}
AUSDK_Catch(result)
return result;
}
#endif // HAVE_MUSICDEVICE_PREPARE_RELEASE
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#pragma mark -
#pragma mark Lookup Methods
AudioComponentMethod AUBaseLookup::Lookup(SInt16 selector)
{
switch (selector) {
case kAudioUnitInitializeSelect:
return (AudioComponentMethod)AUMethodInitialize; // NOLINT cast
case kAudioUnitUninitializeSelect:
return (AudioComponentMethod)AUMethodUninitialize; // NOLINT cast
case kAudioUnitGetPropertyInfoSelect:
return (AudioComponentMethod)AUMethodGetPropertyInfo; // NOLINT cast
case kAudioUnitGetPropertySelect:
return (AudioComponentMethod)AUMethodGetProperty; // NOLINT cast
case kAudioUnitSetPropertySelect:
return (AudioComponentMethod)AUMethodSetProperty; // NOLINT cast
case kAudioUnitAddPropertyListenerSelect:
return (AudioComponentMethod)AUMethodAddPropertyListener; // NOLINT cast
case kAudioUnitRemovePropertyListenerSelect:
return (AudioComponentMethod)AUMethodRemovePropertyListener; // NOLINT cast
case kAudioUnitRemovePropertyListenerWithUserDataSelect:
return (AudioComponentMethod)AUMethodRemovePropertyListenerWithUserData; // NOLINT cast
case kAudioUnitAddRenderNotifySelect:
return (AudioComponentMethod)AUMethodAddRenderNotify; // NOLINT cast
case kAudioUnitRemoveRenderNotifySelect:
return (AudioComponentMethod)AUMethodRemoveRenderNotify; // NOLINT cast
case kAudioUnitGetParameterSelect:
return (AudioComponentMethod)AUMethodGetParameter; // NOLINT cast
case kAudioUnitSetParameterSelect:
return (AudioComponentMethod)AUMethodSetParameter; // NOLINT cast
case kAudioUnitScheduleParametersSelect:
return (AudioComponentMethod)AUMethodScheduleParameters; // NOLINT cast
case kAudioUnitRenderSelect:
return (AudioComponentMethod)AUMethodRender; // NOLINT cast
case kAudioUnitResetSelect:
return (AudioComponentMethod)AUMethodReset; // NOLINT cast
default:
break;
}
return nullptr;
}
AudioComponentMethod AUOutputLookup::Lookup(SInt16 selector)
{
const AudioComponentMethod method = AUBaseLookup::Lookup(selector);
if (method != nullptr) {
return method;
}
switch (selector) {
case kAudioOutputUnitStartSelect:
return (AudioComponentMethod)AUMethodStart; // NOLINT cast
case kAudioOutputUnitStopSelect:
return (AudioComponentMethod)AUMethodStop; // NOLINT cast
default:
break;
}
return nullptr;
}
AudioComponentMethod AUComplexOutputLookup::Lookup(SInt16 selector)
{
AudioComponentMethod method = AUBaseLookup::Lookup(selector);
if (method != nullptr) {
return method;
}
method = AUOutputLookup::Lookup(selector);
if (method != nullptr) {
return method;
}
if (selector == kAudioUnitComplexRenderSelect) {
return (AudioComponentMethod)AUMethodComplexRender; // NOLINT cast
}
return nullptr;
}
AudioComponentMethod AUBaseProcessLookup::Lookup(SInt16 selector)
{
const AudioComponentMethod method = AUBaseLookup::Lookup(selector);
if (method != nullptr) {
return method;
}
if (selector == kAudioUnitProcessSelect) {
return (AudioComponentMethod)AUMethodProcess; // NOLINT cast
}
return nullptr;
}
AudioComponentMethod AUBaseProcessMultipleLookup::Lookup(SInt16 selector)
{
const AudioComponentMethod method = AUBaseLookup::Lookup(selector);
if (method != nullptr) {
return method;
}
if (selector == kAudioUnitProcessMultipleSelect) {
return (AudioComponentMethod)AUMethodProcessMultiple; // NOLINT cast
}
return nullptr;
}
AudioComponentMethod AUBaseProcessAndMultipleLookup::Lookup(SInt16 selector)
{
AudioComponentMethod method = AUBaseLookup::Lookup(selector);
if (method != nullptr) {
return method;
}
method = AUBaseProcessMultipleLookup::Lookup(selector);
if (method != nullptr) {
return method;
}
method = AUBaseProcessLookup::Lookup(selector);
if (method != nullptr) {
return method;
}
return nullptr;
}
inline AudioComponentMethod MIDI_Lookup(SInt16 selector)
{
switch (selector) {
case kMusicDeviceMIDIEventSelect:
return (AudioComponentMethod)AUMethodMIDIEvent; // NOLINT cast
case kMusicDeviceSysExSelect:
return (AudioComponentMethod)AUMethodSysEx; // NOLINT cast
#if AUSDK_MIDI2_AVAILABLE
case kMusicDeviceMIDIEventListSelect:
return (AudioComponentMethod)AUMethodMIDIEventList; // NOLINT cast
#endif
default:
break;
}
return nullptr;
}
AudioComponentMethod AUMIDILookup::Lookup(SInt16 selector)
{
const AudioComponentMethod method = AUBaseLookup::Lookup(selector);
if (method != nullptr) {
return method;
}
return MIDI_Lookup(selector);
}
AudioComponentMethod AUMIDIProcessLookup::Lookup(SInt16 selector)
{
const AudioComponentMethod method = AUBaseProcessLookup::Lookup(selector);
if (method != nullptr) {
return method;
}
return MIDI_Lookup(selector);
}
AudioComponentMethod AUMusicLookup::Lookup(SInt16 selector)
{
const AudioComponentMethod method = AUBaseLookup::Lookup(selector);
if (method != nullptr) {
return method;
}
switch (selector) {
case kMusicDeviceStartNoteSelect:
return (AudioComponentMethod)AUMethodStartNote; // NOLINT cast
case kMusicDeviceStopNoteSelect:
return (AudioComponentMethod)AUMethodStopNote; // NOLINT cast
#if HAVE_MUSICDEVICE_PREPARE_RELEASE
case kMusicDevicePrepareInstrumentSelect:
return (AudioComponentMethod)AUMethodPrepareInstrument; // NOLINT cast
case kMusicDeviceReleaseInstrumentSelect:
return (AudioComponentMethod)AUMethodReleaseInstrument; // NOLINT cast
#endif
default:
break;
}
return MIDI_Lookup(selector);
}
} // namespace ausdk