|
|
1.1 root 1: /*
2: * Copyright (c) 1998-2000 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: /*!
24: * @header
25: * AudioClientImplementation
26: */
27:
28: #ifndef _IOAUDIOCLIENTIMPL_H
29: #define _IOAUDIOCLIENTIMPL_H
30:
31: #include <IOKit/audio/IOAudio.h>
32: class IOWorkLoop;
33: class IOCommandQueue;
34: class IOTimerEventSource;
35: class IOAudioController;
36:
37: /*!
38: * @enum IOAudioCmd
39: * @discussion Commands for IOAudio workloop's command event source
40: * @constant kConnect
41: * @constant kDetach
42: * @constant kSetFlow
43: * @constant kProbeStreams
44: * @constant kSetVal
45: */
46: typedef enum _IOAudioCmd {
47: kConnect = 0,
48: kDetach,
49: kSetFlow,
50: kProbeStreams,
51: kSetVal,
52: kFlush,
53: kAllocMixBuffer
54: } IOAudioCmd;
55:
56: /*!
57: * @typedef AudioStreamIndex
58: * @discussion Sound hardware contains several data streams which can be controlled to
59: * and accessed to some extent by the CPU.
60: * The driver assigns each of its streams an index, starting from 0.
61: * Most calls to the driver specify the stream to manipulate.
62: */
63: typedef int AudioStreamIndex; // Just to be tidy
64:
65: /*!
66: * @defined
67: * @discussion kNoStream Indicates no stream present
68: */
69: #define kNoStream -1
70:
71: /*!
72: * @struct IOAudioStreamMap
73: * @discussion Structure passed back when a stream is mapped, giving addresses in caller's
74: * address space for the two shared data structures
75: * @field fSampleBuffer Pointer to the buffer for an audio stream
76: * @field fStatus Pointer to status information of an audio stream
77: */
78: struct IOAudioStreamMap
79: {
80: void * fSampleBuffer;
81: IOAudioStreamStatus * fStatus;
82: void * fMixBuffer;
83: };
84:
85: /*!
86: * @class IOAudioComponentImpl
87: * Implemenation for IOAudioComponenet
88: */
89: class IOAudioComponentImpl : public IOAudioComponent
90: {
91: OSDeclareDefaultStructors(IOAudioComponentImpl)
92:
93: protected:
94: IOCommandQueue * fCmdQueue;
95: struct _notifyMsg * fNotifyMsg;
96: IOAudioController * fOwner;
97:
98: /*! @function free Override to free memory */
99: virtual void free();
100:
101: /*!
102: * @function updateVal
103: * @param val
104: * @param control
105: * @param direct
106: * @result IOReturn
107: */
108: virtual IOReturn updateVal(UInt32 val, OSDictionary *control, bool direct);
109:
110: public:
111: /*!
112: * @function initWithStuff
113: * @discussion Initialization.
114: * @param owner
115: * @param props
116: * @param queue
117: * @result bool
118: */
119: virtual bool initWithStuff(IOAudioController *owner, OSDictionary *props,
120: IOCommandQueue *queue);
121:
122: /*!
123: * @function newUserClient
124: * @discussion Create an IOUserClient object to handle marshaling across the kernel/User
125: * boundary. We use the IOAudioStream object itself.
126: * @param owningTask
127: * @param security_id
128: * @param type
129: * @param handler
130: * @result IOReturn
131: */
132: virtual IOReturn newUserClient( task_t owningTask, void * security_id,
133: UInt32 type, IOUserClient ** handler );
134: /*!
135: * @function clientClose
136: * @discussion Methods for IOUserClient.
137: * @param void
138: * @result IOReturn
139: */
140: virtual IOReturn clientClose( void );
141:
142: /*!
143: * @function clientDied
144: * @discussion Methods for IOUserClient.
145: * @param void
146: * @result IOReturn
147: */
148: virtual IOReturn clientDied( void );
149:
150: /*!
151: * @function registerNotificationPort
152: * @discussion Methods for IOUserClient.
153: * @param port
154: * @param type
155: * @param refCon
156: * @result IOReturn
157: */
158: virtual IOReturn registerNotificationPort(
159: mach_port_t port, UInt32 type, UInt32 refCon );
160:
161: /*!
162: * @function setProperties
163: * @discussion Request change in properties, eg. volume, treble, etc.
164: * Properties should be an OSDictionary of the form:
165: * {Controls = {
166: * 'AControl' = {'Val' = newVal;};
167: * 'BControl' = {'Val' = newVal;};
168: * };};
169: *
170: * Other dictionary entries are ignored (so you can pass in a modified
171: * version of the current properties).
172: * @param properties
173: * @result IOReturn
174: */
175: virtual IOReturn setProperties( OSObject * properties );
176:
177: /*!
178: * @function Set
179: * @discussion called from device when hardware state changes.
180: * @param type
181: * @param name
182: * @param val
183: * @result void
184: */
185: virtual void Set(const OSSymbol *type, const OSSymbol *name, int val);
186:
187: /*!
188: * @function GetType
189: * @discussion Handy gettors for Type property
190: * @result OSSymbol
191: */
192: virtual const OSSymbol *GetType() const;
193:
194: /*!
195: * @function GetType
196: * @discussion Handy gettors for Type property
197: * @param obj
198: * @result OSSymbol
199: */
200: virtual const OSSymbol *GetType(const OSObject *obj) const;
201: };
202:
203: /*!
204: * @class IOAudioStreamImpl
205: * Implemenation for IOAudioStream
206: */
207: class IOAudioStreamImpl : public IOAudioStream
208: {
209: OSDeclareDefaultStructors(IOAudioStreamImpl)
210:
211: protected:
212: IOExternalMethod fMethods[kNumCalls];
213: IOAudioStreamMap fMappedMem;
214: AudioStreamIndex fIndex;
215: IOCommandQueue * fCmdQueue;
216:
217: /*! @function free Override to free memory */
218: virtual void free();
219:
220: public:
221: /*!
222: * @function initWithPropsIndexQueue
223: * @discussion
224: * @param props
225: * @param index
226: * @param queue
227: * @result bool
228: */
229: virtual bool initWithPropsIndexQueue(OSDictionary *props,
230: AudioStreamIndex index, IOCommandQueue *queue);
231:
232: /*!
233: * @function getInputDescriptor
234: * @result OSNumber
235: */
236: const OSNumber *getInputDescriptor() const
237: {return OSDynamicCast(OSNumber, getProperty("In"));};
238:
239: /*!
240: * @function getOutputDescriptor
241: * @result OSNumber
242: */
243: const OSNumber *getOutputDescriptor() const
244: {return OSDynamicCast(OSNumber, getProperty("Out"));};
245:
246: /*!
247: * @function newUserClient
248: * @discussion Track client connection and departure so DMA and status buffers can be managed.
249: * @result IOReturn
250: */
251: virtual IOReturn newUserClient( task_t owningTask, void * security_id,
252: UInt32 type, IOUserClient ** handler );
253: /*!
254: * @function clientClose
255: * @discussion Track client connection and departure so DMA and status buffers can be managed.
256: * @result IOReturn
257: */
258: virtual IOReturn clientClose( void );
259:
260: /*!
261: * @function clientDied
262: * @discussion Track client connection and departure so DMA and status buffers can be managed.
263: * @result IOReturn
264: */
265: virtual IOReturn clientDied( void );
266:
267: /*!
268: * @function getExternalMethodForIndex
269: * @param index
270: * @result IOExternalMethod
271: */
272: virtual IOExternalMethod * getExternalMethodForIndex( UInt32 index );
273:
274: /*!
275: * @function clientMemoryForType
276: * @discussion Return info on shared memory so base class can share it out to user space
277: * @param type
278: * @param flags
279: * @param memory
280: * @result IOReturn
281: */
282: virtual IOReturn clientMemoryForType( UInt32 type,
283: UInt32 * flags, IOMemoryDescriptor ** memory );
284:
285: /*!
286: * @function Flush
287: * @discussion See base class
288: * @param end
289: * @result IOReturn
290: */
291: virtual IOReturn Flush(IOAudioStreamPosition *end);
292:
293: /*!
294: * @function setFlow
295: * @discussion Control the flow of data
296: * @param flowing True to flow, false to stop
297: * @result IOReturn
298: */
299: virtual IOReturn setFlow(bool flowing);
300:
301: /*!
302: * @function getMixBuffer
303: * @discussion get the mix buffer for the stream
304: * @param mixBuffer
305: * @result IOReturn kIOReturnSuccess
306: */
307:
308: virtual IOReturn getMixBuffer(void **mixBuffer);
309:
310: /*!
311: * @function setErase
312: * @discussion Control the erase head
313: * @param erase
314: * @param oldErase
315: * @result IOReturn
316: */
317: virtual IOReturn setErase(bool erase, SInt32 *oldErase);
318:
319: /*!
320: * @function isOutput
321: * @discussion Handy shortcut to useful property.
322: * @param res
323: * @result IOReturn
324: */
325: IOReturn isOutput(SInt32 *res) const;
326:
327: /*!
328: * @function setProperties
329: * @discussion Set the audio properties.
330: * @param properties The properties.
331: * @result IOReturn
332: */
333: IOReturn setProperties( OSObject * properties );
334:
335: };
336:
337: #endif /* _IOAUDIOCLIENTIMPL_H */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.