1 /* 2 * Copyright 1993 Network Computing Devices, Inc. 3 * 4 * Permission to use, copy, modify, distribute, and sell this software and 5 * its documentation for any purpose is hereby granted without fee, provided 6 * that 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 * $NCDId: @(#)audio.h,v 1.37 1996/05/07 20:12:03 greg Exp $ 23 */ 24 25 /* 26 * <audio/audio.h> 27 * 28 * This file contains the constants and the primitive types (whose minimum 29 * size can be determined and whose maximum size doesn't matter) that are 30 * used by clients and the server. 31 */ 32 33 #ifndef _NCD_AUDIO_H_ 34 #define _NCD_AUDIO_H_ 35 36 #include <audio/Amd.h> 37 38 /**************************************************************************** 39 * GENERIC DATA TYPES * 40 ****************************************************************************/ 41 42 /* 43 * Data types used for resources. They are designed to line up with X 44 * so that implementations may share code. 45 */ 46 typedef INT32 AuInt32; /* 32 bit integer */ 47 typedef CARD32 AuUint32; /* 32 bit unsigned integer */ 48 typedef INT16 AuInt16; /* 16 bit integer */ 49 typedef CARD16 AuUint16; /* 16 bit unsigned integer */ 50 typedef INT8 AuInt8; /* 8 bit integer */ 51 typedef CARD8 AuUint8; /* 8 bit unsigned integer */ 52 53 typedef AuUint32 AuID; /* generic resource id */ 54 typedef AuID AuDeviceID; /* physical or virtual */ 55 typedef AuID AuBucketID; /* stored audio data */ 56 typedef AuID AuRadioID; /* broadcast */ 57 typedef AuID AuFlowID; /* how audio data moves */ 58 59 typedef AuUint32 AuTime; /* server time in millis */ 60 typedef AuUint32 AuMask; /* various value masks */ 61 typedef int AuBool; 62 typedef int AuStatus; 63 typedef AuInt32 AuFixedPoint; 64 65 #define AU_FIXED_POINT_SHIFT (16) 66 #define AU_FIXED_POINT_SCALE (1L << 16) 67 #define AU_FIXED_POINT_MASK (0xffff) 68 69 /* 70 * Fixed point numbers are simply signed integers that represent units of 71 * 65536. Mathematically: 72 * 73 * fixedpoint = floor(floating * 65536) 74 * 75 * It is important to note that although the value can be viewed as having 76 * a easily identifiable integral and fractional portions, negative values 77 * cannot simply be extracted and concatenated since the two pieces are 78 * actually related as: 79 * 80 * floating = (integerportion + fractionalportion) 81 * 82 * rather than 83 * 84 * floating != (integerportion | fractionalportion) 85 * 86 * To make manipulating the values easier, the following macros are provided: 87 * 88 * AuFixedPointFromSum creates a fixed point from an 89 * integer plus fraction. 90 * 91 * AuFixedPointFromFraction creates a fixed point from a 92 * numerator / denominator 93 * 94 * AuFixedPointRoundDown rounds down to prev integer value 95 * 96 * AuFixedPointRoundUp rounds up to next integer value 97 * 98 * AuFixedPointIntegralAddend integer portion of sum 99 * 100 * AuFixedPointFractionalAddend fractional portion of sum 101 */ 102 103 #define AuFixedPointFromSum(a,b) \ 104 ((AuInt32) (((AuInt32) (a) << AU_FIXED_POINT_SHIFT) + ((AuInt32) (b)))) 105 106 #define AuFixedPointFromFraction(nnn,ddd) \ 107 ((((AuInt32) (nnn)) * AU_FIXED_POINT_SCALE) / ((AuInt32) (ddd))) 108 109 #define AuFixedPointRoundDown(fp) \ 110 ((fp) >> AU_FIXED_POINT_SHIFT) 111 #define AuFixedPointRoundUp(fp) \ 112 (AuFixedPointRoundDown((fp) + (AU_FIXED_POINT_SCALE - 1L))) 113 114 #define AuFixedPointIntegralAddend(fp) \ 115 (AuFixedPointRoundDown (fp)) 116 #define AuFixedPointFractionalAddend(fp) \ 117 ((fp) & AU_FIXED_POINT_MASK) 118 119 120 #define AuNone (0) /* null resource */ 121 #define AuFalse (0) 122 #define AuTrue (1) 123 124 125 126 /***************************************************************************** 127 * CONSTANTS * 128 *****************************************************************************/ 129 130 /* 131 * Protocol Version number 132 */ 133 #define AuProtocolMajorVersion 2 134 #define AuProtocolMinorVersion 2 135 136 137 /* 138 * Network types 139 */ 140 #define AuNetworkInternet 0 141 #define AuNetworkDECnet 1 142 #define AuNetworkChaos 2 /* reserved; match X */ 143 #define AuNetworkNetname 254 144 #define AuNetworkLocal 256 145 #define AuNetworkWild 65535 146 147 148 /* 149 * Access Control 150 */ 151 #define AuAccessNoChange 0 152 #define AuAccessEnableControls 1 153 #define AuAccessDisableControls 2 154 155 #define AuAccessAddUser 0 156 #define AuAccessRemoveUser 1 157 158 159 /* 160 * Close Down Mode 161 */ 162 #define AuCloseDownDestroy 0 163 #define AuCloseDownRetainPermanent 1 164 #define AuCloseDownRetainTemporary 2 165 166 167 168 /* 169 * Access Codes - these control what people are allowed to do with resources 170 * that are created by a client. 171 */ 172 #define AuAccessImportMask (1L << 0) 173 #define AuAccessExportMask (1L << 1) 174 #define AuAccessDestroyMask (1L << 2) 175 #define AuAccessListMask (1L << 3) 176 #define AuAccessAllMasks ((1L << 4) - 1) 177 178 179 /* 180 * String Types - how strings are encoded 181 */ 182 #define AuStringLatin1 (1L) 183 #define AuStringCompoundText (2L) /* later */ 184 185 186 /* 187 * Event Codes 188 */ 189 #define AuEventTypeElementNotify 2 190 #define AuEventTypeGrabNotify 3 191 #define AuEventTypeMonitorNotify 4 192 #define AuEventTypeBucketNotify 5 /* not yet */ 193 #define AuEventTypeDeviceNotify 6 /* not yet */ 194 195 #define AuFirstEventType AuEventTypeElementNotify 196 #define AuLastEventType AuEventTypeMonitorNotify 197 198 199 200 /* 201 * Error Codes - note that they are designed to match up with core X protocol. 202 */ 203 #define AuSuccess 0 /* no problems */ 204 #define AuBadRequest 1 /* bad request code */ 205 #define AuBadValue 2 /* int value out of range */ 206 #define AuBadDevice 3 /* bad physical device ID */ 207 #define AuBadBucket 4 /* bad bucket ID */ 208 #define AuBadFlow 5 /* bad flow ID */ 209 #define AuBadElement 6 /* bad portal ID */ 210 211 #define AuBadMatch 8 /* parameter mismatch */ 212 213 #define AuBadAccess 10 /* permission denied */ 214 #define AuBadAlloc 11 /* insufficient resources */ 215 #define AuBadConnection 13 /* problem with network */ 216 #define AuBadIDChoice 14 /* bad ID provided for Create */ 217 #define AuBadName 15 /* named object doesn't exist */ 218 #define AuBadLength 16 /* bad request length */ 219 #define AuBadImplementation 17 /* bad server, no cookie */ 220 221 #define AuLastError AuBadImplementation 222 #define AuFirstExtensionError 128 223 #define AuLastExtensionError 255 224 225 226 /***************************************************************************** 227 * DATA FORMATS * 228 *****************************************************************************/ 229 230 /* 231 * External Data Formats; taken from most common disk formats. 232 * the specific codes used do not match up exactly with the SND headers. 233 * These map -1..+1 values into 8 or 16 bit fixed point representations of 234 * the fractions. The unsigned variants typically just offset by 128 or 32768. 235 * 236 * We're going to assume that bit-order isn't a problem here. 237 */ 238 #define AuFormatULAW8 1 /* logarithmic encoding */ 239 #define AuFormatLinearUnsigned8 2 /* common PCM, offset */ 240 #define AuFormatLinearSigned8 3 /* less common PCM */ 241 #define AuFormatLinearSigned16MSB 4 /* common PCM */ 242 #define AuFormatLinearUnsigned16MSB 5 /* PCM, offset */ 243 #define AuFormatLinearSigned16LSB 6 /* common DEC & PC */ 244 #define AuFormatLinearUnsigned16LSB 7 /* DEC & PC offset */ 245 246 #define AuSizeofFormat(fff) \ 247 (((fff) < AuFormatULAW8 || (fff) > AuFormatLinearUnsigned16LSB) ? 0 : \ 248 (((fff) < AuFormatLinearSigned16MSB) ? 1 : 2)) 249 250 251 #define AuUnlimitedSamples 0 /* an unlimited number of 252 * samples */ 253 254 /**************************************************************************** 255 * DEVICES * 256 ****************************************************************************/ 257 258 /* 259 * Device Attributes. In addition to the ValueMask and ChangeMask, these are 260 * the fields returned by the server to describe each device. They are also 261 * used by the client to change various fields. 262 */ 263 #define AuCompCommonIDMask (1L << 0) 264 #define AuCompCommonKindMask (1L << 1) 265 #define AuCompCommonUseMask (1L << 2) 266 #define AuCompCommonFormatMask (1L << 3) 267 #define AuCompCommonNumTracksMask (1L << 4) 268 #define AuCompCommonAccessMask (1L << 5) 269 #define AuCompCommonDescriptionMask (1L << 6) 270 #define AuCompCommonMasks ((1L << 7) - 1) 271 #define AuCompCommonAllMasks AuCompCommonMasks 272 273 #define AuCompDeviceMinSampleRateMask (1L << 16) 274 #define AuCompDeviceMaxSampleRateMask (1L << 17) 275 #define AuCompDeviceLocationMask (1L << 18) 276 #define AuCompDeviceGainMask (1L << 19) 277 #define AuCompDeviceLineModeMask (1L << 20) 278 #define AuCompDeviceInputModeMask AuCompDeviceLineModeMask 279 #define AuCompDeviceOutputModeMask AuCompDeviceLineModeMask 280 #define AuCompDeviceChildrenMask (1L << 21) 281 #define AuCompDeviceMasks (((1L << 22) - 1) & ~0xffff) 282 #define AuCompDeviceAllMasks (AuCompDeviceMasks | \ 283 AuCompCommonAllMasks) 284 285 #define AuCompBucketSampleRateMask (1L << 16) 286 #define AuCompBucketNumSamplesMask (1L << 17) 287 #define AuCompBucketMasks (((1L << 18) - 1) & ~0xffff) 288 #define AuCompBucketAllMasks (AuCompBucketMasks | \ 289 AuCompCommonAllMasks) 290 291 #define AuCompRadioStationMask (1L << 16) 292 #define AuCompRadioMasks ((1L << 17) - 1) 293 #define AuCompRadioAllMasks (AuCompRadioMasks | \ 294 AuCompCommonAllMasks) 295 296 297 /* 298 * Component Kinds. 299 */ 300 #define AuComponentKindOther 0 301 #define AuComponentKindPhysicalInput 1 302 #define AuComponentKindPhysicalOutput 2 303 #define AuComponentKindBucket 3 304 #define AuComponentKindRadio 4 305 #define AuComponentKindPhysicalFeedback 5 306 307 /* 308 * Component Use. These describe whether or not the device can be used 309 * with ImportDevice and/or ExportDevice. 310 * The ExclusiveMask for a device means that that device will override 311 * other devices when used. For example an ExclusiveMask on an input device 312 * means that using that device will override the use of the output devices. 313 * This usually means that the audio hardware cannot record and play 314 * simultaneously. 315 */ 316 #define AuComponentUseImportMask (1L << 0) 317 #define AuComponentUseExportMask (1L << 1) 318 #define AuComponentUseExclusiveMask (1L << 2) 319 #define AuComponentUseAllMasks ((1L << 3) - 1) 320 321 /* 322 * Component Location Hints. These describe where the device is likely to be, 323 * relative to the user. A device may be in more than one position. 324 * The number of tracks determines whether or not the device is mono or stereo. 325 */ 326 #define AuDeviceLocationLeftMask (1L << 0) 327 #define AuDeviceLocationCenterMask (1L << 1) 328 #define AuDeviceLocationRightMask (1L << 2) 329 #define AuDeviceLocationTopMask (1L << 3) 330 #define AuDeviceLocationMiddleMask (1L << 4) 331 #define AuDeviceLocationBottomMask (1L << 5) 332 #define AuDeviceLocationBackMask (1L << 6) 333 #define AuDeviceLocationFrontMask (1L << 7) 334 #define AuDeviceLocationInternalMask (1L << 8) 335 #define AuDeviceLocationExternalMask (1L << 9) 336 #define AuDeviceLocationAllMasks ((1L << 10) - 1) 337 338 339 /* 340 * Component input device selection. 341 * 342 * These determine which amplifier circuits are used, typically to select 343 * between low gain pathways for CD players and other line-level devices and 344 * high gain pathways for microphones and record players. 345 */ 346 #define AuDeviceInputModeNone (0L) 347 #define AuDeviceInputModeLineIn (1L) 348 #define AuDeviceInputModeMicrophone (2L) 349 350 /* compatability... */ 351 #define AuDeviceLineModeNone AuDeviceInputModeNone 352 #define AuDeviceLineModeLow AuDeviceInputModeLineIn 353 #define AuDeviceLineModeHigh AuDeviceInputModeMicrophone 354 355 /* 356 * Component output device selection. 357 * 358 * These may be or'd together on certain systems to select multiple 359 * devices simultaneously. 360 */ 361 #define AuDeviceOutputModeNone (0L) 362 #define AuDeviceOutputModeSpeaker (1L) 363 #define AuDeviceOutputModeHeadphone (2L) 364 #define AuDeviceOutputModeLineOut (4L) 365 366 367 /***************************************************************************** 368 * FLOWS * 369 *****************************************************************************/ 370 371 /* 372 * Elements in a Flow. These are the primitives used to get data from 373 * one place to another. 374 */ 375 #define AuElementTypeImportClient 0 376 #define AuElementTypeImportDevice 1 377 #define AuElementTypeImportBucket 2 378 #define AuElementTypeImportWaveForm 3 379 #define AuElementTypeImportRadio 4 /* not implemented yet */ 380 #define AuElementTypeBundle 5 381 #define AuElementTypeMultiplyConstant 6 382 #define AuElementTypeAddConstant 7 383 #define AuElementTypeSum 8 384 #define AuElementTypeExportClient 9 385 #define AuElementTypeExportDevice 10 386 #define AuElementTypeExportBucket 11 387 #define AuElementTypeExportRadio 12 /* not implemented yet */ 388 #define AuElementTypeExportMonitor 13 389 390 391 #define AU_MAX_ELEMENTS 254 392 #define AuElementAll 255 393 394 #define AU_MAX_PARMS 5 395 #define AuParmsImportClient 0 396 #define AuParmsImportDevice 0 397 #define AuParmsImportBucket 1 /* offset */ 398 #define AuParmsImportBucketOffset 0 399 #define AuParmsImportWaveForm 2 /* frequency, num samples */ 400 #define AuParmsImportWaveFormFrequency 0 401 #define AuParmsImportWaveFormNumSamples 1 402 #define AuParmsImportRadio 0 403 #define AuParmsBundle 0 404 #define AuParmsMultiplyConstant 1 /* integer, fraction */ 405 #define AuParmsMultiplyConstantConstant 0 406 #define AuParmsAddConstant 1 /* integer, fraction */ 407 #define AuParmsAddConstantConstant 0 408 #define AuParmsSum 0 409 #define AuParmsExportClient 0 410 #define AuParmsExportDevice 0 411 #define AuParmsExportBucket 1 /* offset */ 412 #define AuParmsExportBucketOffset 0 413 #define AuParmsExportRadio 0 414 #define AuParmsExportMonitor 0 415 416 /* 417 * Import and Export Element States. These values are used explicitly 418 * when setting the state, and in any state actions. 419 */ 420 #define AuStateStop 0 421 #define AuStateStart 1 422 #define AuStatePause 2 423 #define AuStateAny 255 424 425 #define AuElementActionChangeState 0 426 #define AuElementActionSendNotify 1 427 #define AuElementActionNoop 2 428 429 430 /* 431 * Wave forms 432 */ 433 #define AuWaveFormSquare 0 434 #define AuWaveFormSine 1 435 #define AuWaveFormSaw 2 436 #define AuWaveFormConstant 3 437 438 439 /* 440 * ElementNotify event kinds. 441 */ 442 #define AuElementNotifyKindLowWater 0 443 #define AuElementNotifyKindHighWater 1 444 #define AuElementNotifyKindState 2 445 446 /* 447 * ElementNotify reasons 448 */ 449 #define AuReasonUser 0 450 #define AuReasonUnderrun 1 451 #define AuReasonOverrun 2 452 #define AuReasonEOF 3 453 #define AuReasonWatermark 4 454 #define AuReasonHardware 5 455 #define AuReasonAny 255 456 457 /* 458 * GrabNotify event kinds. 459 */ 460 #define AuGrabNotifyKindRequested 0 461 #define AuGrabNotifyKindReleased 1 462 463 464 465 /* 466 * Data transfer state 467 */ 468 #define AuTransferStateReady 0 469 #define AuTransferStatePending 1 470 #define AuTransferStateEnd 2 471 472 473 #endif /* _NCD_AUDIO_H_ */ 474