1 /*
2      File: AUPlugInDispatch.cpp
3  Abstract: AUPlugInDispatch.h
4   Version: 1.1
5 
6  Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
7  Inc. ("Apple") in consideration of your agreement to the following
8  terms, and your use, installation, modification or redistribution of
9  this Apple software constitutes acceptance of these terms.  If you do
10  not agree with these terms, please do not use, install, modify or
11  redistribute this Apple software.
12 
13  In consideration of your agreement to abide by the following terms, and
14  subject to these terms, Apple grants you a personal, non-exclusive
15  license, under Apple's copyrights in this original Apple software (the
16  "Apple Software"), to use, reproduce, modify and redistribute the Apple
17  Software, with or without modifications, in source and/or binary forms;
18  provided that if you redistribute the Apple Software in its entirety and
19  without modifications, you must retain this notice and the following
20  text and disclaimers in all such redistributions of the Apple Software.
21  Neither the name, trademarks, service marks or logos of Apple Inc. may
22  be used to endorse or promote products derived from the Apple Software
23  without specific prior written permission from Apple.  Except as
24  expressly stated in this notice, no other rights or licenses, express or
25  implied, are granted by Apple herein, including but not limited to any
26  patent rights that may be infringed by your derivative works or by other
27  works in which the Apple Software may be incorporated.
28 
29  The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
30  MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
31  THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
32  FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
33  OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
34 
35  IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
36  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38  INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
39  MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
40  AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
41  STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
42  POSSIBILITY OF SUCH DAMAGE.
43 
44  Copyright (C) 2014 Apple Inc. All Rights Reserved.
45 
46 */
47 /**
48 * Audio Unit plug-in client. Unused yet. Unfinished dispatcher for the Audio Component API.
49 * Copyright: Copyright Auburn Sounds 2016.
50 * License:   $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
51 * Authors:   Guillaume Piolat
52 */
53 module dplug.au.audiocomponentdispatch;
54 
55 import derelict.carbon;
56 
57 // Dispatcher for the Audio Component API
58 // Not implemented yet
59 
60 import core.stdc.stdio;
61 
62 
63 struct AudioComponentPlugInInstance
64 {
65     AudioComponentPlugInInterface iface;
66     //AUClient auclient;
67 }
68 
69 extern(C) nothrow
70 {
71     OSStatus audioComponentOpen(void *self, AudioComponentInstance mInstance)
72     {
73         /*
74             OSStatus result = noErr;
75     try {
76         ComponentInitLocker lock;
77 
78         ComponentBase::sNewInstanceType = ComponentBase::kAudioComponentInstance;
79         ComponentBase *cb = (ComponentBase *)(*ACPI->mConstruct)(&ACPI->mInstanceStorage, compInstance);
80         cb->PostConstructor();  // allows base class to do additional initialization
81         // once the derived class is fully constructed
82         result = noErr;
83     }
84     COMPONENT_CATCH
85     if (result)
86         delete ACPI;
87     return result;
88     */
89         import core.stdc.stdio;
90         printf("audioComponentOpen %p %p\n", self, mInstance);
91         return noErr;
92     }
93 
94     OSStatus audioComponentClose(void *self)
95     {
96         /*
97             OSStatus result = noErr;
98     try {
99         if (ACImp) {
100             ACImp->PreDestructor();
101             (*ACPI->mDestruct)(&ACPI->mInstanceStorage);
102             free(self);
103         }
104     }
105     COMPONENT_CATCH
106     return result;
107     */
108         printf("audioComponentClose %p\n", self);
109         return noErr;
110     }
111 
112     AudioComponentMethod audioComponentLookup(SInt16 selector)
113     {
114         switch(selector)
115         {
116             case kAudioUnitInitializeSelect:
117                 return cast(AudioComponentMethod)&AUMethodInitialize;
118             case kAudioUnitUninitializeSelect:
119                 return cast(AudioComponentMethod)&AUMethodUninitialize;
120             case kAudioUnitGetPropertyInfoSelect:
121                 return cast(AudioComponentMethod)&AUMethodGetPropertyInfo;
122             case kAudioUnitGetPropertySelect:
123                 return cast(AudioComponentMethod)&AUMethodGetProperty;
124             case kAudioUnitSetPropertySelect:
125                 return cast(AudioComponentMethod)&AUMethodSetProperty;
126             case kAudioUnitAddPropertyListenerSelect:
127                 return cast(AudioComponentMethod)&AUMethodAddPropertyListener;
128             case kAudioUnitRemovePropertyListenerSelect:
129                 return cast(AudioComponentMethod)&AUMethodRemovePropertyListener;
130             case kAudioUnitRemovePropertyListenerWithUserDataSelect:
131                 return cast(AudioComponentMethod)&AUMethodRemovePropertyListenerWithUserData;
132             case kAudioUnitAddRenderNotifySelect:
133                 return cast(AudioComponentMethod)&AUMethodAddRenderNotify;
134             case kAudioUnitRemoveRenderNotifySelect:
135                 return cast(AudioComponentMethod)&AUMethodRemoveRenderNotify;
136             case kAudioUnitGetParameterSelect:
137                 return cast(AudioComponentMethod)&AUMethodGetParameter;
138             case kAudioUnitSetParameterSelect:
139                 return cast(AudioComponentMethod)&AUMethodSetParameter;
140             case kAudioUnitScheduleParametersSelect:
141                 return cast(AudioComponentMethod)&AUMethodScheduleParameters;
142             case kAudioUnitRenderSelect:
143                 return cast(AudioComponentMethod)&AUMethodRender;
144             case kAudioUnitResetSelect:
145                 return cast(AudioComponentMethod)&AUMethodReset;
146 
147             default:
148                 debug printf("unsupported audioComponentLookup selector %d\n", selector);
149                 return null;
150         }
151     }
152 
153     OSStatus AUMethodInitialize(void* self)
154     {
155         printf("FUTURE AUMethodInitialize\n");
156         return noErr;
157     }
158     OSStatus AUMethodUninitialize(void* self)
159     {
160         printf("FUTURE AUMethodUninitialize\n");
161         return noErr;
162     }
163     OSStatus AUMethodGetPropertyInfo(void* self)
164     {
165         printf("FUTURE AUMethodGetPropertyInfo\n");
166         return noErr;
167     }
168     OSStatus AUMethodGetProperty(void* self)
169     {
170         printf("FUTURE AUMethodGetProperty\n");
171         return noErr;
172     }
173     OSStatus AUMethodSetProperty(void* self)
174     {
175         printf("FUTURE AUMethodSetProperty\n");
176         return noErr;
177     }
178     OSStatus AUMethodAddPropertyListener(void* self)
179     {
180         printf("FUTURE AUMethodAddPropertyListener\n");
181         return noErr;
182     }
183     OSStatus AUMethodRemovePropertyListener(void* self)
184     {
185         printf("FUTURE AUMethodRemovePropertyListener\n");
186         return noErr;
187     }
188     OSStatus AUMethodRemovePropertyListenerWithUserData(void* self)
189     {
190         printf("FUTURE AUMethodRemovePropertyListenerWithUserData\n");
191         return noErr;
192     }
193     OSStatus AUMethodAddRenderNotify(void* self)
194     {
195         printf("FUTURE AUMethodAddRenderNotify\n");
196         return noErr;
197     }
198     OSStatus AUMethodRemoveRenderNotify(void* self)
199     {
200         printf("FUTURE AUMethodRemoveRenderNotify\n");
201         return noErr;
202     }
203     OSStatus AUMethodGetParameter(void* self)
204     {
205         printf("FUTURE AUMethodGetParameter\n");
206         return noErr;
207     }
208     OSStatus AUMethodSetParameter(void* self)
209     {
210         printf("FUTURE AUMethodSetParameter\n");
211         return noErr;
212     }
213     OSStatus AUMethodScheduleParameters(void* self)
214     {
215         printf("FUTURE AUMethodScheduleParameters\n");
216         return noErr;
217     }
218     OSStatus AUMethodRender(void* self)
219     {
220         printf("FUTURE AUMethodRender\n");
221         return noErr;
222     }
223     OSStatus AUMethodReset(void* self)
224     {
225         printf("FUTURE AUMethodReset\n");
226         return noErr;
227     }
228 }