Root/
Source at commit 2740 created 8 years 11 months ago. By ifabio, sync with trunk. | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 1998-2010 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | *␊ |
6 | * The contents of this file constitute Original Code as defined in and␊ |
7 | * are subject to the Apple Public Source License Version 1.1 (the␊ |
8 | * "License"). You may not use this file except in compliance with the␊ |
9 | * License. Please obtain a copy of the License at␊ |
10 | * http://www.apple.com/publicsource and read it before using this file.␊ |
11 | *␊ |
12 | * This Original Code and all software distributed under the License are␊ |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the␊ |
17 | * License for the specific language governing rights and limitations␊ |
18 | * under the License.␊ |
19 | *␊ |
20 | * @APPLE_LICENSE_HEADER_END@␊ |
21 | */␊ |
22 | ␊ |
23 | #ifndef _IOKIT_IOAUDIOENGINEUSERCLIENT_H␊ |
24 | #define _IOKIT_IOAUDIOENGINEUSERCLIENT_H␊ |
25 | ␊ |
26 | #include <IOKit/IOUserClient.h>␊ |
27 | #ifndef IOAUDIOFAMILY_SELF_BUILD␊ |
28 | #include <IOKit/audio/IOAudioEngine.h>␊ |
29 | #include <IOKit/audio/IOAudioTypes.h>␊ |
30 | #else␊ |
31 | #include "IOAudioEngine.h"␊ |
32 | #include "IOAudioTypes.h"␊ |
33 | #endif␊ |
34 | #include <IOKit/IOBufferMemoryDescriptor.h>␊ |
35 | ␊ |
36 | class IOAudioEngine;␊ |
37 | class IOAudioStream;␊ |
38 | class IOMemoryDescriptor;␊ |
39 | class IOCommandGate;␊ |
40 | class IOWorkLoop;␊ |
41 | ␊ |
42 | class IOAudioEngineUserClient;␊ |
43 | class IOAudioClientBufferSet;␊ |
44 | typedef struct IOAudioFormatNotification;␊ |
45 | typedef struct IOAudioClientBuffer {␊ |
46 | IOAudioEngineUserClient␉␉*userClient;␊ |
47 | IOAudioStream ␉␉␉␉*audioStream;␊ |
48 | void␉␉␉␉␉␉*sourceBuffer;␊ |
49 | IOMemoryDescriptor␉␉␉*sourceBufferDescriptor;␊ |
50 | IOMemoryMap␉␉␉␉␉*sourceBufferMap;␊ |
51 | void␉␉␉␉␉␉*unmappedSourceBuffer; ␊ |
52 | UInt32␉␉␉␉␉␉numSampleFrames;␊ |
53 | UInt32␉␉␉␉␉␉numChannels;␊ |
54 | IOAudioEnginePosition␉␉mixedPosition;␊ |
55 | struct IOAudioClientBuffer␉*mNextBuffer32;␊ |
56 | struct IOAudioClientBuffer␉*nextClip;␊ |
57 | struct IOAudioClientBuffer␉*previousClip;␊ |
58 | struct IOAudioClientBuffer␉*nextClient;␊ |
59 | ␉IOAudioBufferDataDescriptor *bufferDataDescriptor;␊ |
60 | } IOAudioClientBuffer;␊ |
61 | ␊ |
62 | /* IOAudioClientBuffer64 added for binary compatibility with old PPC drivers covered by <rdar://problem/4651809> */␊ |
63 | typedef struct IOAudioClientBuffer64 ␊ |
64 | {␊ |
65 | IOAudioClientBuffer␉␉␉␉mAudioClientBuffer32;␊ |
66 | mach_vm_address_t␉␉␉␉mUnmappedSourceBuffer64;␊ |
67 | struct IOAudioClientBuffer64␉*mNextBuffer64;␊ |
68 | } IOAudioClientBuffer64;␊ |
69 | ␊ |
70 | typedef struct IOAudioClientBufferExtendedInfo {␊ |
71 | ␉// Added stuff for registerClientParameterBuffer␊ |
72 | ␉UInt32␉␉␉␉␉␉bufferSetID;␊ |
73 | ␉void␉␉␉␉␉␉*paramBuffer;␊ |
74 | ␉IOMemoryDescriptor␉␉␉*paramBufferDescriptor;␊ |
75 | ␉IOMemoryMap␉␉␉␉␉*paramBufferMap;␊ |
76 | ␉void␉␉␉␉␉␉*unmappedParamBuffer;␊ |
77 | ␉struct IOAudioClientBufferExtendedInfo␉*mNextExtended;␊ |
78 | } IOAudioClientBufferExtendedInfo;␊ |
79 | /* IOAudioClientBufferExtendedInfo64 added for binary compatibility with old PPC drivers covered by <rdar://problem/4651809> */␊ |
80 | typedef struct IOAudioClientBufferExtendedInfo64 ␊ |
81 | {␊ |
82 | ␉IOAudioClientBufferExtendedInfo mAudioClientBufferExtended32;␊ |
83 | ␉mach_vm_address_t␉␉␉mUnmappedParamBuffer64;␊ |
84 | ␉struct IOAudioClientBufferExtendedInfo64␉*mNextExtended64;␊ |
85 | }␉IOAudioClientBufferExtendedInfo64;␊ |
86 | ␊ |
87 | ␊ |
88 | class IOAudioEngineUserClient : public IOUserClient␊ |
89 | ␉{␊ |
90 | ␉␉OSDeclareDefaultStructors(IOAudioEngineUserClient)␊ |
91 | ␉␉␊ |
92 | ␉␉friend class IOAudioEngine;␊ |
93 | ␉␉friend class IOAudioClientBufferSet;␊ |
94 | ␉␉friend class IOAudioStream;␊ |
95 | ␉␉␊ |
96 | ␉protected:␊ |
97 | ␉␉IOAudioEngine␉␉␉␉*audioEngine;␊ |
98 | ␉␉␊ |
99 | ␉␉IOWorkLoop␉␉␉␉␉*workLoop;␊ |
100 | ␉␉IOCommandGate␉␉␉␉*commandGate;␊ |
101 | ␉␉␊ |
102 | ␉␉IOExternalMethod␉␉␉old_methods[5];␉␉// It's size can't be changed for binary compatibility reasons, no longer used.␊ |
103 | ␉␉IOExternalTrap␉␉␉␉trap;␊ |
104 | ␉␉␊ |
105 | ␉␉task_t␉␉␉␉␉␉clientTask;␊ |
106 | ␉␉UInt32␉␉␉␉␉␉numSampleFrames;␉␉// Never used...␊ |
107 | ␉␉␊ |
108 | ␉␉IOAudioClientBufferSet␉␉*clientBufferSetList;␊ |
109 | ␉␉IORecursiveLock ␉␉␉*clientBufferLock;␊ |
110 | ␉␉␊ |
111 | ␉␉IOAudioNotificationMessage␉*notificationMessage;␊ |
112 | ␉␉␊ |
113 | ␉␉bool␉␉␉␉␉␉online;␊ |
114 | ␉␉␊ |
115 | ␉protected:␊ |
116 | ␉␉struct ExpansionData {␊ |
117 | ␉␉␉IOAudioClientBufferExtendedInfo64␉*extendedInfo;␊ |
118 | ␉␉␉IOExternalMethod␉␉␉␉␉methods[kIOAudioEngineNumCalls];␉␉// This size can be changed, this is the new methods pointer␊ |
119 | ␉␉␉UInt32␉␉␉␉␉␉␉␉classicMode;␊ |
120 | ␉␉};␊ |
121 | ␉␉␊ |
122 | ␉␉ExpansionData *reserved;␊ |
123 | ␉␉␊ |
124 | ␉public:␊ |
125 | ␉␉virtual IOReturn externalMethod( uint32_t selector, IOExternalMethodArguments * arguments, ␉IOExternalMethodDispatch * dispatch, ␊ |
126 | ␉␉␉␉␉␉␉␉␉␉OSObject * target, ␉void * reference);␊ |
127 | ␉␉// New code added here...␊ |
128 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 0);␉␊ |
129 | ␉␉virtual IOReturn registerClientParameterBuffer (void * parameterBuffer, UInt32 bufferSetID); // unused function␊ |
130 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 1);␉␊ |
131 | ␉␉virtual IOAudioClientBufferExtendedInfo * findExtendedInfo(UInt32 bufferSetID);␊ |
132 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 2);␉␊ |
133 | ␉␉virtual IOReturn getNearestStartTime(IOAudioStream *audioStream, IOAudioTimeStamp *ioTimeStamp, UInt32 isInput);␊ |
134 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 3);␉␊ |
135 | ␉␉virtual IOReturn getClientNearestStartTime(IOAudioStream *audioStream, IOAudioTimeStamp *ioTimeStamp, UInt32 isInput);␊ |
136 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 4);␉␊ |
137 | ␉␉virtual IOReturn safeRegisterClientBuffer(UInt32 audioStreamIndex, void * sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);␊ |
138 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 5);␉␊ |
139 | ␉␉virtual bool initWithAudioEngine(IOAudioEngine *engine, task_t task, void *securityToken, UInt32 type, OSDictionary *properties);␉␊ |
140 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 6);␉<rdar://problems/5321701>␊ |
141 | ␉␉virtual IOReturn safeRegisterClientBuffer64(UInt32 audioStreamIndex, mach_vm_address_t * sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);␊ |
142 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 7);␉<rdar://problems/5321701>␊ |
143 | ␉␉virtual IOReturn registerClientBuffer64(IOAudioStream *audioStream, mach_vm_address_t sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);␊ |
144 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 8);␉<rdar://problems/5321701>␊ |
145 | ␉␉virtual IOReturn registerBuffer64(IOAudioStream *audioStream, mach_vm_address_t sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);␊ |
146 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 9);␉<rdar://problems/5321701>␊ |
147 | ␉␉virtual IOReturn unregisterBuffer64(mach_vm_address_t sourceBuffer, UInt32 bufferSetID);␊ |
148 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 10);␉<rdar://problems/5321701>␊ |
149 | ␉␉virtual IOReturn unregisterClientBuffer64(mach_vm_address_t * sourceBuffer, UInt32 bufferSetID);␊ |
150 | ␉␉// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 11);␉ <rdar://problems/5321701>␊ |
151 | ␉␉virtual IOAudioClientBufferExtendedInfo64 * findExtendedInfo64(UInt32 bufferSetID);␊ |
152 | ␉␊ |
153 | ␉␉␊ |
154 | ␉␉␊ |
155 | ␉private:␊ |
156 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 0);␊ |
157 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 1);␊ |
158 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 2);␊ |
159 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 3);␊ |
160 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 4);␊ |
161 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 5);␊ |
162 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 6);␊ |
163 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 7);␊ |
164 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 8);␊ |
165 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 9);␊ |
166 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 10);␊ |
167 | ␉␉OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 11);␊ |
168 | ␉␉␊ |
169 | ␉␉␊ |
170 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 12);␊ |
171 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 13);␊ |
172 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 14);␊ |
173 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 15);␊ |
174 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 16);␊ |
175 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 17);␊ |
176 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 18);␊ |
177 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 19);␊ |
178 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 20);␊ |
179 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 21);␊ |
180 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 22);␊ |
181 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 23);␊ |
182 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 24);␊ |
183 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 25);␊ |
184 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 26);␊ |
185 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 27);␊ |
186 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 28);␊ |
187 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 29);␊ |
188 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 30);␊ |
189 | ␉␉OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 31);␊ |
190 | ␉␉␊ |
191 | ␉protected:␊ |
192 | ␉␉virtual IOReturn clientClose();␊ |
193 | ␉␉virtual IOReturn clientDied();␊ |
194 | ␉␉␊ |
195 | ␉␉static IOReturn _closeClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);␉// <rdar://7529580>␊ |
196 | ␉␉static IOReturn closeClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);␊ |
197 | ␉␉virtual IOReturn closeClient();␊ |
198 | ␉␉␊ |
199 | ␉␉␊ |
200 | ␉␉virtual IOReturn clientMemoryForType(UInt32 type, UInt32 *flags, IOMemoryDescriptor **memory);␊ |
201 | ␉␉virtual IOExternalMethod *getExternalMethodForIndex(UInt32 index);␊ |
202 | ␉␉virtual IOExternalTrap *getExternalTrapForIndex(UInt32 index);␊ |
203 | ␉␉virtual IOReturn registerNotificationPort(mach_port_t port, UInt32 type, UInt32 refCon);␊ |
204 | ␉␉␊ |
205 | ␉␉static IOReturn _registerNotificationAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);␉// <rdar://7529580>␊ |
206 | ␉␉static IOReturn registerNotificationAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);␊ |
207 | ␉␉virtual IOReturn registerNotification(mach_port_t port, UInt32 refCon);␊ |
208 | ␉␊ |
209 | ␉␉virtual void setOnline(bool newOnline);␊ |
210 | ␉␉␊ |
211 | ␉␉virtual IOReturn performClientOutput(UInt32 firstSampleFrame, UInt32 loopCount, IOAudioClientBufferSet *bufferSet, UInt32 sampleIntervalHi, UInt32 sampleIntervalLo);␊ |
212 | ␉␉virtual IOReturn performClientInput(UInt32 firstSampleFrame, IOAudioClientBufferSet *bufferSet);␊ |
213 | ␉␉virtual void performWatchdogOutput(IOAudioClientBufferSet *clientBufferSet, UInt32 generationCount);␊ |
214 | ␉␉␊ |
215 | ␉␉virtual void lockBuffers();␊ |
216 | ␉␉virtual void unlockBuffers();␊ |
217 | ␉␉␊ |
218 | ␉public:␊ |
219 | ␉␉␊ |
220 | ␉␉static IOAudioEngineUserClient *withAudioEngine(IOAudioEngine *engine, task_t clientTask, void *securityToken, UInt32 type);␊ |
221 | ␉␉static IOAudioEngineUserClient *withAudioEngine(IOAudioEngine *engine, task_t clientTask, void *securityToken, UInt32 type, OSDictionary *properties);␊ |
222 | ␉␉␊ |
223 | ␉␉virtual bool initWithAudioEngine(IOAudioEngine *engine, task_t task, void *securityToken, UInt32 type);␊ |
224 | ␉␉␊ |
225 | ␉␉virtual void free();␊ |
226 | ␉␉virtual void freeClientBufferSetList();␊ |
227 | ␉␉virtual void freeClientBuffer(IOAudioClientBuffer64 *clientBuffer);␊ |
228 | ␉␉␊ |
229 | ␉␉virtual void stop(IOService *provider);␊ |
230 | ␉␉␊ |
231 | ␉␉virtual bool isOnline();␊ |
232 | ␉␉␊ |
233 | ␉␉virtual IOReturn registerBuffer(IOAudioStream *audioStream, void* sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);␊ |
234 | ␉␉virtual IOReturn unregisterBuffer( void * sourceBuffer, UInt32 bufferSetID);␊ |
235 | ␉␉␊ |
236 | ␉␉static IOReturn _registerBufferAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);␉// <rdar://7529580>␊ |
237 | ␉␉static IOReturn registerBufferAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);␊ |
238 | ␉␉static IOReturn _unregisterBufferAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);␉// <rdar://7529580>␊ |
239 | ␉␉static IOReturn unregisterBufferAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);␊ |
240 | ␉␉␊ |
241 | ␉␉virtual IOReturn registerClientBuffer(IOAudioStream *audioStream, void * sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);␊ |
242 | ␉␉virtual IOReturn unregisterClientBuffer(void * sourceBuffer, UInt32 bufferSetID);␊ |
243 | ␉␉␊ |
244 | ␉␉static IOReturn _getNearestStartTimeAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);␉// <rdar://7529580>␊ |
245 | ␉␉static IOReturn getNearestStartTimeAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);␊ |
246 | ␉␉␊ |
247 | ␉␉virtual IOAudioClientBufferSet *findBufferSet(UInt32 bufferSetID);␊ |
248 | ␉␉virtual void removeBufferSet(IOAudioClientBufferSet *bufferSet);␊ |
249 | ␉␉␊ |
250 | ␉␉virtual IOReturn getConnectionID(UInt32 *connectionID);␊ |
251 | ␉␉␊ |
252 | ␉␉virtual IOReturn clientStart();␊ |
253 | ␉␉virtual IOReturn clientStop();␊ |
254 | ␉␉␊ |
255 | ␉␉static IOReturn _startClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);␉// <rdar://7529580>␊ |
256 | ␉␉static IOReturn startClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);␊ |
257 | ␉␉static IOReturn _stopClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);␉// <rdar://7529580>␊ |
258 | ␉␉static IOReturn stopClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);␊ |
259 | ␉␉␊ |
260 | ␉␉virtual IOReturn startClient();␊ |
261 | ␉␉virtual IOReturn stopClient();␊ |
262 | ␉␉␊ |
263 | ␉␉virtual IOReturn performClientIO(UInt32 firstSampleFrame, UInt32 loopCount, bool inputIO, UInt32 bufferSetID, UInt32 sampleIntervalHi, UInt32 sampleIntervalLo);␊ |
264 | ␉␉␊ |
265 | ␉␉virtual void sendFormatChangeNotification(IOAudioStream *audioStream);␊ |
266 | ␉␉virtual IOReturn sendNotification(UInt32 notificationType);␊ |
267 | ␉␉␊ |
268 | ␉};␊ |
269 | ␊ |
270 | #endif /* _IOKIT_IOAUDIOENGINEUSERCLIENT_H */␊ |
271 |