This file is indexed.

/usr/include/audio/audiolib.h is in libaudio-dev 1.9.3-4ubuntu0.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
/*
 * Copyright 1993 Network Computing Devices, Inc.
 * 
 * Permission to use, copy, modify, distribute, and sell this software and its
 * documentation for any purpose is hereby granted without fee, provided that
 * the above copyright notice appear in all copies and that both that
 * copyright notice and this permission notice appear in supporting
 * documentation, and that the name Network Computing Devices, Inc. not be
 * used in advertising or publicity pertaining to distribution of this
 * software without specific, written prior permission.
 * 
 * THIS SOFTWARE IS PROVIDED 'AS-IS'.  NETWORK COMPUTING DEVICES, INC.,
 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
 * LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NONINFRINGEMENT.  IN NO EVENT SHALL NETWORK
 * COMPUTING DEVICES, INC., BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING
 * SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA,
 * OR PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
 * WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 * 
 * $Id: audiolib.h 226 2006-08-31 00:46:14Z jon $
 * $NCDId: @(#)audiolib.h,v 1.67 1995/12/28 19:46:49 greg Exp $
 * 
 * <audio/audiolib.h>
 * 
 * This file contains the low-level application programming interface for the
 * NCD-AUDIO service.
 */

#ifndef _NCD_AUDIOLIB_H_
#define _NCD_AUDIOLIB_H_

/*****************************************************************************
 *				    VERSION				     *
 *****************************************************************************/



#define AudioLibraryVersionMajor        2
#define AudioLibraryVersionMinor        3
#define AudioLibraryVersionTeeny        0

#define AudioLibraryVersion             AudioLibraryVersionMajor

/*****************************************************************************
 *			    GET NEEDED HEADER FILES			     *
 *****************************************************************************/

#ifdef USG
#ifndef __TYPES__
#include <sys/types.h>				/* forgot to protect it... */
#define __TYPES__
#endif						/* __TYPES__ */
#else
#if defined(_POSIX_SOURCE) && defined(MOTOROLA)
#undef _POSIX_SOURCE
#include <sys/types.h>
#define _POSIX_SOURCE
#else
#include <sys/types.h>
#endif
#endif						/* USG */

#include <audio/audio.h>

/* applications should not depend on these two headers being included! */
#include <audio/Afuncproto.h>
#include <audio/Aosdefs.h>


#if 0
#define AU_MACRO_PREFIX do {
#define AU_MACRO_SUFFIX } while (0)
#else
#define AU_MACRO_PREFIX {
#define AU_MACRO_SUFFIX }
#endif

/*****************************************************************************
 *				  DATA TYPES				     *
 *****************************************************************************/

#define AuEventsQueuedAlready		0
#define AuEventsQueuedAfterReading	1
#define AuEventsQueuedAfterFlush	2

#define AU_MAX_SCRATCH_FLOWS		3

#ifdef AU_NOT_STDC_ENV
typedef char   *AuPointer;
#else
typedef void   *AuPointer;
#endif

/* struct pre-declarations */
struct _AuErrorEvent;
struct _AuServer;
struct _AuEventHandlerRec;
struct _AuEventEnqHandlerRec;
struct _AuSyncHandlerRec;
union _AuEvent;

typedef struct _AuString
{
    int             type;			/* AuStringLatin1, ... */
    int             len;			/* length in bytes */
    char           *data;
}               AuString;

#define AuMakeString(_s, _type, _len, _data)				      \
AU_MACRO_PREFIX								      \
    (_s)->type = _type;							      \
    (_s)->len = _len;							      \
    (_s)->data = _data;							      \
AU_MACRO_SUFFIX

#define AuSetString AuMakeString	/* compatibility */

typedef
AuBool(*AuErrorHandler) (
			 struct _AuServer *,	/* server */
			 struct _AuErrorEvent *	/* error_event */
);

typedef
AuBool(*AuIOErrorHandler) (
			   struct _AuServer *	/* server */
);

typedef
AuBool(*AuEventHandlerCallback) (
				 struct _AuServer *,	/* server */
				 union _AuEvent *,	/* event */
				 struct _AuEventHandlerRec *	/* who invoked */
);

#define AuEventHandlerTypeMask		(1L << 0)
#define AuEventHandlerIDMask		(1L << 1)
#define AuEventHandlerAllMasks	       ((1L << 2) - 1)

typedef struct _AuEventHandlerRec
{
    struct _AuServer *aud;			/* server */
    AuMask          mask;			/* what to compare for match */
    int             type;			/* AuEventHandler*Mask */
    AuID            id;				/* id of event */
    AuEventHandlerCallback callback;		/* whom to call */
    AuPointer       data;			/* data registered with id */
    struct _AuEventHandlerRec *next,
                   *prev;
}               AuEventHandlerRec;


typedef void
(*AuSyncHandlerCallback) (
			  struct _AuServer *,		/* server */
			  struct _AuSyncHandlerRec *,	/* who called me */
			  AuPointer			/* private data */
			  );

typedef struct _AuSyncHandlerRec
{
    AuSyncHandlerCallback callback;		/* whom to call */
    AuPointer       data;			/* data registered with id */
    struct _AuSyncHandlerRec *next,
                   *prev;
}               AuSyncHandlerRec;

#define AuEventEnqueuedByAny		0
#define AuEventEnqueuedByUnknown	1
#define AuEventEnqueuedByReply		2

typedef void
(*AuEventEnqHandlerCallback)
(
    struct _AuServer *,			/* server */
    struct _AuEventEnqHandlerRec *,	/* who called me */
    union _AuEvent *,			/* event */
    AuPointer				/* private data */
);

typedef struct _AuEventEnqHandlerRec
{
    AuEventEnqHandlerCallback callback;		/* whom to call */
    int             who;			/* who enqueued the event */
    AuPointer       data;			/* data registered with id */
    struct _AuEventEnqHandlerRec *next,
                   *prev;
}               AuEventEnqHandlerRec;

/*
 * Extensions need a way to hang private data on some structures.
 */
typedef struct _AuExtData
{
    int             number;			/* number returned by
						 * XRegisterExtension */
    struct _AuExtData *next;			/* next item on list of data
						 * for structure */
    int             (*free_private) ();		/* called to free private
						 * storage */
    AuPointer       private_data;		/* data private to this
						 * extension. */
}               AuExtData;

typedef struct _AuExtCodes			/* public to extension,
						 * cannot be changed */
{
    int             extension;			/* extension number */
    int             major_opcode;		/* major op-code assigned by
						 * server */
    int             first_event;		/* first event number for the
						 * extension */
    int             first_error;		/* first error number for the
						 * extension */
}               AuExtCodes;


typedef struct _AuScratchFlow
{
    AuFlowID        flow;
    AuBool          inuse;
}               AuScratchFlow;


/*
 * AudioServer - this contains all of the information needed to send data to
 * and receive data from the audio server.  Applications should not deref
 * this structure; they should use the macros instead.
 */
typedef struct _AuServer
{
    AuPointer      *client_data;		/* client can stick stuff
						 * here */
    AuExtData      *ext_data;			/* hook for extension to hang
						 * data */
    int             fd;				/* Network socket. */
    int             lock;			/* is someone in critical
						 * section? */
    int             proto_major_version;	/* maj. version of server's
						 * protocol */
    int             proto_minor_version;	/* minor version of servers
						 * protocol */
    char           *vendor;			/* vendor of the server
						 * hardware */
    AuID            resource_base;		/* resource ID base */
    AuID            resource_mask;		/* resource ID mask bits */
    AuID            resource_id;		/* allocator current ID */
    int             resource_shift;		/* allocator shift to correct
						 * bits */
                    AuID(*resource_alloc) ();	/* allocator function */
    int             vnumber;			/* audiolib's protocol
						 * version number. */
    int             release;			/* release of the server */
    struct _AuSQEvent *head,
                   *tail;			/* Input event queue. */
    struct _AuSQEvent *qfree;
    int             qlen;			/* Length of input event
						 * queue */
    AuUint32   last_request_read;		/* seq number of last event
						 * read */
    AuUint32   request;			/* sequence number of last
						 * request. */
    char           *last_req;			/* beginning of last request,
						 * or dummy */
    char           *buffer;			/* Output buffer starting
						 * address. */
    char           *bufptr;			/* Output buffer index
						 * pointer. */
    char           *bufmax;			/* Output buffer maximum+1
						 * address. */
    unsigned        max_request_size;		/* maximum number 32 bit
						 * words in request */
    struct _AuSyncHandlerRec *synchandler;	/* Synchronization handler */
    char           *server_name;		/* "host:port" string used on
						 * this connect */
    char           *scratch_buffer;		/* place to hang scratch
						 * buffer */
    AuUint32   scratch_length;		/* length of scratch buffer */
    int             ext_number;			/* extension number on this
						 * server */
    struct _AuExten *ext_procs;			/* extensions initialized on
						 * this aud */
    /*
     * the following can be fixed size, as the protocol defines how much
     * address space is available. While this could be done using the
     * extension vector, there may be MANY events processed, so a search
     * through the extension list to find the right procedure for each event
     * might be expensive if many extensions are being used.
     */
                    AuBool(*event_vec[128]) ();	/* vector for wire to event */
                    AuStatus(*wire_vec[128]) ();/* vector for event to wire */
    struct _AuInternalAsync *async_handlers;	/* for internal async */
    AuUint32   flags;			/* internal connection flags */
                    AuBool(**error_vec) ();	/* vector for wire to error */
    int             conn_checker;		/* ugly thing used by
						 * _AuEventsQueued */
    AuEventHandlerRec *eventhandlerq;
    AuEventEnqHandlerRec *eventenqhandlerq;
    struct
    {
	AuErrorHandler  error_handler;
	AuIOErrorHandler ioerror_handler;
    }               funcs;
    struct
    {
	int             min_sample_rate;
	int             max_sample_rate;
	int             max_tracks;
	int             num_formats;
	int             num_element_types;
	int             num_wave_forms;
	int             num_actions;
	int             num_devices;
	int             num_buckets;
#ifdef NOTYET
	int             num_radios;
#endif						/* NOTYET */
	int            *formats;
	int            *element_types;
	int            *wave_forms;
	int            *actions;
	struct _AuDeviceAttributes *devices;
	struct _AuBucketAttributes *buckets;
#ifdef NOTYET
	AuRadioAttributes *radios;
#endif						/* NOTYET */
    }               connsetup;
    struct
    {						/* tmp flows to keep around */
	int             total,
	                num_inuse;
	AuScratchFlow   flows[AU_MAX_SCRATCH_FLOWS];
    }               scratch_flows;
}               AuServer;

/* USE THESE MACROS INSTEAD OF DEREFERENCING AUSERVER STRUCTURE! */
#define AuServerConnectionNumber(aud)		((aud)->fd)
#define AuServerQLength(aud) 			((aud)->qlen)
#define AuServerVendor(aud) 			((aud)->vendor)
#define AuServerProtocolMajorVersion(aud)	((aud)->proto_major_version)
#define AuServerProtocolMinorVersion(aud) 	((aud)->proto_minor_version)
#define AuServerVendorRelease(aud) 		((aud)->release)
#define AuServerString(aud) 			((aud)->server_name)
#define AuServerNextRequest(aud)		((aud)->request + 1)
#define AuServerLastKnownRequestProcessed(aud)	((aud)->last_request_read)
#define AuServerResourceBase(aud)		((aud)->resource_base)
#define AuServerResourceMask(aud)		((aud)->resource_mask)
#define AuClientOfID(aud,xxx) \
    ((xxx) & ~(AuServerResourceMask(aud) | 0xe0000000))

#define AuServerMinSampleRate(aud)	((aud)->connsetup.min_sample_rate)
#define AuServerMaxSampleRate(aud)	((aud)->connsetup.max_sample_rate)
#define AuServerMaxTracks(aud)		((aud)->connsetup.max_tracks)
#define AuServerNumFormats(aud)		((aud)->connsetup.num_formats)
#define AuServerNumElementTypes(aud)	((aud)->connsetup.num_element_types)
#define AuServerNumWaveForms(aud)	((aud)->connsetup.num_wave_forms)
#define AuServerNumActions(aud)		((aud)->connsetup.num_actions)
#define AuServerNumDevices(aud)		((aud)->connsetup.num_devices)
#define AuServerNumBuckets(aud)		((aud)->connsetup.num_buckets)
#ifdef NOTYET
#define AuServerNumRadios(aud)		((aud)->connsetup.num_radios)
#endif						/* NOTYET */
#define AuServerFormat(aud, num)		((aud)->connsetup.formats[(num)])
#define AuServerElementType(aud, num)	((aud)->connsetup.element_types[(num)])
#define AuServerWaveForm(aud, num)	((aud)->connsetup.wave_forms[(num)])
#define AuServerAction(aud, num)	((aud)->connsetup.actions[(num)])
#define AuServerDevice(aud, num)      (&((aud)->connsetup.devices[(num)]))
#define AuServerBucket(aud, num)      (&((aud)->connsetup.buckets[(num)]))
#ifdef NOTYET
#define AuServerRadio(aud, num)	      (&((aud)->connsetup.radios[(num)]))
#endif						/* NOTYET */

#define AuAllocID(aud) 			((*(aud)->resource_alloc)((aud)))

/*
 * Attributes used for Devices, Buckets, and Radios
 */
typedef struct _AuCommonPart
{
    AuMask          value_mask;			/* what is present */
    AuMask          changable_mask;		/* what can be changed */
    AuID            id;				/* used to reference in flows */
    unsigned int    kind;			/* what type of object is it */
    AuMask          use;			/* importable, exportable,
						 * etc. */
    int             format;			/* current value */
    int             num_tracks;			/* 1 for mono, 2 for stereo,
						 * etc. */
    AuMask          access;			/* who can access */
    AuString        description;		/* description of device */
}               AuCommonPart;

#define AuCommonValueMask(c)		((c)->value_mask)
#define AuCommonChangableMask(c) 	((c)->changable_mask)
#define AuCommonIdentifier(c)		((c)->id)
#define AuCommonKind(c)			((c)->kind)
#define AuCommonUse(c)			((c)->use)
#define AuCommonFormat(c)		((c)->format)
#define AuCommonNumTracks(c)		((c)->num_tracks)
#define AuCommonAccess(c)		((c)->access)
#define AuCommonDescription(c) 		(&((c)->description))

/*
 * Device attributes - these are physical devices attached to the server.
 */
typedef struct _AuDevicePart
{
    unsigned int    min_sample_rate;
    unsigned int    max_sample_rate;
    AuMask          location;			/* mask of bits */
    AuFixedPoint    gain;			/* built into the hardware */
    AuInt32            line_mode;			/* high vs. low amp circuit */
    int             num_children;		/* number of subdevices, if
						 * any */
    AuDeviceID     *children;			/* subdevices */
}               AuDevicePart;
typedef struct _AuDeviceAttributes
{
    AuCommonPart    common;
    AuDevicePart    device;
}               AuDeviceAttributes;

#define AuDeviceValueMask(d)		AuCommonValueMask(&(d)->common)
#define AuDeviceChangableMask(d)	AuCommonChangableMask(&(d)->common)
#define AuDeviceIdentifier(d)		AuCommonIdentifier(&(d)->common)
#define AuDeviceKind(d)			AuCommonKind(&(d)->common)
#define AuDeviceUse(d)			AuCommonUse(&(d)->common)
#define AuDeviceFormat(d)		AuCommonFormat(&(d)->common)
#define AuDeviceNumTracks(d)		AuCommonNumTracks(&(d)->common)
#define AuDeviceAccess(d)		AuCommonAccess(&(d)->common)
#define AuDeviceDescription(d)		AuCommonDescription(&(d)->common)
#define AuDeviceMinSampleRate(d)	((d)->device.min_sample_rate)
#define AuDeviceMaxSampleRate(d)	((d)->device.max_sample_rate)
#define AuDeviceLocation(d)		((d)->device.location)
#define AuDeviceGain(d)			((d)->device.gain)
#define AuDeviceLineMode(d)		((d)->device.line_mode)
#define AuDeviceInputMode(d)		AuDeviceLineMode(d)
#define AuDeviceOutputMode(d)		AuDeviceLineMode(d)
#define AuDeviceNumChildren(d)		((d)->device.num_children)
#define AuDeviceChildren(d)		((d)->device.children)

/*
 * Bucket attributes - these are server storage for sound data.
 */
typedef struct _AuBucketPart
{
    unsigned int    sample_rate;		/* current value */
    AuUint32   num_samples;		/* max number in this device */
}               AuBucketPart;
typedef struct _AuBucketAttributes
{
    AuCommonPart    common;
    AuBucketPart    bucket;
}               AuBucketAttributes;

#define AuBucketValueMask(b)		AuCommonValueMask(&(b)->common)
#define AuBucketChangableMask(b)	AuCommonChangableMask(&(b)->common)
#define AuBucketIdentifier(b)		AuCommonIdentifier(&(b)->common)
#define AuBucketKind(b)			AuCommonKind(&(b)->common)
#define AuBucketUse(b)			AuCommonUse(&(b)->common)
#define AuBucketFormat(b)		AuCommonFormat(&(b)->common)
#define AuBucketNumTracks(b)		AuCommonNumTracks(&(b)->common)
#define AuBucketAccess(b)		AuCommonAccess(&(b)->common)
#define AuBucketDescription(b)		AuCommonDescription(&(b)->common)
#define AuBucketSampleRate(b)		((b)->bucket.sample_rate)
#define AuBucketNumSamples(b)		((b)->bucket.num_samples)

#ifdef NOTYET
/*
 * Radio attributes - these are special devices for LAN broadcast audio data
 */
typedef struct _AuRadioPart
{
    int             station;			/* which one you are
						 * listening to */
}               AuRadioPart;
typedef struct _AuRadioAttributes
{
    AuCommonPart    common;
    AuRadioPart     radio;
}               AuRadioAttributes;

#define AuRadioValueMask(r)		AuCommonValueMask(&(r)->common)
#define AuRadioChangableMask(r)		AuCommonChangableMask(&(r)->common)
#define AuRadioIdentifier(r)		AuCommonIdentifier(&(r)->common)
#define AuRadioKind(r)			AuCommonKind(&(r)->common)
#define AuRadioUse(r)			AuCommonUse(&(r)->common)
#define AuRadioFormat(r)		AuCommonFormat(&(r)->common)
#define AuRadioNumTracks(r)		AuCommonNumTracks(&(r)->common)
#define AuRadioAccess(r)		AuCommonAccess(&(r)->common)
#define AuRadioDescription(r)		AuCommonDescription(&(r)->common)
#define AuRadioStation(r)		((r)->radio.station)
#endif						/* NOTYET */




/*
 * Flows - These are the instructions (called Elements) for how to move audio
 * data from one place to another.
 */
typedef struct _AuFlowAttributes
{
    unsigned char   state;			/* Stop, Start, Pause */
    unsigned char   pad1;
    unsigned short  pad2;
    AuBool          clocked;			/* instantantious or not */
}               AuFlowAttributes;


typedef struct _AuElementAction
{
    AuFlowID        flow;			/* target flow to affect */
    unsigned char   element_num;		/* target element to affect */
    unsigned char   trigger_state;		/* state to trigger action */
    unsigned char   trigger_prev_state;		/* previous state to trigger */
    unsigned char   trigger_reason;		/* reason to trigger action */
    unsigned char   action;			/* what to do */
    unsigned char   new_state;			/* new state for target */
    unsigned short  pad;
}               AuElementAction;

#define AuMakeChangeStateAction(A, _trigger_state, _trigger_prev_state, _trigger_reason, _flow, _element_num, _new_state)\
AU_MACRO_PREFIX								       \
    (A)->trigger_state = (_trigger_state);				       \
    (A)->trigger_prev_state = (_trigger_prev_state);			       \
    (A)->trigger_reason = (_trigger_reason);				       \
    (A)->action = AuElementActionChangeState;				       \
    (A)->flow = (_flow);						       \
    (A)->element_num = (_element_num);					       \
    (A)->new_state = (_new_state);					       \
AU_MACRO_SUFFIX

#define AuMakeSendNotifyAction(A, _trigger_state, _trigger_prev_state, _trigger_reason)\
AU_MACRO_PREFIX								       \
    (A)->trigger_state = (_trigger_state);				       \
    (A)->trigger_prev_state = (_trigger_prev_state);			       \
    (A)->trigger_reason = (_trigger_reason);				       \
    (A)->action = AuElementActionSendNotify;				       \
AU_MACRO_SUFFIX

#define AuMakeNoopAction(A, _trigger_state, _trigger_prev_state, _trigger_reason)\
AU_MACRO_PREFIX								       \
    (A)->trigger_state = (_trigger_state);				       \
    (A)->trigger_prev_state = (_trigger_prev_state);			       \
    (A)->trigger_reason = (_trigger_reason);				       \
    (A)->action = AuElementActionNoop;					       \
AU_MACRO_SUFFIX


typedef struct _AuElementActionList
{
    int             num_actions;
    AuElementAction *actions;
}               AuElementActionList;

/* IMPORTS */

typedef struct _AuElementImportClient
{
    unsigned short  type;			/* AuElementTypeImportClient */
    unsigned short  sample_rate;
    unsigned char   format;
    unsigned char   num_tracks;
    unsigned char   discard;
    unsigned char   pad;
    AuUint32   max_samples;
    AuUint32   low_water_mark;
    AuElementActionList actions;
}               AuElementImportClient;

#define AuMakeElementImportClient(E, _sample_rate, _format, _num_tracks, _discard, _max_samples, _low_water_mark, _num_actions, _actions)\
AU_MACRO_PREFIX								       \
    (E)->type = AuElementTypeImportClient;				       \
    (E)->importclient.sample_rate = (_sample_rate);			       \
    (E)->importclient.format = (_format);				       \
    (E)->importclient.num_tracks = (_num_tracks);			       \
    (E)->importclient.discard = (_discard);				       \
    (E)->importclient.max_samples = (_max_samples);			       \
    (E)->importclient.low_water_mark = (_low_water_mark);		       \
    (E)->importclient.actions.num_actions = (_num_actions);		       \
    (E)->importclient.actions.actions = (_actions);			       \
AU_MACRO_SUFFIX


typedef struct _AuElementImportDevice
{
    unsigned short  type;			/* AuElementTypeImportDevice */
    unsigned short  sample_rate;
    AuDeviceID      device;
    AuUint32   num_samples;
    AuElementActionList actions;
}               AuElementImportDevice;

#define AuMakeElementImportDevice(E, _sample_rate, _device, _num_samples, _num_actions, _actions)\
AU_MACRO_PREFIX								       \
    (E)->type = AuElementTypeImportDevice;				       \
    (E)->importdevice.sample_rate = (_sample_rate);			       \
    (E)->importdevice.device = (_device);				       \
    (E)->importdevice.num_samples = (_num_samples);			       \
    (E)->importdevice.actions.num_actions = (_num_actions);		       \
    (E)->importdevice.actions.actions = (_actions);			       \
AU_MACRO_SUFFIX

typedef struct _AuElementImportBucket
{
    unsigned short  type;			/* AuElementTypeImportBucket */
    unsigned short  sample_rate;
    AuBucketID      bucket;
    AuUint32   num_samples;
    AuInt32         parms[AuParmsImportBucket];	/* offset */
    AuElementActionList actions;
}               AuElementImportBucket;

#define AuMakeElementImportBucket(E, _sample_rate, _bucket, _num_samples, _offset, _num_actions, _actions)\
AU_MACRO_PREFIX								       \
    (E)->type = AuElementTypeImportBucket;				       \
    (E)->importbucket.sample_rate = (_sample_rate);			       \
    (E)->importbucket.bucket = (_bucket);				       \
    (E)->importbucket.num_samples = (_num_samples);			       \
    (E)->importbucket.parms[AuParmsImportBucketOffset] = (_offset);	       \
    (E)->importbucket.actions.num_actions = (_num_actions);		       \
    (E)->importbucket.actions.actions = (_actions);			       \
AU_MACRO_SUFFIX


typedef struct _AuElementImportWaveForm
{
    unsigned short  type;		       /* AuElementTypeImportWaveForm */
    unsigned short  sample_rate;
    int             wave_form;
    AuInt32         parms[AuParmsImportWaveForm];	/* freq, num samples */
    AuElementActionList actions;
}               AuElementImportWaveForm;

#define AuMakeElementImportWaveForm(E, _sample_rate, _wave_form, _num_samples, _freq, _num_actions, _actions)\
AU_MACRO_PREFIX								      \
    (E)->type = AuElementTypeImportWaveForm;				      \
    (E)->importwaveform.sample_rate = (_sample_rate);			      \
    (E)->importwaveform.wave_form = (_wave_form);			      \
    (E)->importwaveform.parms[AuParmsImportWaveFormFrequency] = (_freq);      \
    (E)->importwaveform.parms[AuParmsImportWaveFormNumSamples] =	      \
        (_num_samples);							      \
    (E)->importwaveform.actions.num_actions = (_num_actions);		      \
    (E)->importwaveform.actions.actions = (_actions);			      \
AU_MACRO_SUFFIX


#ifdef NOTYET
typedef struct _AuElementImportRadio
{
    unsigned short  type;			/* AuElementTypeImportRadio */
    unsigned short  sample_rate;
    AuRadioID       radio;
    AuUint32   num_samples;
    AuElementActionList actions;
}               AuElementImportRadio;

#define AuMakeElementImportRadio(E,asample_rate,aradio,anum_samples,aactions)  \
{									       \
    (E)->type = AuElementTypeImportDevice;				       \
    (E)->sample_rate = (asample_rate);					       \
    (E)->radio = (aradio);						       \
    (E)->num_samples = (anum_samples);					       \
    (E)->actions = (aactions);						       \
}
#endif /* NOTYET */


/* OPS */

typedef struct _AuInputTrack
{
    unsigned char   element_num;
    unsigned char   track;
}               AuInputTrack;

#define AuMakeInputTrack(T, _element_num, _track)			       \
AU_MACRO_PREFIX								       \
    (T)->element_num = (_element_num);					       \
    (T)->track = (_track);						       \
AU_MACRO_SUFFIX								       \

typedef struct _AuElementBundle
{
    unsigned short  type;			/* AuElementTypeBundle */
    unsigned short  num_inputs;
    AuInputTrack   *inputs;
}               AuElementBundle;

#define AuMakeElementBundle(E, _num_inputs, _inputs)			       \
AU_MACRO_PREFIX								       \
    (E)->type = AuElementTypeBundle;					       \
    (E)->bundle.num_inputs = (_num_inputs);				       \
    (E)->bundle.inputs = (_inputs);					       \
AU_MACRO_SUFFIX


typedef struct _AuElementMultiplyConstant
{
    unsigned short  type;			/* AuElementTypeMultiplyConsta
						 * nt */
    unsigned short  input;
    AuInt32            parms[AuParmsMultiplyConstant];	/* constant */
}               AuElementMultiplyConstant;

#define AuMakeElementMultiplyConstant(E, _input, _constant)		       \
AU_MACRO_PREFIX								       \
    (E)->type = AuElementTypeMultiplyConstant;				       \
    (E)->multiplyconstant.input = (_input);				       \
    (E)->multiplyconstant.parms[AuParmsMultiplyConstantConstant] = (_constant);\
AU_MACRO_SUFFIX


typedef struct _AuElementAddConstant
{
    unsigned short  type;			/* AuElementTypeAddConstant */
    unsigned short  input;
    AuInt32            parms[AuParmsAddConstant];
}               AuElementAddConstant;

#define AuMakeElementAddConstant(E, _input, _constant)			       \
AU_MACRO_PREFIX								       \
    (E)->type = AuElementTypeAddConstant;				       \
    (E)->addconstant.input = (_input);					       \
    (E)->addconstant.parms[AuParmsAddConstantConstant] = (_constant);	       \
AU_MACRO_SUFFIX


typedef struct _AuElementSum
{
    unsigned short  type;			/* AuElementTypeSum */
    unsigned short  num_inputs;
    unsigned short  *inputs;
}               AuElementSum;

#define AuMakeElementSum(E, _num_inputs, _inputs)			       \
AU_MACRO_PREFIX								       \
    (E)->type = AuElementTypeSum;					       \
    (E)->sum.num_inputs = (_num_inputs);				       \
    (E)->sum.inputs = (_inputs);					       \
AU_MACRO_SUFFIX



/* EXPORTS */

typedef struct _AuElementExportClient
{
    unsigned short  type;			/* AuElementTypeExportClient */
    unsigned short  sample_rate;
    unsigned short  input;
    unsigned char   format;
    unsigned char   num_tracks;
    unsigned char   discard;
    unsigned char   pad;
    AuUint32   max_samples;
    AuUint32   high_water_mark;
    AuElementActionList actions;
}               AuElementExportClient;

#define AuMakeElementExportClient(E, _input, _sample_rate, _format, _num_tracks, _discard, _max_samples, _high_water_mark, _num_actions, _actions)\
AU_MACRO_PREFIX								       \
    (E)->type = AuElementTypeExportClient;				       \
    (E)->exportclient.input = (_input);					       \
    (E)->exportclient.sample_rate = (_sample_rate);			       \
    (E)->exportclient.format = (_format);				       \
    (E)->exportclient.num_tracks = (_num_tracks);			       \
    (E)->exportclient.discard = (_discard);				       \
    (E)->exportclient.max_samples = (_max_samples);			       \
    (E)->exportclient.high_water_mark = (_high_water_mark);		       \
    (E)->exportclient.actions.num_actions = (_num_actions);		       \
    (E)->exportclient.actions.actions = (_actions);			       \
AU_MACRO_SUFFIX

typedef struct _AuElementExportDevice
{
    unsigned short  type;			/* AuElementTypeExportDevice */
    unsigned short  sample_rate;
    unsigned short  input;
    AuDeviceID      device;
    AuUint32   num_samples;
    AuElementActionList actions;
}               AuElementExportDevice;

#define AuMakeElementExportDevice(E, _input, _device, _sample_rate, _num_samples, _num_actions, _actions)\
AU_MACRO_PREFIX								       \
    (E)->type = AuElementTypeExportDevice;				       \
    (E)->exportdevice.sample_rate = (_sample_rate);			       \
    (E)->exportdevice.input = (_input);					       \
    (E)->exportdevice.device = (_device);				       \
    (E)->exportdevice.num_samples = (_num_samples);			       \
    (E)->exportdevice.actions.num_actions = (_num_actions);		       \
    (E)->exportdevice.actions.actions = (_actions);			       \
AU_MACRO_SUFFIX

typedef struct _AuElementExportBucket
{
    unsigned short  type;			/* AuElementTypeExportBucket */
    unsigned short  input;
    AuBucketID      bucket;
    AuUint32   num_samples;
    AuInt32            parms[AuParmsExportBucket];	/* offset */
    AuElementActionList actions;
}               AuElementExportBucket;

#define AuMakeElementExportBucket(E, _input, _bucket, _num_samples, _offset, _num_actions, _actions)\
AU_MACRO_PREFIX								       \
    (E)->type = AuElementTypeExportBucket;				       \
    (E)->exportbucket.input = (_input);					       \
    (E)->exportbucket.bucket = (_bucket);				       \
    (E)->exportbucket.num_samples = (_num_samples);			       \
    (E)->exportbucket.parms[AuParmsExportBucketOffset] = (_offset);	       \
    (E)->exportbucket.actions.num_actions = (_num_actions);		       \
    (E)->exportbucket.actions.actions = (_actions);			       \
AU_MACRO_SUFFIX

typedef struct _AuElementExportRadio
{
    unsigned short  type;			/* AuElementTypeExportRadio */
    unsigned short  sample_rate;
    AuRadioID       radio;
    AuUint32   num_samples;
    AuElementActionList actions;
}               AuElementExportRadio;

#define AuMakeElementExportRadio(E,asample_rate,aradio,anum_samples,aactions)  \
{									       \
    (E)->type = AuElementTypeExportDevice;				       \
    (E)->sample_rate = (asample_rate);					       \
    (E)->radio = (aradio);						       \
    (E)->num_samples = (anum_samples);					       \
    (E)->actions = (aactions);						       \
}

typedef struct _AuElementExportMonitor
{
    unsigned short  type;			/* AuElementTypeExportMonitor */
    unsigned short  event_rate;
    unsigned short  input;
    unsigned short  pad;
    unsigned char   format;
    unsigned char   num_tracks;
    unsigned short  pad1;
}               AuElementExportMonitor;

#define AuMakeElementExportMonitor(E, _input, _event_rate, _format, _num_tracks)\
AU_MACRO_PREFIX								       \
    (E)->type = AuElementTypeExportMonitor;				       \
    (E)->exportmonitor.input = (_input);				       \
    (E)->exportmonitor.event_rate = (_event_rate);			       \
    (E)->exportmonitor.format = (_format);				       \
    (E)->exportmonitor.num_tracks = (_num_tracks);			       \
AU_MACRO_SUFFIX

/* UNION OF ELEMENTS */

typedef union _AuElement			/* generic element */
{
    unsigned short  type;
    AuElementImportClient importclient;
    AuElementImportDevice importdevice;
    AuElementImportBucket importbucket;
    AuElementImportWaveForm importwaveform;
#ifdef NOTYET
    AuElementImportRadio importradio;
#endif /* NOTYET */
    AuElementBundle bundle;
    AuElementMultiplyConstant multiplyconstant;
    AuElementAddConstant addconstant;
    AuElementSum    sum;
    AuElementExportClient exportclient;
    AuElementExportDevice exportdevice;
    AuElementExportBucket exportbucket;
#ifdef NOTYET
    AuElementExportRadio exportradio;
#endif /* NOTYET */
    AuElementExportMonitor exportmonitor;
}               AuElement;

typedef struct _AuElementParameters
{
    AuFlowID        flow;
    unsigned char   element_num;
    unsigned char   num_parameters;
    unsigned short  pad;
    AuInt32            parameters[AU_MAX_PARMS];
}               AuElementParameters;

typedef struct _AuElementState
{
    AuFlowID        flow;
    unsigned char   element_num;
    unsigned char   state;
    unsigned short  pad;
}               AuElementState;

#define AuMakeElementState(S, _flow, _element_num, _state)		       \
{									       \
    (S)->flow = (_flow);						       \
    (S)->element_num = (_element_num);					       \
    (S)->state = (_state);						       \
}

/*****************************************************************************
 *				    EVENTS				     *
 *****************************************************************************/

typedef struct _AuAnyEvent			/* common to all events */
{
    int             type;
    AuUint32   serial;
    AuBool          send_event;
    AuServer       *server;
    AuTime          time;
    AuID            id;				/* primary id */
}               AuAnyEvent;


typedef struct _AuElementNotifyEvent
{
    int             type;			/* AuEventTypeElementNotify */
    AuUint32   serial;
    AuBool          send_event;
    AuServer       *server;
    AuTime          time;
    AuFlowID        flow;
    unsigned char   element_num;
    unsigned char   kind;			/* AuElementNotify* */
    unsigned char   prev_state;			/* of element */
    unsigned char   cur_state;			/* of element */
    unsigned char   reason;			/* for event */
    AuUint32   num_bytes;			/* unread bytes, etc. */
}               AuElementNotifyEvent;


typedef struct _AuMonitorNotifyEvent
{
    int             type;			/* AuEventTypeElementNotify */
    AuUint32   serial;
    AuBool          send_event;
    AuServer       *server;
    AuTime          time;
    AuFlowID        flow;
    unsigned char   element_num;
    unsigned char   format;
    unsigned char   num_tracks;
    unsigned short  count;
    unsigned short  num_fields;
    AuUint32   data;
    AuUint32   data1;
    AuUint32   data2;
}               AuMonitorNotifyEvent;

typedef struct _AuGrabNotifyEvent
{
    int             type;			/* AuEventTypeElementNotify */
    AuUint32   serial;
    AuBool          send_event;
    AuServer       *server;
    AuTime          time;
    AuID            id;
    unsigned char   kind;			/* AuGrabNotifyKind* */
    unsigned char   pad1;
    unsigned short  pad2;
    AuID            client;			/* requestor, prev owner */
}               AuGrabNotifyEvent;



typedef struct _AuErrorEvent
{
    int             type;
    AuUint32   serial;			/* of failed request */
    AuBool          send_event;
    AuServer       *server;
    AuTime          time;
    AuID            resourceid;
    unsigned char   error_code;			/* of failed request */
    unsigned char   request_code;		/* Major op-code */
    unsigned char   minor_code;			/* Minor op-code */
    union
    {
	AuUint32   l[4];
    }               data;			/* per-error type data */
}               AuErrorEvent;


typedef union _AuEvent
{
    int             type;
    AuAnyEvent      auany;
    AuElementNotifyEvent auelementnotify;
    AuMonitorNotifyEvent aumonitornotify;
    AuGrabNotifyEvent augrabnotify;
    AuErrorEvent    auerror;
}               AuEvent;




/*****************************************************************************
 *		      APPLICATION PROGRAMMING INTERFACES		     *
 *****************************************************************************/


_AUFUNCPROTOBEGIN


/*
 * AuServerName - this routine returns the that the library will use to
 * locate the audio server.
 */
extern const char * AUCDECL
AuServerName(
	     const char *			/* servername */
);

/*
 * AuOpenServer - this routine is used to open a connection to an audio
 * server.
 */
extern AuServer * AUCDECL
AuOpenServer(
	     const char *,			/* servername */
	     int,				/* num_authproto */
	     const char *,			/* authproto */
	     int,				/* num_authdata */
	     const char *,			/* authdata */
	     char **				/* server_message */
);


/*
 * AuCloseServer - this routine is used to close a connection to an audio
 * server when it is no AuInt32er needed.
 */
extern void AUCDECL
AuCloseServer(
	      AuServer *			/* server */
);


/*
 * AuSetErrorHandler - this routine is used to set the procedure that should
 * be called when this connection sees an error that is not being intercepted
 * by the library.
 */
extern          AuErrorHandler AUCDECL
AuSetErrorHandler(
		  AuServer *,			/* server */
		  AuErrorHandler		/* handler */
);


/*
 * AuSetIOErrorHandler - this routine is used to set the procedure that
 * should be called when the connection to the server has unexpectedly been
 * broken.
 */
extern          AuIOErrorHandler AUCDECL
AuSetIOErrorHandler(
		    AuServer *,			/* server */
		    AuIOErrorHandler		/* handler */
);


/*
 * AuFlush - this routine flushes any queued packets down to the server.
 */
extern void AUCDECL
AuFlush(
	AuServer *				/* server */
);


/*
 * AuSync - this routine forces a round trip to the server
 */
extern void AUCDECL
AuSync(
       AuServer *,				/* server */
       AuBool					/* discard_queued_events */
);


/*
 * AuSynchronize - this routine instructs the library to operate
 * synchronously, which may be easier for some applications to deal with.
 */
extern          AuBool AUCDECL
AuSynchronize(
	      AuServer *,			/* server */
	      AuBool				/* enablesync */
);


/*
 * AuGetErrorText - this routine is used to translate error codes into
 * English strings for printing.
 */
extern void AUCDECL
AuGetErrorText(
	       AuServer *,			/* server */
	       int,				/* code */
	       char *,				/* buffer_return */
	       int				/* length */
);


/*
 * AuGetErrorDatabaseText - this routine is used to lookup strings for error
 * messages.
 */
extern void AUCDECL
AuGetErrorDatabaseText(
		       AuServer *,		/* server */
		       const char *,		/* name */
		       const char *,		/* message */
		       const char *,		/* default_string */
		       char *,			/* buffer_return */
		       int			/* length */
);



/*
 * AuSetCloseDownMode - this routine instructs the server to save any objects
 * created by this client even if it shuts down.
 */
extern void AUCDECL
AuSetCloseDownMode(
		   AuServer *,			/* server */
		   int,				/* mode */
		   AuStatus *			/* RETURN_status */
);


/*
 * AuGetCloseDownMode - this routine returns the current close-down mode for
 * this client.
 */
extern int AUCDECL
AuGetCloseDownMode(
		   AuServer *,			/* server */
		   AuStatus *			/* RETURN_status */
);

/*
 * AuGetServerTime - this routine returns the current server time
 */
extern AuTime AUCDECL
AuGetServerTime(
		   AuServer *,			/* server */
		   AuStatus *			/* RETURN_status */
);

/*
 * AuKillClient - this routine forces the client that created the specified
 * resource to close down, regardless of its close down mode.
 */
extern void AUCDECL
AuKillClient(
	     AuServer *,			/* server */
	     AuID,				/* resource */
	     AuStatus *				/* RETURN_status */
);



/*
 * AuSetDeviceAttributes - this routine is used to change device attributes
 * for the fields in changable_mask returned by AuGetDeviceAttributes or the
 * setup information.
 */
extern void AUCDECL
AuSetDeviceAttributes(
		      AuServer *,		/* server */
		      AuDeviceID,		/* resource */
		      AuMask,			/* value_mask */
		      AuDeviceAttributes *,	/* attr */
		      AuStatus *		/* RETURN_status */
);


/*
 * AuGetDeviceAttributes - this routine is used to get device attributes
 * (which are also provided by the server at connection setup).
 */
extern AuDeviceAttributes * AUCDECL
AuGetDeviceAttributes(
		      AuServer *,		/* server */
		      AuDeviceID,		/* resource */
		      AuStatus *		/* RETURN_status */
);


/*
 * AuListDevices - this routine is used to query the devices
 */
extern AuDeviceAttributes * AUCDECL
AuListDevices(
	      AuServer *,			/* server */
	      AuMask,				/* value_mask */
	      AuDeviceAttributes *,		/* attr */
	      int *,				/* RETURN_ndevices */
	      AuStatus *			/* RETURN_status */
);


/*
 * AuFreeDeviceAttributes - this routine is used to free storage returned by
 * calls to AuGetDeviceAttributes.
 */
extern void AUCDECL
AuFreeDeviceAttributes(
		       AuServer *,		/* server */
		       int,			/* num_attr */
		       AuDeviceAttributes *	/* attr */
);


/*
 * AuGetBucketAttributes - this routine is used to get bucket attributes
 * (which are also provided by the server at connection setup).
 */
extern AuBucketAttributes * AUCDECL
AuGetBucketAttributes(
		      AuServer *,		/* server */
		      AuBucketID,		/* resource */
		      AuStatus *		/* RETURN_status */
);


/*
 * AuListBuckets - this routine is used to query the buffers for a given
 * client, all retained clients, or all known buffers.
 */
extern AuBucketAttributes * AUCDECL
AuListBuckets(
	      AuServer *,			/* server */
	      AuMask,				/* value_mask */
	      AuBucketAttributes *,		/* attr */
	      int *,				/* RETURN_nbuckets */
	      AuStatus *			/* RETURN_status */
);


/*
 * AuFreeBucketAttributes - this routine is used to free storage returned by
 * calls to AuGetBucketAttributes.
 */
extern void AUCDECL
AuFreeBucketAttributes(
		       AuServer *,		/* server */
		       int,			/* num_attr */
		       AuBucketAttributes *	/* attr */
);

/*
 * AuCreateBucket - this routine is used to create new buckets (buffers,
 * radios, wave form generators)
 */
extern          AuBucketID AUCDECL
AuCreateBucket(
	       AuServer *,			/* server */
	       AuUint32,			/* format */
	       AuUint32,			/* num tracks */
	       AuUint32,			/* access */
	       AuUint32,			/* sample_rate */
	       AuUint32,			/* num_samples */
	       AuString *,			/* description */
	       AuStatus *			/* RETURN_status */
);


/*
 * AuDestroyBucket - this routine is used to destroy a bucket once it is no
 * AuInt32er being used.
 */
extern void AUCDECL
AuDestroyBucket(
		AuServer *,			/* server */
		AuBucketID,			/* bucket */
		AuStatus *			/* RETURN_status */
);


/*
 * AuCreateFlow - this routine is used to create a Flow object which
 * describes how audio data gets from one or more inputs to one or more
 * outputs.
 */
extern          AuFlowID AUCDECL
AuCreateFlow(
	     AuServer *,			/* server */
	     AuStatus *				/* RETURN_status */
);


/*
 * AuDestroyFlow - this routine is used to destroy a Flow object once it is
 * no AuInt32er needed.
 */
extern void AUCDECL
AuDestroyFlow(
	      AuServer *,			/* server */
	      AuFlowID,				/* flow */
	      AuStatus *			/* RETURN_status */
);


/*
 * AuGetFlowAttributes - this routine is used to find out what the state of
 * the flow is at any given time.
 */
extern          AuBool AUCDECL
AuGetFlowAttributes(
		    AuServer *,			/* server */
		    int,			/* num_attrs */
		    AuFlowAttributes *,		/* attrs */
		    AuStatus *			/* RETURN_status */
);


/*
 * AuSetElements - this routine is used to set the flow topology; it is
 * equivalent to destroying the flow and recreating it using the same id. The
 * API will keep a list of scratch flows to use in sending audio data over
 * the wire.
 */
extern void AUCDECL
AuSetElements(
	      AuServer *,			/* server */
	      AuFlowID,				/* flow id */
	      AuBool,				/* clocked */
	      int,				/* num_elements */
	      AuElement *,			/* elements */
	      AuStatus *			/* RETURN_status */
);


/*
 * AuGetElements - this routine is used to return the element topology that
 * was set in the AuCreateElements.
 */
extern AuElement * AUCDECL
AuGetElements(
	      AuServer *,			/* server */
	      AuFlowID,				/* flow id */
	      AuBool *,				/* RETURN_clocked */
	      int *,				/* RETURN_num_elements */
	      AuStatus *			/* RETURN_status */
);


/*
 * AuFreeElements - this routine is used to free the results returned from a
 * call to AuGetElements.
 */
extern void AUCDECL
AuFreeElements(
	       AuServer *,			/* server */
	       int,				/* num_elements */
	       AuElement *			/* listofelements */
);


/*
 * AuGetElementStates - this routine is used to get the state of various
 * elements within a flow.
 */
extern AuElementState * AUCDECL
AuGetElementStates(
		   AuServer *,			/* server */
		   int *,			/* INOUT_num_states */
		   AuElementState *,		/* states */
		   AuStatus *			/* RETURN_status */
);


/*
 * AuFreeElementStates - this routine is used to free the results returned
 * from a call to AuGetElementStates.
 */
extern void AUCDECL
AuFreeElementStates(
		    AuServer *,			/* server */
		    int,			/* num_elements */
		    AuElementState *		/* list of element states */
);


/*
 * AuSetElementStates - this routine is used to set the state of various
 * elements within a flow.
 */
extern void AUCDECL
AuSetElementStates(
		   AuServer *,			/* server */
		   int,				/* num_states */
		   AuElementState *,		/* states */
		   AuStatus *			/* RETURN_status */
);


/*
 * AuSetElementParameters - this routine is used to change parameters of
 * elements within a flow.  Changes in element types is not permitted.
 */
extern void AUCDECL
AuSetElementParameters(
		       AuServer *,		/* server */
		       int,			/* num_changes */
		       AuElementParameters *,	/* changes */
		       AuStatus *		/* RETURN_status */
);



/*
 * AuWriteElement - this routine is used to send audio data to an
 * ImportClient element in a flow.
 */
extern void AUCDECL
AuWriteElement(
	       AuServer *,			/* server */
	       AuFlowID,			/* flow */
	       int,				/* element */
	       AuUint32,			/* num_bytes */
	       AuPointer,			/* data */
	       AuBool,				/* end of data flag */
	       AuStatus *			/* RETURN_status */
);


/*
 * AuReadElement - this routine is used to get audio data from an
 * ExportClient element in a flow.
 */
extern AuUint32 AUCDECL
AuReadElement(
	      AuServer *,			/* server */
	      AuFlowID,				/* flow */
	      int,				/* element */
	      AuUint32,			/* num_bytes */
	      AuPointer,			/* data */
	      int *				/* RETURN_status */
);

#define AuEventsQueued _AuEventsQueued

/*
 * AuEventsQueued - this routine is used to see if there are any events
 * waiting to be read.
 */
extern int AUCDECL
AuEventsQueued(
	       AuServer *,			/* server */
	       int				/* AuEventsQueued_mode */
);


/*
 * AuScanEvents - this routine is used to walk the event queue looking for
 * events that match a client-supplied predicate.  If the predicate returns
 * AuTrue for an event, that event is returned to the caller.
 */
extern          AuBool AUCDECL
AuScanEvents(
	     AuServer *,			/* server */
	     int,				/* AuEventsQueued_mode */
	     AuBool,				/* dequeue_match */
	     AuBool(*) (			/* clientpredicate */
			AuServer *,		/* server */
			AuEvent *,		/* eventtocheck */
			AuPointer		/* clientdata */
			),
	     AuPointer,				/* clientdata */
	     AuEvent *				/* RETURN_event */
);


/*
 * AuScanForTypedEvent - this is a convenience routine that calls
 * AuScanEvents with a predicate that looks for the specified event type.
 */
extern          AuBool AUCDECL
AuScanForTypedEvent(
		    AuServer *,			/* server */
		    int,			/* AuEventsQueued_mode */
		    AuBool,			/* dequeue */
		    int,			/* eventtype */
		    AuEvent *			/* RETURN_event */
);


/*
 * AuNextEvent - this routine is used to read a queued event.  If there is no
 * event available, it will block until one arrives.
 */
extern void AUCDECL
AuNextEvent(
	    AuServer *,				/* server */
	    AuBool,				/* dequeue */
	    AuEvent *				/* RETURN_event */
);




/*
 * AuRequeueEvent - this routine puts an event back on the front of the event
 * queue.  The skip argument specifies the number of events in the queue to
 * skip (0 means the head of the queue, AuServerQLength() means the end of
 * the queue).
 */
extern          AuBool AUCDECL
AuRequeueEvent(
	       AuServer *,			/* server */
	       AuEvent *,			/* event */
	       int				/* skip */
);


/*
 * AuIDOfEvent - this routine returns the Flow, Bucket, or Device id from an
 * event so that it can be used to dispatch the event to the proper handler.
 */
extern          AuID AUCDECL
AuIDOfEvent(
	    AuEvent *				/* RETURN_event */
);


extern void  AUCDECL
AuFree (
		    AuPointer
);

/*****************************************************************************
 *				    MACROS				     *
 *****************************************************************************/

/**
 * The following macros are provided to make initialization of various
 * structures easier:
 *
 *     AuMakeElementImportClient()
 *     AuMakeElementImportDevice()
 *     AuMakeElementImportBucket()
 *     AuMakeElementImportWaveForm()
 *     AuMakeElementImportRadio()
 *     AuMakeElementBundle()
 *     AuMakeElementMultipleConstant()
 *     AuMakeElementAddConstant()
 *     AuMakeElementSum()
 *     AuMakeElementExportClient()
 *     AuMakeElementExportDevice()
 *     AuMakeElementExportBucket()
 *     AuMakeElementExportRadio()
 *
 *     AuMakeInputTrack()
 *
 */

_AUFUNCPROTOEND

#include <audio/audioutil.h>			/* get rest of prototypes */

/*
 * Default error handlers.
 * These can be set before attempting to open the server to ensure
 * that errors in the open procedure are handled.
 */

#if defined(WIN32) && (!defined(_OPENSVR_C_) && !defined(__CYGWIN__))
#define AuDefaultErrorHandler	(*AuDefaultErrorHandler_p)
#define AuDefaultIOErrorHandler	(*AuDefaultIOErrorHandler_p)
#endif /* WIN32 && !_OPENSVR_C_ */

extern AuErrorHandler AuDefaultErrorHandler;
extern AuIOErrorHandler AuDefaultIOErrorHandler;

#endif						/* _NCD_AUDIOLIB_H_ */