1 /*
2  * Copyright 1993 Network Computing Devices, Inc.
3  *
4  * Permission to use, copy, modify, distribute, and sell this software and its
5  * documentation for any purpose is hereby granted without fee, provided that
6  * the above copyright notice appear in all copies and that both that
7  * copyright notice and this permission notice appear in supporting
8  * documentation, and that the name Network Computing Devices, Inc. not be
9  * used in advertising or publicity pertaining to distribution of this
10  * software without specific, written prior permission.
11  *
12  * THIS SOFTWARE IS PROVIDED 'AS-IS'.  NETWORK COMPUTING DEVICES, INC.,
13  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
14  * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15  * PARTICULAR PURPOSE, OR NONINFRINGEMENT.  IN NO EVENT SHALL NETWORK
16  * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
17  * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
18  * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
19  * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
20  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21  *
22  * $Id: audiolib.h 226 2006-08-31 00:46:14Z jon $
23  * $NCDId: @(#)audiolib.h,v 1.67 1995/12/28 19:46:49 greg Exp $
24  *
25  * <audio/audiolib.h>
26  *
27  * This file contains the low-level application programming interface for the
28  * NCD-AUDIO service.
29  */
30 
31 #ifndef _NCD_AUDIOLIB_H_
32 #define _NCD_AUDIOLIB_H_
33 
34 /*****************************************************************************
35  *				    VERSION				     *
36  *****************************************************************************/
37 
38 
39 
40 #define AudioLibraryVersionMajor        2
41 #define AudioLibraryVersionMinor        3
42 #define AudioLibraryVersionTeeny        0
43 
44 #define AudioLibraryVersion             AudioLibraryVersionMajor
45 
46 /*****************************************************************************
47  *			    GET NEEDED HEADER FILES			     *
48  *****************************************************************************/
49 
50 #ifdef USG
51 #ifndef __TYPES__
52 #include <sys/types.h>				/* forgot to protect it... */
53 #define __TYPES__
54 #endif						/* __TYPES__ */
55 #else
56 #if defined(_POSIX_SOURCE) && defined(MOTOROLA)
57 #undef _POSIX_SOURCE
58 #include <sys/types.h>
59 #define _POSIX_SOURCE
60 #else
61 #include <sys/types.h>
62 #endif
63 #endif						/* USG */
64 
65 #include <audio/audio.h>
66 
67 /* applications should not depend on these two headers being included! */
68 #include <audio/Afuncproto.h>
69 #include <audio/Aosdefs.h>
70 
71 
72 #if 0
73 #define AU_MACRO_PREFIX do {
74 #define AU_MACRO_SUFFIX } while (0)
75 #else
76 #define AU_MACRO_PREFIX {
77 #define AU_MACRO_SUFFIX }
78 #endif
79 
80 /*****************************************************************************
81  *				  DATA TYPES				     *
82  *****************************************************************************/
83 
84 #define AuEventsQueuedAlready		0
85 #define AuEventsQueuedAfterReading	1
86 #define AuEventsQueuedAfterFlush	2
87 
88 #define AU_MAX_SCRATCH_FLOWS		3
89 
90 #ifdef AU_NOT_STDC_ENV
91 typedef char   *AuPointer;
92 #else
93 typedef void   *AuPointer;
94 #endif
95 
96 /* struct pre-declarations */
97 struct _AuErrorEvent;
98 struct _AuServer;
99 struct _AuEventHandlerRec;
100 struct _AuEventEnqHandlerRec;
101 struct _AuSyncHandlerRec;
102 union _AuEvent;
103 
104 typedef struct _AuString
105 {
106     int             type;			/* AuStringLatin1, ... */
107     int             len;			/* length in bytes */
108     char           *data;
109 }               AuString;
110 
111 #define AuMakeString(_s, _type, _len, _data)				      \
112 AU_MACRO_PREFIX								      \
113     (_s)->type = _type;							      \
114     (_s)->len = _len;							      \
115     (_s)->data = _data;							      \
116 AU_MACRO_SUFFIX
117 
118 #define AuSetString AuMakeString	/* compatibility */
119 
120 typedef
121 AuBool(*AuErrorHandler) (
122 			 struct _AuServer *,	/* server */
123 			 struct _AuErrorEvent *	/* error_event */
124 );
125 
126 typedef
127 AuBool(*AuIOErrorHandler) (
128 			   struct _AuServer *	/* server */
129 );
130 
131 typedef
132 AuBool(*AuEventHandlerCallback) (
133 				 struct _AuServer *,	/* server */
134 				 union _AuEvent *,	/* event */
135 				 struct _AuEventHandlerRec *	/* who invoked */
136 );
137 
138 #define AuEventHandlerTypeMask		(1L << 0)
139 #define AuEventHandlerIDMask		(1L << 1)
140 #define AuEventHandlerAllMasks	       ((1L << 2) - 1)
141 
142 typedef struct _AuEventHandlerRec
143 {
144     struct _AuServer *aud;			/* server */
145     AuMask          mask;			/* what to compare for match */
146     int             type;			/* AuEventHandler*Mask */
147     AuID            id;				/* id of event */
148     AuEventHandlerCallback callback;		/* whom to call */
149     AuPointer       data;			/* data registered with id */
150     struct _AuEventHandlerRec *next,
151                    *prev;
152 }               AuEventHandlerRec;
153 
154 
155 typedef void
156 (*AuSyncHandlerCallback) (
157 			  struct _AuServer *,		/* server */
158 			  struct _AuSyncHandlerRec *,	/* who called me */
159 			  AuPointer			/* private data */
160 			  );
161 
162 typedef struct _AuSyncHandlerRec
163 {
164     AuSyncHandlerCallback callback;		/* whom to call */
165     AuPointer       data;			/* data registered with id */
166     struct _AuSyncHandlerRec *next,
167                    *prev;
168 }               AuSyncHandlerRec;
169 
170 #define AuEventEnqueuedByAny		0
171 #define AuEventEnqueuedByUnknown	1
172 #define AuEventEnqueuedByReply		2
173 
174 typedef void
175 (*AuEventEnqHandlerCallback)
176 (
177     struct _AuServer *,			/* server */
178     struct _AuEventEnqHandlerRec *,	/* who called me */
179     union _AuEvent *,			/* event */
180     AuPointer				/* private data */
181 );
182 
183 typedef struct _AuEventEnqHandlerRec
184 {
185     AuEventEnqHandlerCallback callback;		/* whom to call */
186     int             who;			/* who enqueued the event */
187     AuPointer       data;			/* data registered with id */
188     struct _AuEventEnqHandlerRec *next,
189                    *prev;
190 }               AuEventEnqHandlerRec;
191 
192 /*
193  * Extensions need a way to hang private data on some structures.
194  */
195 typedef struct _AuExtData
196 {
197     int             number;			/* number returned by
198 						 * XRegisterExtension */
199     struct _AuExtData *next;			/* next item on list of data
200 						 * for structure */
201     int             (*free_private) ();		/* called to free private
202 						 * storage */
203     AuPointer       private_data;		/* data private to this
204 						 * extension. */
205 }               AuExtData;
206 
207 typedef struct _AuExtCodes			/* public to extension,
208 						 * cannot be changed */
209 {
210     int             extension;			/* extension number */
211     int             major_opcode;		/* major op-code assigned by
212 						 * server */
213     int             first_event;		/* first event number for the
214 						 * extension */
215     int             first_error;		/* first error number for the
216 						 * extension */
217 }               AuExtCodes;
218 
219 
220 typedef struct _AuScratchFlow
221 {
222     AuFlowID        flow;
223     AuBool          inuse;
224 }               AuScratchFlow;
225 
226 
227 /*
228  * AudioServer - this contains all of the information needed to send data to
229  * and receive data from the audio server.  Applications should not deref
230  * this structure; they should use the macros instead.
231  */
232 typedef struct _AuServer
233 {
234     AuPointer      *client_data;		/* client can stick stuff
235 						 * here */
236     AuExtData      *ext_data;			/* hook for extension to hang
237 						 * data */
238     int             fd;				/* Network socket. */
239     int             lock;			/* is someone in critical
240 						 * section? */
241     int             proto_major_version;	/* maj. version of server's
242 						 * protocol */
243     int             proto_minor_version;	/* minor version of servers
244 						 * protocol */
245     char           *vendor;			/* vendor of the server
246 						 * hardware */
247     AuID            resource_base;		/* resource ID base */
248     AuID            resource_mask;		/* resource ID mask bits */
249     AuID            resource_id;		/* allocator current ID */
250     int             resource_shift;		/* allocator shift to correct
251 						 * bits */
252                     AuID(*resource_alloc) ();	/* allocator function */
253     int             vnumber;			/* audiolib's protocol
254 						 * version number. */
255     int             release;			/* release of the server */
256     struct _AuSQEvent *head,
257                    *tail;			/* Input event queue. */
258     struct _AuSQEvent *qfree;
259     int             qlen;			/* Length of input event
260 						 * queue */
261     AuUint32   last_request_read;		/* seq number of last event
262 						 * read */
263     AuUint32   request;			/* sequence number of last
264 						 * request. */
265     char           *last_req;			/* beginning of last request,
266 						 * or dummy */
267     char           *buffer;			/* Output buffer starting
268 						 * address. */
269     char           *bufptr;			/* Output buffer index
270 						 * pointer. */
271     char           *bufmax;			/* Output buffer maximum+1
272 						 * address. */
273     unsigned        max_request_size;		/* maximum number 32 bit
274 						 * words in request */
275     struct _AuSyncHandlerRec *synchandler;	/* Synchronization handler */
276     char           *server_name;		/* "host:port" string used on
277 						 * this connect */
278     char           *scratch_buffer;		/* place to hang scratch
279 						 * buffer */
280     AuUint32   scratch_length;		/* length of scratch buffer */
281     int             ext_number;			/* extension number on this
282 						 * server */
283     struct _AuExten *ext_procs;			/* extensions initialized on
284 						 * this aud */
285     /*
286      * the following can be fixed size, as the protocol defines how much
287      * address space is available. While this could be done using the
288      * extension vector, there may be MANY events processed, so a search
289      * through the extension list to find the right procedure for each event
290      * might be expensive if many extensions are being used.
291      */
292                     AuBool(*event_vec[128]) ();	/* vector for wire to event */
293                     AuStatus(*wire_vec[128]) ();/* vector for event to wire */
294     struct _AuInternalAsync *async_handlers;	/* for internal async */
295     AuUint32   flags;			/* internal connection flags */
296                     AuBool(**error_vec) ();	/* vector for wire to error */
297     int             conn_checker;		/* ugly thing used by
298 						 * _AuEventsQueued */
299     AuEventHandlerRec *eventhandlerq;
300     AuEventEnqHandlerRec *eventenqhandlerq;
301     struct
302     {
303 	AuErrorHandler  error_handler;
304 	AuIOErrorHandler ioerror_handler;
305     }               funcs;
306     struct
307     {
308 	int             min_sample_rate;
309 	int             max_sample_rate;
310 	int             max_tracks;
311 	int             num_formats;
312 	int             num_element_types;
313 	int             num_wave_forms;
314 	int             num_actions;
315 	int             num_devices;
316 	int             num_buckets;
317 #ifdef NOTYET
318 	int             num_radios;
319 #endif						/* NOTYET */
320 	int            *formats;
321 	int            *element_types;
322 	int            *wave_forms;
323 	int            *actions;
324 	struct _AuDeviceAttributes *devices;
325 	struct _AuBucketAttributes *buckets;
326 #ifdef NOTYET
327 	AuRadioAttributes *radios;
328 #endif						/* NOTYET */
329     }               connsetup;
330     struct
331     {						/* tmp flows to keep around */
332 	int             total,
333 	                num_inuse;
334 	AuScratchFlow   flows[AU_MAX_SCRATCH_FLOWS];
335     }               scratch_flows;
336 }               AuServer;
337 
338 /* USE THESE MACROS INSTEAD OF DEREFERENCING AUSERVER STRUCTURE! */
339 #define AuServerConnectionNumber(aud)		((aud)->fd)
340 #define AuServerQLength(aud) 			((aud)->qlen)
341 #define AuServerVendor(aud) 			((aud)->vendor)
342 #define AuServerProtocolMajorVersion(aud)	((aud)->proto_major_version)
343 #define AuServerProtocolMinorVersion(aud) 	((aud)->proto_minor_version)
344 #define AuServerVendorRelease(aud) 		((aud)->release)
345 #define AuServerString(aud) 			((aud)->server_name)
346 #define AuServerNextRequest(aud)		((aud)->request + 1)
347 #define AuServerLastKnownRequestProcessed(aud)	((aud)->last_request_read)
348 #define AuServerResourceBase(aud)		((aud)->resource_base)
349 #define AuServerResourceMask(aud)		((aud)->resource_mask)
350 #define AuClientOfID(aud,xxx) \
351     ((xxx) & ~(AuServerResourceMask(aud) | 0xe0000000))
352 
353 #define AuServerMinSampleRate(aud)	((aud)->connsetup.min_sample_rate)
354 #define AuServerMaxSampleRate(aud)	((aud)->connsetup.max_sample_rate)
355 #define AuServerMaxTracks(aud)		((aud)->connsetup.max_tracks)
356 #define AuServerNumFormats(aud)		((aud)->connsetup.num_formats)
357 #define AuServerNumElementTypes(aud)	((aud)->connsetup.num_element_types)
358 #define AuServerNumWaveForms(aud)	((aud)->connsetup.num_wave_forms)
359 #define AuServerNumActions(aud)		((aud)->connsetup.num_actions)
360 #define AuServerNumDevices(aud)		((aud)->connsetup.num_devices)
361 #define AuServerNumBuckets(aud)		((aud)->connsetup.num_buckets)
362 #ifdef NOTYET
363 #define AuServerNumRadios(aud)		((aud)->connsetup.num_radios)
364 #endif						/* NOTYET */
365 #define AuServerFormat(aud, num)		((aud)->connsetup.formats[(num)])
366 #define AuServerElementType(aud, num)	((aud)->connsetup.element_types[(num)])
367 #define AuServerWaveForm(aud, num)	((aud)->connsetup.wave_forms[(num)])
368 #define AuServerAction(aud, num)	((aud)->connsetup.actions[(num)])
369 #define AuServerDevice(aud, num)      (&((aud)->connsetup.devices[(num)]))
370 #define AuServerBucket(aud, num)      (&((aud)->connsetup.buckets[(num)]))
371 #ifdef NOTYET
372 #define AuServerRadio(aud, num)	      (&((aud)->connsetup.radios[(num)]))
373 #endif						/* NOTYET */
374 
375 #define AuAllocID(aud) 			((*(aud)->resource_alloc)((aud)))
376 
377 /*
378  * Attributes used for Devices, Buckets, and Radios
379  */
380 typedef struct _AuCommonPart
381 {
382     AuMask          value_mask;			/* what is present */
383     AuMask          changable_mask;		/* what can be changed */
384     AuID            id;				/* used to reference in flows */
385     unsigned int    kind;			/* what type of object is it */
386     AuMask          use;			/* importable, exportable,
387 						 * etc. */
388     int             format;			/* current value */
389     int             num_tracks;			/* 1 for mono, 2 for stereo,
390 						 * etc. */
391     AuMask          access;			/* who can access */
392     AuString        description;		/* description of device */
393 }               AuCommonPart;
394 
395 #define AuCommonValueMask(c)		((c)->value_mask)
396 #define AuCommonChangableMask(c) 	((c)->changable_mask)
397 #define AuCommonIdentifier(c)		((c)->id)
398 #define AuCommonKind(c)			((c)->kind)
399 #define AuCommonUse(c)			((c)->use)
400 #define AuCommonFormat(c)		((c)->format)
401 #define AuCommonNumTracks(c)		((c)->num_tracks)
402 #define AuCommonAccess(c)		((c)->access)
403 #define AuCommonDescription(c) 		(&((c)->description))
404 
405 /*
406  * Device attributes - these are physical devices attached to the server.
407  */
408 typedef struct _AuDevicePart
409 {
410     unsigned int    min_sample_rate;
411     unsigned int    max_sample_rate;
412     AuMask          location;			/* mask of bits */
413     AuFixedPoint    gain;			/* built into the hardware */
414     AuInt32            line_mode;			/* high vs. low amp circuit */
415     int             num_children;		/* number of subdevices, if
416 						 * any */
417     AuDeviceID     *children;			/* subdevices */
418 }               AuDevicePart;
419 typedef struct _AuDeviceAttributes
420 {
421     AuCommonPart    common;
422     AuDevicePart    device;
423 }               AuDeviceAttributes;
424 
425 #define AuDeviceValueMask(d)		AuCommonValueMask(&(d)->common)
426 #define AuDeviceChangableMask(d)	AuCommonChangableMask(&(d)->common)
427 #define AuDeviceIdentifier(d)		AuCommonIdentifier(&(d)->common)
428 #define AuDeviceKind(d)			AuCommonKind(&(d)->common)
429 #define AuDeviceUse(d)			AuCommonUse(&(d)->common)
430 #define AuDeviceFormat(d)		AuCommonFormat(&(d)->common)
431 #define AuDeviceNumTracks(d)		AuCommonNumTracks(&(d)->common)
432 #define AuDeviceAccess(d)		AuCommonAccess(&(d)->common)
433 #define AuDeviceDescription(d)		AuCommonDescription(&(d)->common)
434 #define AuDeviceMinSampleRate(d)	((d)->device.min_sample_rate)
435 #define AuDeviceMaxSampleRate(d)	((d)->device.max_sample_rate)
436 #define AuDeviceLocation(d)		((d)->device.location)
437 #define AuDeviceGain(d)			((d)->device.gain)
438 #define AuDeviceLineMode(d)		((d)->device.line_mode)
439 #define AuDeviceInputMode(d)		AuDeviceLineMode(d)
440 #define AuDeviceOutputMode(d)		AuDeviceLineMode(d)
441 #define AuDeviceNumChildren(d)		((d)->device.num_children)
442 #define AuDeviceChildren(d)		((d)->device.children)
443 
444 /*
445  * Bucket attributes - these are server storage for sound data.
446  */
447 typedef struct _AuBucketPart
448 {
449     unsigned int    sample_rate;		/* current value */
450     AuUint32   num_samples;		/* max number in this device */
451 }               AuBucketPart;
452 typedef struct _AuBucketAttributes
453 {
454     AuCommonPart    common;
455     AuBucketPart    bucket;
456 }               AuBucketAttributes;
457 
458 #define AuBucketValueMask(b)		AuCommonValueMask(&(b)->common)
459 #define AuBucketChangableMask(b)	AuCommonChangableMask(&(b)->common)
460 #define AuBucketIdentifier(b)		AuCommonIdentifier(&(b)->common)
461 #define AuBucketKind(b)			AuCommonKind(&(b)->common)
462 #define AuBucketUse(b)			AuCommonUse(&(b)->common)
463 #define AuBucketFormat(b)		AuCommonFormat(&(b)->common)
464 #define AuBucketNumTracks(b)		AuCommonNumTracks(&(b)->common)
465 #define AuBucketAccess(b)		AuCommonAccess(&(b)->common)
466 #define AuBucketDescription(b)		AuCommonDescription(&(b)->common)
467 #define AuBucketSampleRate(b)		((b)->bucket.sample_rate)
468 #define AuBucketNumSamples(b)		((b)->bucket.num_samples)
469 
470 #ifdef NOTYET
471 /*
472  * Radio attributes - these are special devices for LAN broadcast audio data
473  */
474 typedef struct _AuRadioPart
475 {
476     int             station;			/* which one you are
477 						 * listening to */
478 }               AuRadioPart;
479 typedef struct _AuRadioAttributes
480 {
481     AuCommonPart    common;
482     AuRadioPart     radio;
483 }               AuRadioAttributes;
484 
485 #define AuRadioValueMask(r)		AuCommonValueMask(&(r)->common)
486 #define AuRadioChangableMask(r)		AuCommonChangableMask(&(r)->common)
487 #define AuRadioIdentifier(r)		AuCommonIdentifier(&(r)->common)
488 #define AuRadioKind(r)			AuCommonKind(&(r)->common)
489 #define AuRadioUse(r)			AuCommonUse(&(r)->common)
490 #define AuRadioFormat(r)		AuCommonFormat(&(r)->common)
491 #define AuRadioNumTracks(r)		AuCommonNumTracks(&(r)->common)
492 #define AuRadioAccess(r)		AuCommonAccess(&(r)->common)
493 #define AuRadioDescription(r)		AuCommonDescription(&(r)->common)
494 #define AuRadioStation(r)		((r)->radio.station)
495 #endif						/* NOTYET */
496 
497 
498 
499 
500 /*
501  * Flows - These are the instructions (called Elements) for how to move audio
502  * data from one place to another.
503  */
504 typedef struct _AuFlowAttributes
505 {
506     unsigned char   state;			/* Stop, Start, Pause */
507     unsigned char   pad1;
508     unsigned short  pad2;
509     AuBool          clocked;			/* instantantious or not */
510 }               AuFlowAttributes;
511 
512 
513 typedef struct _AuElementAction
514 {
515     AuFlowID        flow;			/* target flow to affect */
516     unsigned char   element_num;		/* target element to affect */
517     unsigned char   trigger_state;		/* state to trigger action */
518     unsigned char   trigger_prev_state;		/* previous state to trigger */
519     unsigned char   trigger_reason;		/* reason to trigger action */
520     unsigned char   action;			/* what to do */
521     unsigned char   new_state;			/* new state for target */
522     unsigned short  pad;
523 }               AuElementAction;
524 
525 #define AuMakeChangeStateAction(A, _trigger_state, _trigger_prev_state, _trigger_reason, _flow, _element_num, _new_state)\
526 AU_MACRO_PREFIX								       \
527     (A)->trigger_state = (_trigger_state);				       \
528     (A)->trigger_prev_state = (_trigger_prev_state);			       \
529     (A)->trigger_reason = (_trigger_reason);				       \
530     (A)->action = AuElementActionChangeState;				       \
531     (A)->flow = (_flow);						       \
532     (A)->element_num = (_element_num);					       \
533     (A)->new_state = (_new_state);					       \
534 AU_MACRO_SUFFIX
535 
536 #define AuMakeSendNotifyAction(A, _trigger_state, _trigger_prev_state, _trigger_reason)\
537 AU_MACRO_PREFIX								       \
538     (A)->trigger_state = (_trigger_state);				       \
539     (A)->trigger_prev_state = (_trigger_prev_state);			       \
540     (A)->trigger_reason = (_trigger_reason);				       \
541     (A)->action = AuElementActionSendNotify;				       \
542 AU_MACRO_SUFFIX
543 
544 #define AuMakeNoopAction(A, _trigger_state, _trigger_prev_state, _trigger_reason)\
545 AU_MACRO_PREFIX								       \
546     (A)->trigger_state = (_trigger_state);				       \
547     (A)->trigger_prev_state = (_trigger_prev_state);			       \
548     (A)->trigger_reason = (_trigger_reason);				       \
549     (A)->action = AuElementActionNoop;					       \
550 AU_MACRO_SUFFIX
551 
552 
553 typedef struct _AuElementActionList
554 {
555     int             num_actions;
556     AuElementAction *actions;
557 }               AuElementActionList;
558 
559 /* IMPORTS */
560 
561 typedef struct _AuElementImportClient
562 {
563     unsigned short  type;			/* AuElementTypeImportClient */
564     unsigned short  sample_rate;
565     unsigned char   format;
566     unsigned char   num_tracks;
567     unsigned char   discard;
568     unsigned char   pad;
569     AuUint32   max_samples;
570     AuUint32   low_water_mark;
571     AuElementActionList actions;
572 }               AuElementImportClient;
573 
574 #define AuMakeElementImportClient(E, _sample_rate, _format, _num_tracks, _discard, _max_samples, _low_water_mark, _num_actions, _actions)\
575 AU_MACRO_PREFIX								       \
576     (E)->type = AuElementTypeImportClient;				       \
577     (E)->importclient.sample_rate = (_sample_rate);			       \
578     (E)->importclient.format = (_format);				       \
579     (E)->importclient.num_tracks = (_num_tracks);			       \
580     (E)->importclient.discard = (_discard);				       \
581     (E)->importclient.max_samples = (_max_samples);			       \
582     (E)->importclient.low_water_mark = (_low_water_mark);		       \
583     (E)->importclient.actions.num_actions = (_num_actions);		       \
584     (E)->importclient.actions.actions = (_actions);			       \
585 AU_MACRO_SUFFIX
586 
587 
588 typedef struct _AuElementImportDevice
589 {
590     unsigned short  type;			/* AuElementTypeImportDevice */
591     unsigned short  sample_rate;
592     AuDeviceID      device;
593     AuUint32   num_samples;
594     AuElementActionList actions;
595 }               AuElementImportDevice;
596 
597 #define AuMakeElementImportDevice(E, _sample_rate, _device, _num_samples, _num_actions, _actions)\
598 AU_MACRO_PREFIX								       \
599     (E)->type = AuElementTypeImportDevice;				       \
600     (E)->importdevice.sample_rate = (_sample_rate);			       \
601     (E)->importdevice.device = (_device);				       \
602     (E)->importdevice.num_samples = (_num_samples);			       \
603     (E)->importdevice.actions.num_actions = (_num_actions);		       \
604     (E)->importdevice.actions.actions = (_actions);			       \
605 AU_MACRO_SUFFIX
606 
607 typedef struct _AuElementImportBucket
608 {
609     unsigned short  type;			/* AuElementTypeImportBucket */
610     unsigned short  sample_rate;
611     AuBucketID      bucket;
612     AuUint32   num_samples;
613     AuInt32         parms[AuParmsImportBucket];	/* offset */
614     AuElementActionList actions;
615 }               AuElementImportBucket;
616 
617 #define AuMakeElementImportBucket(E, _sample_rate, _bucket, _num_samples, _offset, _num_actions, _actions)\
618 AU_MACRO_PREFIX								       \
619     (E)->type = AuElementTypeImportBucket;				       \
620     (E)->importbucket.sample_rate = (_sample_rate);			       \
621     (E)->importbucket.bucket = (_bucket);				       \
622     (E)->importbucket.num_samples = (_num_samples);			       \
623     (E)->importbucket.parms[AuParmsImportBucketOffset] = (_offset);	       \
624     (E)->importbucket.actions.num_actions = (_num_actions);		       \
625     (E)->importbucket.actions.actions = (_actions);			       \
626 AU_MACRO_SUFFIX
627 
628 
629 typedef struct _AuElementImportWaveForm
630 {
631     unsigned short  type;		       /* AuElementTypeImportWaveForm */
632     unsigned short  sample_rate;
633     int             wave_form;
634     AuInt32         parms[AuParmsImportWaveForm];	/* freq, num samples */
635     AuElementActionList actions;
636 }               AuElementImportWaveForm;
637 
638 #define AuMakeElementImportWaveForm(E, _sample_rate, _wave_form, _num_samples, _freq, _num_actions, _actions)\
639 AU_MACRO_PREFIX								      \
640     (E)->type = AuElementTypeImportWaveForm;				      \
641     (E)->importwaveform.sample_rate = (_sample_rate);			      \
642     (E)->importwaveform.wave_form = (_wave_form);			      \
643     (E)->importwaveform.parms[AuParmsImportWaveFormFrequency] = (_freq);      \
644     (E)->importwaveform.parms[AuParmsImportWaveFormNumSamples] =	      \
645         (_num_samples);							      \
646     (E)->importwaveform.actions.num_actions = (_num_actions);		      \
647     (E)->importwaveform.actions.actions = (_actions);			      \
648 AU_MACRO_SUFFIX
649 
650 
651 #ifdef NOTYET
652 typedef struct _AuElementImportRadio
653 {
654     unsigned short  type;			/* AuElementTypeImportRadio */
655     unsigned short  sample_rate;
656     AuRadioID       radio;
657     AuUint32   num_samples;
658     AuElementActionList actions;
659 }               AuElementImportRadio;
660 
661 #define AuMakeElementImportRadio(E,asample_rate,aradio,anum_samples,aactions)  \
662 {									       \
663     (E)->type = AuElementTypeImportDevice;				       \
664     (E)->sample_rate = (asample_rate);					       \
665     (E)->radio = (aradio);						       \
666     (E)->num_samples = (anum_samples);					       \
667     (E)->actions = (aactions);						       \
668 }
669 #endif /* NOTYET */
670 
671 
672 /* OPS */
673 
674 typedef struct _AuInputTrack
675 {
676     unsigned char   element_num;
677     unsigned char   track;
678 }               AuInputTrack;
679 
680 #define AuMakeInputTrack(T, _element_num, _track)			       \
681 AU_MACRO_PREFIX								       \
682     (T)->element_num = (_element_num);					       \
683     (T)->track = (_track);						       \
684 AU_MACRO_SUFFIX								       \
685 
686 typedef struct _AuElementBundle
687 {
688     unsigned short  type;			/* AuElementTypeBundle */
689     unsigned short  num_inputs;
690     AuInputTrack   *inputs;
691 }               AuElementBundle;
692 
693 #define AuMakeElementBundle(E, _num_inputs, _inputs)			       \
694 AU_MACRO_PREFIX								       \
695     (E)->type = AuElementTypeBundle;					       \
696     (E)->bundle.num_inputs = (_num_inputs);				       \
697     (E)->bundle.inputs = (_inputs);					       \
698 AU_MACRO_SUFFIX
699 
700 
701 typedef struct _AuElementMultiplyConstant
702 {
703     unsigned short  type;			/* AuElementTypeMultiplyConsta
704 						 * nt */
705     unsigned short  input;
706     AuInt32            parms[AuParmsMultiplyConstant];	/* constant */
707 }               AuElementMultiplyConstant;
708 
709 #define AuMakeElementMultiplyConstant(E, _input, _constant)		       \
710 AU_MACRO_PREFIX								       \
711     (E)->type = AuElementTypeMultiplyConstant;				       \
712     (E)->multiplyconstant.input = (_input);				       \
713     (E)->multiplyconstant.parms[AuParmsMultiplyConstantConstant] = (_constant);\
714 AU_MACRO_SUFFIX
715 
716 
717 typedef struct _AuElementAddConstant
718 {
719     unsigned short  type;			/* AuElementTypeAddConstant */
720     unsigned short  input;
721     AuInt32            parms[AuParmsAddConstant];
722 }               AuElementAddConstant;
723 
724 #define AuMakeElementAddConstant(E, _input, _constant)			       \
725 AU_MACRO_PREFIX								       \
726     (E)->type = AuElementTypeAddConstant;				       \
727     (E)->addconstant.input = (_input);					       \
728     (E)->addconstant.parms[AuParmsAddConstantConstant] = (_constant);	       \
729 AU_MACRO_SUFFIX
730 
731 
732 typedef struct _AuElementSum
733 {
734     unsigned short  type;			/* AuElementTypeSum */
735     unsigned short  num_inputs;
736     unsigned short  *inputs;
737 }               AuElementSum;
738 
739 #define AuMakeElementSum(E, _num_inputs, _inputs)			       \
740 AU_MACRO_PREFIX								       \
741     (E)->type = AuElementTypeSum;					       \
742     (E)->sum.num_inputs = (_num_inputs);				       \
743     (E)->sum.inputs = (_inputs);					       \
744 AU_MACRO_SUFFIX
745 
746 
747 
748 /* EXPORTS */
749 
750 typedef struct _AuElementExportClient
751 {
752     unsigned short  type;			/* AuElementTypeExportClient */
753     unsigned short  sample_rate;
754     unsigned short  input;
755     unsigned char   format;
756     unsigned char   num_tracks;
757     unsigned char   discard;
758     unsigned char   pad;
759     AuUint32   max_samples;
760     AuUint32   high_water_mark;
761     AuElementActionList actions;
762 }               AuElementExportClient;
763 
764 #define AuMakeElementExportClient(E, _input, _sample_rate, _format, _num_tracks, _discard, _max_samples, _high_water_mark, _num_actions, _actions)\
765 AU_MACRO_PREFIX								       \
766     (E)->type = AuElementTypeExportClient;				       \
767     (E)->exportclient.input = (_input);					       \
768     (E)->exportclient.sample_rate = (_sample_rate);			       \
769     (E)->exportclient.format = (_format);				       \
770     (E)->exportclient.num_tracks = (_num_tracks);			       \
771     (E)->exportclient.discard = (_discard);				       \
772     (E)->exportclient.max_samples = (_max_samples);			       \
773     (E)->exportclient.high_water_mark = (_high_water_mark);		       \
774     (E)->exportclient.actions.num_actions = (_num_actions);		       \
775     (E)->exportclient.actions.actions = (_actions);			       \
776 AU_MACRO_SUFFIX
777 
778 typedef struct _AuElementExportDevice
779 {
780     unsigned short  type;			/* AuElementTypeExportDevice */
781     unsigned short  sample_rate;
782     unsigned short  input;
783     AuDeviceID      device;
784     AuUint32   num_samples;
785     AuElementActionList actions;
786 }               AuElementExportDevice;
787 
788 #define AuMakeElementExportDevice(E, _input, _device, _sample_rate, _num_samples, _num_actions, _actions)\
789 AU_MACRO_PREFIX								       \
790     (E)->type = AuElementTypeExportDevice;				       \
791     (E)->exportdevice.sample_rate = (_sample_rate);			       \
792     (E)->exportdevice.input = (_input);					       \
793     (E)->exportdevice.device = (_device);				       \
794     (E)->exportdevice.num_samples = (_num_samples);			       \
795     (E)->exportdevice.actions.num_actions = (_num_actions);		       \
796     (E)->exportdevice.actions.actions = (_actions);			       \
797 AU_MACRO_SUFFIX
798 
799 typedef struct _AuElementExportBucket
800 {
801     unsigned short  type;			/* AuElementTypeExportBucket */
802     unsigned short  input;
803     AuBucketID      bucket;
804     AuUint32   num_samples;
805     AuInt32            parms[AuParmsExportBucket];	/* offset */
806     AuElementActionList actions;
807 }               AuElementExportBucket;
808 
809 #define AuMakeElementExportBucket(E, _input, _bucket, _num_samples, _offset, _num_actions, _actions)\
810 AU_MACRO_PREFIX								       \
811     (E)->type = AuElementTypeExportBucket;				       \
812     (E)->exportbucket.input = (_input);					       \
813     (E)->exportbucket.bucket = (_bucket);				       \
814     (E)->exportbucket.num_samples = (_num_samples);			       \
815     (E)->exportbucket.parms[AuParmsExportBucketOffset] = (_offset);	       \
816     (E)->exportbucket.actions.num_actions = (_num_actions);		       \
817     (E)->exportbucket.actions.actions = (_actions);			       \
818 AU_MACRO_SUFFIX
819 
820 typedef struct _AuElementExportRadio
821 {
822     unsigned short  type;			/* AuElementTypeExportRadio */
823     unsigned short  sample_rate;
824     AuRadioID       radio;
825     AuUint32   num_samples;
826     AuElementActionList actions;
827 }               AuElementExportRadio;
828 
829 #define AuMakeElementExportRadio(E,asample_rate,aradio,anum_samples,aactions)  \
830 {									       \
831     (E)->type = AuElementTypeExportDevice;				       \
832     (E)->sample_rate = (asample_rate);					       \
833     (E)->radio = (aradio);						       \
834     (E)->num_samples = (anum_samples);					       \
835     (E)->actions = (aactions);						       \
836 }
837 
838 typedef struct _AuElementExportMonitor
839 {
840     unsigned short  type;			/* AuElementTypeExportMonitor */
841     unsigned short  event_rate;
842     unsigned short  input;
843     unsigned short  pad;
844     unsigned char   format;
845     unsigned char   num_tracks;
846     unsigned short  pad1;
847 }               AuElementExportMonitor;
848 
849 #define AuMakeElementExportMonitor(E, _input, _event_rate, _format, _num_tracks)\
850 AU_MACRO_PREFIX								       \
851     (E)->type = AuElementTypeExportMonitor;				       \
852     (E)->exportmonitor.input = (_input);				       \
853     (E)->exportmonitor.event_rate = (_event_rate);			       \
854     (E)->exportmonitor.format = (_format);				       \
855     (E)->exportmonitor.num_tracks = (_num_tracks);			       \
856 AU_MACRO_SUFFIX
857 
858 /* UNION OF ELEMENTS */
859 
860 typedef union _AuElement			/* generic element */
861 {
862     unsigned short  type;
863     AuElementImportClient importclient;
864     AuElementImportDevice importdevice;
865     AuElementImportBucket importbucket;
866     AuElementImportWaveForm importwaveform;
867 #ifdef NOTYET
868     AuElementImportRadio importradio;
869 #endif /* NOTYET */
870     AuElementBundle bundle;
871     AuElementMultiplyConstant multiplyconstant;
872     AuElementAddConstant addconstant;
873     AuElementSum    sum;
874     AuElementExportClient exportclient;
875     AuElementExportDevice exportdevice;
876     AuElementExportBucket exportbucket;
877 #ifdef NOTYET
878     AuElementExportRadio exportradio;
879 #endif /* NOTYET */
880     AuElementExportMonitor exportmonitor;
881 }               AuElement;
882 
883 typedef struct _AuElementParameters
884 {
885     AuFlowID        flow;
886     unsigned char   element_num;
887     unsigned char   num_parameters;
888     unsigned short  pad;
889     AuInt32            parameters[AU_MAX_PARMS];
890 }               AuElementParameters;
891 
892 typedef struct _AuElementState
893 {
894     AuFlowID        flow;
895     unsigned char   element_num;
896     unsigned char   state;
897     unsigned short  pad;
898 }               AuElementState;
899 
900 #define AuMakeElementState(S, _flow, _element_num, _state)		       \
901 {									       \
902     (S)->flow = (_flow);						       \
903     (S)->element_num = (_element_num);					       \
904     (S)->state = (_state);						       \
905 }
906 
907 /*****************************************************************************
908  *				    EVENTS				     *
909  *****************************************************************************/
910 
911 typedef struct _AuAnyEvent			/* common to all events */
912 {
913     int             type;
914     AuUint32   serial;
915     AuBool          send_event;
916     AuServer       *server;
917     AuTime          time;
918     AuID            id;				/* primary id */
919 }               AuAnyEvent;
920 
921 
922 typedef struct _AuElementNotifyEvent
923 {
924     int             type;			/* AuEventTypeElementNotify */
925     AuUint32   serial;
926     AuBool          send_event;
927     AuServer       *server;
928     AuTime          time;
929     AuFlowID        flow;
930     unsigned char   element_num;
931     unsigned char   kind;			/* AuElementNotify* */
932     unsigned char   prev_state;			/* of element */
933     unsigned char   cur_state;			/* of element */
934     unsigned char   reason;			/* for event */
935     AuUint32   num_bytes;			/* unread bytes, etc. */
936 }               AuElementNotifyEvent;
937 
938 
939 typedef struct _AuMonitorNotifyEvent
940 {
941     int             type;			/* AuEventTypeElementNotify */
942     AuUint32   serial;
943     AuBool          send_event;
944     AuServer       *server;
945     AuTime          time;
946     AuFlowID        flow;
947     unsigned char   element_num;
948     unsigned char   format;
949     unsigned char   num_tracks;
950     unsigned short  count;
951     unsigned short  num_fields;
952     AuUint32   data;
953     AuUint32   data1;
954     AuUint32   data2;
955 }               AuMonitorNotifyEvent;
956 
957 typedef struct _AuGrabNotifyEvent
958 {
959     int             type;			/* AuEventTypeElementNotify */
960     AuUint32   serial;
961     AuBool          send_event;
962     AuServer       *server;
963     AuTime          time;
964     AuID            id;
965     unsigned char   kind;			/* AuGrabNotifyKind* */
966     unsigned char   pad1;
967     unsigned short  pad2;
968     AuID            client;			/* requestor, prev owner */
969 }               AuGrabNotifyEvent;
970 
971 
972 
973 typedef struct _AuErrorEvent
974 {
975     int             type;
976     AuUint32   serial;			/* of failed request */
977     AuBool          send_event;
978     AuServer       *server;
979     AuTime          time;
980     AuID            resourceid;
981     unsigned char   error_code;			/* of failed request */
982     unsigned char   request_code;		/* Major op-code */
983     unsigned char   minor_code;			/* Minor op-code */
984     union
985     {
986 	AuUint32   l[4];
987     }               data;			/* per-error type data */
988 }               AuErrorEvent;
989 
990 
991 typedef union _AuEvent
992 {
993     int             type;
994     AuAnyEvent      auany;
995     AuElementNotifyEvent auelementnotify;
996     AuMonitorNotifyEvent aumonitornotify;
997     AuGrabNotifyEvent augrabnotify;
998     AuErrorEvent    auerror;
999 }               AuEvent;
1000 
1001 
1002 
1003 
1004 /*****************************************************************************
1005  *		      APPLICATION PROGRAMMING INTERFACES		     *
1006  *****************************************************************************/
1007 
1008 
1009 _AUFUNCPROTOBEGIN
1010 
1011 
1012 /*
1013  * AuServerName - this routine returns the that the library will use to
1014  * locate the audio server.
1015  */
1016 extern const char * AUCDECL
1017 AuServerName(
1018 	     const char *			/* servername */
1019 );
1020 
1021 /*
1022  * AuOpenServer - this routine is used to open a connection to an audio
1023  * server.
1024  */
1025 extern AuServer * AUCDECL
1026 AuOpenServer(
1027 	     const char *,			/* servername */
1028 	     int,				/* num_authproto */
1029 	     const char *,			/* authproto */
1030 	     int,				/* num_authdata */
1031 	     const char *,			/* authdata */
1032 	     char **				/* server_message */
1033 );
1034 
1035 
1036 /*
1037  * AuCloseServer - this routine is used to close a connection to an audio
1038  * server when it is no AuInt32er needed.
1039  */
1040 extern void AUCDECL
1041 AuCloseServer(
1042 	      AuServer *			/* server */
1043 );
1044 
1045 
1046 /*
1047  * AuSetErrorHandler - this routine is used to set the procedure that should
1048  * be called when this connection sees an error that is not being intercepted
1049  * by the library.
1050  */
1051 extern          AuErrorHandler AUCDECL
1052 AuSetErrorHandler(
1053 		  AuServer *,			/* server */
1054 		  AuErrorHandler		/* handler */
1055 );
1056 
1057 
1058 /*
1059  * AuSetIOErrorHandler - this routine is used to set the procedure that
1060  * should be called when the connection to the server has unexpectedly been
1061  * broken.
1062  */
1063 extern          AuIOErrorHandler AUCDECL
1064 AuSetIOErrorHandler(
1065 		    AuServer *,			/* server */
1066 		    AuIOErrorHandler		/* handler */
1067 );
1068 
1069 
1070 /*
1071  * AuFlush - this routine flushes any queued packets down to the server.
1072  */
1073 extern void AUCDECL
1074 AuFlush(
1075 	AuServer *				/* server */
1076 );
1077 
1078 
1079 /*
1080  * AuSync - this routine forces a round trip to the server
1081  */
1082 extern void AUCDECL
1083 AuSync(
1084        AuServer *,				/* server */
1085        AuBool					/* discard_queued_events */
1086 );
1087 
1088 
1089 /*
1090  * AuSynchronize - this routine instructs the library to operate
1091  * synchronously, which may be easier for some applications to deal with.
1092  */
1093 extern          AuBool AUCDECL
1094 AuSynchronize(
1095 	      AuServer *,			/* server */
1096 	      AuBool				/* enablesync */
1097 );
1098 
1099 
1100 /*
1101  * AuGetErrorText - this routine is used to translate error codes into
1102  * English strings for printing.
1103  */
1104 extern void AUCDECL
1105 AuGetErrorText(
1106 	       AuServer *,			/* server */
1107 	       int,				/* code */
1108 	       char *,				/* buffer_return */
1109 	       int				/* length */
1110 );
1111 
1112 
1113 /*
1114  * AuGetErrorDatabaseText - this routine is used to lookup strings for error
1115  * messages.
1116  */
1117 extern void AUCDECL
1118 AuGetErrorDatabaseText(
1119 		       AuServer *,		/* server */
1120 		       const char *,		/* name */
1121 		       const char *,		/* message */
1122 		       const char *,		/* default_string */
1123 		       char *,			/* buffer_return */
1124 		       int			/* length */
1125 );
1126 
1127 
1128 
1129 /*
1130  * AuSetCloseDownMode - this routine instructs the server to save any objects
1131  * created by this client even if it shuts down.
1132  */
1133 extern void AUCDECL
1134 AuSetCloseDownMode(
1135 		   AuServer *,			/* server */
1136 		   int,				/* mode */
1137 		   AuStatus *			/* RETURN_status */
1138 );
1139 
1140 
1141 /*
1142  * AuGetCloseDownMode - this routine returns the current close-down mode for
1143  * this client.
1144  */
1145 extern int AUCDECL
1146 AuGetCloseDownMode(
1147 		   AuServer *,			/* server */
1148 		   AuStatus *			/* RETURN_status */
1149 );
1150 
1151 /*
1152  * AuGetServerTime - this routine returns the current server time
1153  */
1154 extern AuTime AUCDECL
1155 AuGetServerTime(
1156 		   AuServer *,			/* server */
1157 		   AuStatus *			/* RETURN_status */
1158 );
1159 
1160 /*
1161  * AuKillClient - this routine forces the client that created the specified
1162  * resource to close down, regardless of its close down mode.
1163  */
1164 extern void AUCDECL
1165 AuKillClient(
1166 	     AuServer *,			/* server */
1167 	     AuID,				/* resource */
1168 	     AuStatus *				/* RETURN_status */
1169 );
1170 
1171 
1172 
1173 /*
1174  * AuSetDeviceAttributes - this routine is used to change device attributes
1175  * for the fields in changable_mask returned by AuGetDeviceAttributes or the
1176  * setup information.
1177  */
1178 extern void AUCDECL
1179 AuSetDeviceAttributes(
1180 		      AuServer *,		/* server */
1181 		      AuDeviceID,		/* resource */
1182 		      AuMask,			/* value_mask */
1183 		      AuDeviceAttributes *,	/* attr */
1184 		      AuStatus *		/* RETURN_status */
1185 );
1186 
1187 
1188 /*
1189  * AuGetDeviceAttributes - this routine is used to get device attributes
1190  * (which are also provided by the server at connection setup).
1191  */
1192 extern AuDeviceAttributes * AUCDECL
1193 AuGetDeviceAttributes(
1194 		      AuServer *,		/* server */
1195 		      AuDeviceID,		/* resource */
1196 		      AuStatus *		/* RETURN_status */
1197 );
1198 
1199 
1200 /*
1201  * AuListDevices - this routine is used to query the devices
1202  */
1203 extern AuDeviceAttributes * AUCDECL
1204 AuListDevices(
1205 	      AuServer *,			/* server */
1206 	      AuMask,				/* value_mask */
1207 	      AuDeviceAttributes *,		/* attr */
1208 	      int *,				/* RETURN_ndevices */
1209 	      AuStatus *			/* RETURN_status */
1210 );
1211 
1212 
1213 /*
1214  * AuFreeDeviceAttributes - this routine is used to free storage returned by
1215  * calls to AuGetDeviceAttributes.
1216  */
1217 extern void AUCDECL
1218 AuFreeDeviceAttributes(
1219 		       AuServer *,		/* server */
1220 		       int,			/* num_attr */
1221 		       AuDeviceAttributes *	/* attr */
1222 );
1223 
1224 
1225 /*
1226  * AuGetBucketAttributes - this routine is used to get bucket attributes
1227  * (which are also provided by the server at connection setup).
1228  */
1229 extern AuBucketAttributes * AUCDECL
1230 AuGetBucketAttributes(
1231 		      AuServer *,		/* server */
1232 		      AuBucketID,		/* resource */
1233 		      AuStatus *		/* RETURN_status */
1234 );
1235 
1236 
1237 /*
1238  * AuListBuckets - this routine is used to query the buffers for a given
1239  * client, all retained clients, or all known buffers.
1240  */
1241 extern AuBucketAttributes * AUCDECL
1242 AuListBuckets(
1243 	      AuServer *,			/* server */
1244 	      AuMask,				/* value_mask */
1245 	      AuBucketAttributes *,		/* attr */
1246 	      int *,				/* RETURN_nbuckets */
1247 	      AuStatus *			/* RETURN_status */
1248 );
1249 
1250 
1251 /*
1252  * AuFreeBucketAttributes - this routine is used to free storage returned by
1253  * calls to AuGetBucketAttributes.
1254  */
1255 extern void AUCDECL
1256 AuFreeBucketAttributes(
1257 		       AuServer *,		/* server */
1258 		       int,			/* num_attr */
1259 		       AuBucketAttributes *	/* attr */
1260 );
1261 
1262 /*
1263  * AuCreateBucket - this routine is used to create new buckets (buffers,
1264  * radios, wave form generators)
1265  */
1266 extern          AuBucketID AUCDECL
1267 AuCreateBucket(
1268 	       AuServer *,			/* server */
1269 	       AuUint32,			/* format */
1270 	       AuUint32,			/* num tracks */
1271 	       AuUint32,			/* access */
1272 	       AuUint32,			/* sample_rate */
1273 	       AuUint32,			/* num_samples */
1274 	       AuString *,			/* description */
1275 	       AuStatus *			/* RETURN_status */
1276 );
1277 
1278 
1279 /*
1280  * AuDestroyBucket - this routine is used to destroy a bucket once it is no
1281  * AuInt32er being used.
1282  */
1283 extern void AUCDECL
1284 AuDestroyBucket(
1285 		AuServer *,			/* server */
1286 		AuBucketID,			/* bucket */
1287 		AuStatus *			/* RETURN_status */
1288 );
1289 
1290 
1291 /*
1292  * AuCreateFlow - this routine is used to create a Flow object which
1293  * describes how audio data gets from one or more inputs to one or more
1294  * outputs.
1295  */
1296 extern          AuFlowID AUCDECL
1297 AuCreateFlow(
1298 	     AuServer *,			/* server */
1299 	     AuStatus *				/* RETURN_status */
1300 );
1301 
1302 
1303 /*
1304  * AuDestroyFlow - this routine is used to destroy a Flow object once it is
1305  * no AuInt32er needed.
1306  */
1307 extern void AUCDECL
1308 AuDestroyFlow(
1309 	      AuServer *,			/* server */
1310 	      AuFlowID,				/* flow */
1311 	      AuStatus *			/* RETURN_status */
1312 );
1313 
1314 
1315 /*
1316  * AuGetFlowAttributes - this routine is used to find out what the state of
1317  * the flow is at any given time.
1318  */
1319 extern          AuBool AUCDECL
1320 AuGetFlowAttributes(
1321 		    AuServer *,			/* server */
1322 		    int,			/* num_attrs */
1323 		    AuFlowAttributes *,		/* attrs */
1324 		    AuStatus *			/* RETURN_status */
1325 );
1326 
1327 
1328 /*
1329  * AuSetElements - this routine is used to set the flow topology; it is
1330  * equivalent to destroying the flow and recreating it using the same id. The
1331  * API will keep a list of scratch flows to use in sending audio data over
1332  * the wire.
1333  */
1334 extern void AUCDECL
1335 AuSetElements(
1336 	      AuServer *,			/* server */
1337 	      AuFlowID,				/* flow id */
1338 	      AuBool,				/* clocked */
1339 	      int,				/* num_elements */
1340 	      AuElement *,			/* elements */
1341 	      AuStatus *			/* RETURN_status */
1342 );
1343 
1344 
1345 /*
1346  * AuGetElements - this routine is used to return the element topology that
1347  * was set in the AuCreateElements.
1348  */
1349 extern AuElement * AUCDECL
1350 AuGetElements(
1351 	      AuServer *,			/* server */
1352 	      AuFlowID,				/* flow id */
1353 	      AuBool *,				/* RETURN_clocked */
1354 	      int *,				/* RETURN_num_elements */
1355 	      AuStatus *			/* RETURN_status */
1356 );
1357 
1358 
1359 /*
1360  * AuFreeElements - this routine is used to free the results returned from a
1361  * call to AuGetElements.
1362  */
1363 extern void AUCDECL
1364 AuFreeElements(
1365 	       AuServer *,			/* server */
1366 	       int,				/* num_elements */
1367 	       AuElement *			/* listofelements */
1368 );
1369 
1370 
1371 /*
1372  * AuGetElementStates - this routine is used to get the state of various
1373  * elements within a flow.
1374  */
1375 extern AuElementState * AUCDECL
1376 AuGetElementStates(
1377 		   AuServer *,			/* server */
1378 		   int *,			/* INOUT_num_states */
1379 		   AuElementState *,		/* states */
1380 		   AuStatus *			/* RETURN_status */
1381 );
1382 
1383 
1384 /*
1385  * AuFreeElementStates - this routine is used to free the results returned
1386  * from a call to AuGetElementStates.
1387  */
1388 extern void AUCDECL
1389 AuFreeElementStates(
1390 		    AuServer *,			/* server */
1391 		    int,			/* num_elements */
1392 		    AuElementState *		/* list of element states */
1393 );
1394 
1395 
1396 /*
1397  * AuSetElementStates - this routine is used to set the state of various
1398  * elements within a flow.
1399  */
1400 extern void AUCDECL
1401 AuSetElementStates(
1402 		   AuServer *,			/* server */
1403 		   int,				/* num_states */
1404 		   AuElementState *,		/* states */
1405 		   AuStatus *			/* RETURN_status */
1406 );
1407 
1408 
1409 /*
1410  * AuSetElementParameters - this routine is used to change parameters of
1411  * elements within a flow.  Changes in element types is not permitted.
1412  */
1413 extern void AUCDECL
1414 AuSetElementParameters(
1415 		       AuServer *,		/* server */
1416 		       int,			/* num_changes */
1417 		       AuElementParameters *,	/* changes */
1418 		       AuStatus *		/* RETURN_status */
1419 );
1420 
1421 
1422 
1423 /*
1424  * AuWriteElement - this routine is used to send audio data to an
1425  * ImportClient element in a flow.
1426  */
1427 extern void AUCDECL
1428 AuWriteElement(
1429 	       AuServer *,			/* server */
1430 	       AuFlowID,			/* flow */
1431 	       int,				/* element */
1432 	       AuUint32,			/* num_bytes */
1433 	       AuPointer,			/* data */
1434 	       AuBool,				/* end of data flag */
1435 	       AuStatus *			/* RETURN_status */
1436 );
1437 
1438 
1439 /*
1440  * AuReadElement - this routine is used to get audio data from an
1441  * ExportClient element in a flow.
1442  */
1443 extern AuUint32 AUCDECL
1444 AuReadElement(
1445 	      AuServer *,			/* server */
1446 	      AuFlowID,				/* flow */
1447 	      int,				/* element */
1448 	      AuUint32,			/* num_bytes */
1449 	      AuPointer,			/* data */
1450 	      int *				/* RETURN_status */
1451 );
1452 
1453 #define AuEventsQueued _AuEventsQueued
1454 
1455 /*
1456  * AuEventsQueued - this routine is used to see if there are any events
1457  * waiting to be read.
1458  */
1459 extern int AUCDECL
1460 AuEventsQueued(
1461 	       AuServer *,			/* server */
1462 	       int				/* AuEventsQueued_mode */
1463 );
1464 
1465 
1466 /*
1467  * AuScanEvents - this routine is used to walk the event queue looking for
1468  * events that match a client-supplied predicate.  If the predicate returns
1469  * AuTrue for an event, that event is returned to the caller.
1470  */
1471 extern          AuBool AUCDECL
1472 AuScanEvents(
1473 	     AuServer *,			/* server */
1474 	     int,				/* AuEventsQueued_mode */
1475 	     AuBool,				/* dequeue_match */
1476 	     AuBool(*) (			/* clientpredicate */
1477 			AuServer *,		/* server */
1478 			AuEvent *,		/* eventtocheck */
1479 			AuPointer		/* clientdata */
1480 			),
1481 	     AuPointer,				/* clientdata */
1482 	     AuEvent *				/* RETURN_event */
1483 );
1484 
1485 
1486 /*
1487  * AuScanForTypedEvent - this is a convenience routine that calls
1488  * AuScanEvents with a predicate that looks for the specified event type.
1489  */
1490 extern          AuBool AUCDECL
1491 AuScanForTypedEvent(
1492 		    AuServer *,			/* server */
1493 		    int,			/* AuEventsQueued_mode */
1494 		    AuBool,			/* dequeue */
1495 		    int,			/* eventtype */
1496 		    AuEvent *			/* RETURN_event */
1497 );
1498 
1499 
1500 /*
1501  * AuNextEvent - this routine is used to read a queued event.  If there is no
1502  * event available, it will block until one arrives.
1503  */
1504 extern void AUCDECL
1505 AuNextEvent(
1506 	    AuServer *,				/* server */
1507 	    AuBool,				/* dequeue */
1508 	    AuEvent *				/* RETURN_event */
1509 );
1510 
1511 
1512 
1513 
1514 /*
1515  * AuRequeueEvent - this routine puts an event back on the front of the event
1516  * queue.  The skip argument specifies the number of events in the queue to
1517  * skip (0 means the head of the queue, AuServerQLength() means the end of
1518  * the queue).
1519  */
1520 extern          AuBool AUCDECL
1521 AuRequeueEvent(
1522 	       AuServer *,			/* server */
1523 	       AuEvent *,			/* event */
1524 	       int				/* skip */
1525 );
1526 
1527 
1528 /*
1529  * AuIDOfEvent - this routine returns the Flow, Bucket, or Device id from an
1530  * event so that it can be used to dispatch the event to the proper handler.
1531  */
1532 extern          AuID AUCDECL
1533 AuIDOfEvent(
1534 	    AuEvent *				/* RETURN_event */
1535 );
1536 
1537 
1538 extern void  AUCDECL
1539 AuFree (
1540 		    AuPointer
1541 );
1542 
1543 /*****************************************************************************
1544  *				    MACROS				     *
1545  *****************************************************************************/
1546 
1547 /**
1548  * The following macros are provided to make initialization of various
1549  * structures easier:
1550  *
1551  *     AuMakeElementImportClient()
1552  *     AuMakeElementImportDevice()
1553  *     AuMakeElementImportBucket()
1554  *     AuMakeElementImportWaveForm()
1555  *     AuMakeElementImportRadio()
1556  *     AuMakeElementBundle()
1557  *     AuMakeElementMultipleConstant()
1558  *     AuMakeElementAddConstant()
1559  *     AuMakeElementSum()
1560  *     AuMakeElementExportClient()
1561  *     AuMakeElementExportDevice()
1562  *     AuMakeElementExportBucket()
1563  *     AuMakeElementExportRadio()
1564  *
1565  *     AuMakeInputTrack()
1566  *
1567  */
1568 
1569 _AUFUNCPROTOEND
1570 
1571 #include <audio/audioutil.h>			/* get rest of prototypes */
1572 
1573 /*
1574  * Default error handlers.
1575  * These can be set before attempting to open the server to ensure
1576  * that errors in the open procedure are handled.
1577  */
1578 
1579 #if defined(WIN32) && (!defined(_OPENSVR_C_) && !defined(__CYGWIN__))
1580 #define AuDefaultErrorHandler	(*AuDefaultErrorHandler_p)
1581 #define AuDefaultIOErrorHandler	(*AuDefaultIOErrorHandler_p)
1582 #endif /* WIN32 && !_OPENSVR_C_ */
1583 
1584 extern AuErrorHandler AuDefaultErrorHandler;
1585 extern AuIOErrorHandler AuDefaultIOErrorHandler;
1586 
1587 #endif						/* _NCD_AUDIOLIB_H_ */
1588