Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/i386/include/IOKit/audio/IOAudioEngineUserClient.h

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
36class IOAudioEngine;
37class IOAudioStream;
38class IOMemoryDescriptor;
39class IOCommandGate;
40class IOWorkLoop;
41
42class IOAudioEngineUserClient;
43class IOAudioClientBufferSet;
44typedef struct IOAudioFormatNotification;
45typedef struct IOAudioClientBuffer {
46 IOAudioEngineUserClient*userClient;
47 IOAudioStream *audioStream;
48 void*sourceBuffer;
49 IOMemoryDescriptor*sourceBufferDescriptor;
50 IOMemoryMap*sourceBufferMap;
51 void*unmappedSourceBuffer;
52 UInt32numSampleFrames;
53 UInt32numChannels;
54 IOAudioEnginePositionmixedPosition;
55 struct IOAudioClientBuffer*mNextBuffer32;
56 struct IOAudioClientBuffer*nextClip;
57 struct IOAudioClientBuffer*previousClip;
58 struct IOAudioClientBuffer*nextClient;
59IOAudioBufferDataDescriptor *bufferDataDescriptor;
60} IOAudioClientBuffer;
61
62/* IOAudioClientBuffer64 added for binary compatibility with old PPC drivers covered by <rdar://problem/4651809> */
63typedef struct IOAudioClientBuffer64
64{
65 IOAudioClientBuffermAudioClientBuffer32;
66 mach_vm_address_tmUnmappedSourceBuffer64;
67 struct IOAudioClientBuffer64*mNextBuffer64;
68} IOAudioClientBuffer64;
69
70typedef struct IOAudioClientBufferExtendedInfo {
71// Added stuff for registerClientParameterBuffer
72UInt32bufferSetID;
73void*paramBuffer;
74IOMemoryDescriptor*paramBufferDescriptor;
75IOMemoryMap*paramBufferMap;
76void*unmappedParamBuffer;
77struct IOAudioClientBufferExtendedInfo*mNextExtended;
78} IOAudioClientBufferExtendedInfo;
79/* IOAudioClientBufferExtendedInfo64 added for binary compatibility with old PPC drivers covered by <rdar://problem/4651809> */
80typedef struct IOAudioClientBufferExtendedInfo64
81{
82IOAudioClientBufferExtendedInfo mAudioClientBufferExtended32;
83mach_vm_address_tmUnmappedParamBuffer64;
84struct IOAudioClientBufferExtendedInfo64*mNextExtended64;
85}IOAudioClientBufferExtendedInfo64;
86
87
88class IOAudioEngineUserClient : public IOUserClient
89{
90OSDeclareDefaultStructors(IOAudioEngineUserClient)
91
92friend class IOAudioEngine;
93friend class IOAudioClientBufferSet;
94friend class IOAudioStream;
95
96protected:
97IOAudioEngine*audioEngine;
98
99IOWorkLoop*workLoop;
100IOCommandGate*commandGate;
101
102IOExternalMethodold_methods[5];// It's size can't be changed for binary compatibility reasons, no longer used.
103IOExternalTraptrap;
104
105task_tclientTask;
106UInt32numSampleFrames;// Never used...
107
108IOAudioClientBufferSet*clientBufferSetList;
109IORecursiveLock *clientBufferLock;
110
111IOAudioNotificationMessage*notificationMessage;
112
113boolonline;
114
115protected:
116struct ExpansionData {
117IOAudioClientBufferExtendedInfo64*extendedInfo;
118IOExternalMethodmethods[kIOAudioEngineNumCalls];// This size can be changed, this is the new methods pointer
119UInt32classicMode;
120};
121
122ExpansionData *reserved;
123
124public:
125virtual IOReturn externalMethod( uint32_t selector, IOExternalMethodArguments * arguments, IOExternalMethodDispatch * dispatch,
126OSObject * target, void * reference);
127// New code added here...
128// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 0);
129virtual IOReturn registerClientParameterBuffer (void * parameterBuffer, UInt32 bufferSetID); // unused function
130// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 1);
131virtual IOAudioClientBufferExtendedInfo * findExtendedInfo(UInt32 bufferSetID);
132// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 2);
133virtual IOReturn getNearestStartTime(IOAudioStream *audioStream, IOAudioTimeStamp *ioTimeStamp, UInt32 isInput);
134// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 3);
135virtual IOReturn getClientNearestStartTime(IOAudioStream *audioStream, IOAudioTimeStamp *ioTimeStamp, UInt32 isInput);
136// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 4);
137virtual IOReturn safeRegisterClientBuffer(UInt32 audioStreamIndex, void * sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);
138// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 5);
139virtual bool initWithAudioEngine(IOAudioEngine *engine, task_t task, void *securityToken, UInt32 type, OSDictionary *properties);
140// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 6);<rdar://problems/5321701>
141virtual IOReturn safeRegisterClientBuffer64(UInt32 audioStreamIndex, mach_vm_address_t * sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);
142// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 7);<rdar://problems/5321701>
143virtual IOReturn registerClientBuffer64(IOAudioStream *audioStream, mach_vm_address_t sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);
144// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 8);<rdar://problems/5321701>
145virtual IOReturn registerBuffer64(IOAudioStream *audioStream, mach_vm_address_t sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);
146// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 9);<rdar://problems/5321701>
147virtual IOReturn unregisterBuffer64(mach_vm_address_t sourceBuffer, UInt32 bufferSetID);
148// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 10);<rdar://problems/5321701>
149virtual IOReturn unregisterClientBuffer64(mach_vm_address_t * sourceBuffer, UInt32 bufferSetID);
150// OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 11); <rdar://problems/5321701>
151virtual IOAudioClientBufferExtendedInfo64 * findExtendedInfo64(UInt32 bufferSetID);
152
153
154
155private:
156OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 0);
157OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 1);
158OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 2);
159OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 3);
160OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 4);
161OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 5);
162OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 6);
163OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 7);
164OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 8);
165OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 9);
166OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 10);
167OSMetaClassDeclareReservedUsed(IOAudioEngineUserClient, 11);
168
169
170OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 12);
171OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 13);
172OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 14);
173OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 15);
174OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 16);
175OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 17);
176OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 18);
177OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 19);
178OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 20);
179OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 21);
180OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 22);
181OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 23);
182OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 24);
183OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 25);
184OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 26);
185OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 27);
186OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 28);
187OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 29);
188OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 30);
189OSMetaClassDeclareReservedUnused(IOAudioEngineUserClient, 31);
190
191protected:
192virtual IOReturn clientClose();
193virtual IOReturn clientDied();
194
195static IOReturn _closeClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);// <rdar://7529580>
196static IOReturn closeClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
197virtual IOReturn closeClient();
198
199
200virtual IOReturn clientMemoryForType(UInt32 type, UInt32 *flags, IOMemoryDescriptor **memory);
201virtual IOExternalMethod *getExternalMethodForIndex(UInt32 index);
202virtual IOExternalTrap *getExternalTrapForIndex(UInt32 index);
203virtual IOReturn registerNotificationPort(mach_port_t port, UInt32 type, UInt32 refCon);
204
205static IOReturn _registerNotificationAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);// <rdar://7529580>
206static IOReturn registerNotificationAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
207virtual IOReturn registerNotification(mach_port_t port, UInt32 refCon);
208
209virtual void setOnline(bool newOnline);
210
211virtual IOReturn performClientOutput(UInt32 firstSampleFrame, UInt32 loopCount, IOAudioClientBufferSet *bufferSet, UInt32 sampleIntervalHi, UInt32 sampleIntervalLo);
212virtual IOReturn performClientInput(UInt32 firstSampleFrame, IOAudioClientBufferSet *bufferSet);
213virtual void performWatchdogOutput(IOAudioClientBufferSet *clientBufferSet, UInt32 generationCount);
214
215virtual void lockBuffers();
216virtual void unlockBuffers();
217
218public:
219
220static IOAudioEngineUserClient *withAudioEngine(IOAudioEngine *engine, task_t clientTask, void *securityToken, UInt32 type);
221static IOAudioEngineUserClient *withAudioEngine(IOAudioEngine *engine, task_t clientTask, void *securityToken, UInt32 type, OSDictionary *properties);
222
223virtual bool initWithAudioEngine(IOAudioEngine *engine, task_t task, void *securityToken, UInt32 type);
224
225virtual void free();
226virtual void freeClientBufferSetList();
227virtual void freeClientBuffer(IOAudioClientBuffer64 *clientBuffer);
228
229virtual void stop(IOService *provider);
230
231virtual bool isOnline();
232
233virtual IOReturn registerBuffer(IOAudioStream *audioStream, void* sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);
234virtual IOReturn unregisterBuffer( void * sourceBuffer, UInt32 bufferSetID);
235
236static IOReturn _registerBufferAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);// <rdar://7529580>
237static IOReturn registerBufferAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
238static IOReturn _unregisterBufferAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);// <rdar://7529580>
239static IOReturn unregisterBufferAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
240
241virtual IOReturn registerClientBuffer(IOAudioStream *audioStream, void * sourceBuffer, UInt32 bufSizeInBytes, UInt32 bufferSetID);
242virtual IOReturn unregisterClientBuffer(void * sourceBuffer, UInt32 bufferSetID);
243
244static IOReturn _getNearestStartTimeAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);// <rdar://7529580>
245static IOReturn getNearestStartTimeAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
246
247virtual IOAudioClientBufferSet *findBufferSet(UInt32 bufferSetID);
248virtual void removeBufferSet(IOAudioClientBufferSet *bufferSet);
249
250virtual IOReturn getConnectionID(UInt32 *connectionID);
251
252virtual IOReturn clientStart();
253virtual IOReturn clientStop();
254
255static IOReturn _startClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);// <rdar://7529580>
256static IOReturn startClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
257static IOReturn _stopClientAction(OSObject *target, void *arg0, void *arg1, void *arg2, void *arg3);// <rdar://7529580>
258static IOReturn stopClientAction(OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
259
260virtual IOReturn startClient();
261virtual IOReturn stopClient();
262
263virtual IOReturn performClientIO(UInt32 firstSampleFrame, UInt32 loopCount, bool inputIO, UInt32 bufferSetID, UInt32 sampleIntervalHi, UInt32 sampleIntervalLo);
264
265virtual void sendFormatChangeNotification(IOAudioStream *audioStream);
266virtual IOReturn sendNotification(UInt32 notificationType);
267
268};
269
270#endif /* _IOKIT_IOAUDIOENGINEUSERCLIENT_H */
271

Archive Download this file

Revision: 1622