1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _AUDIO_AU_H 28 #define _AUDIO_AU_H 29 30 #include <sys/isa_defs.h> 31 #include <sys/types.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* 38 * Define an on-disk audio file header for the AU file format. 39 * 40 * Note that there is an optional 'info' field that immediately follows this 41 * structure in the file. It is an optional length field that is sometimes 42 * used to store additional information. At the minimum, it is at 43 * least 4 bytes. 44 * 45 * The offset field is problematic in the general case because the 46 * field is really "data location", which does not ensure that all 47 * the bytes between the header and the data are really 'info'. 48 * Further, there are no absolute guarantees that the info is ASCII text. 49 * 50 * When audio files are passed through pipes, the au_data_size field may 51 * not be known in advance. In such cases, au_data_size should be 52 * set to AUDIO_AU_UNKNOWN_SIZE. 53 */ 54 55 struct au_filehdr { 56 uint32_t au_magic; /* magic number */ 57 uint32_t au_offset; /* size of this header */ 58 uint32_t au_data_size; /* length of data */ 59 uint32_t au_encoding; /* data encoding format */ 60 uint32_t au_sample_rate; /* samples per second */ 61 uint32_t au_channels; /* number of interleaved channels */ 62 }; 63 typedef struct au_filehdr au_filehdr_t; 64 65 /* 66 * This is the appearance of a typical AU audio file as described 67 * by this structure. 68 * 69 * ------------------------------------------------------------ 70 * | | | | 71 * | AU Audio Header | Info | Audio Data | 72 * | | (optional) | | 73 * | | | | 74 * | 24 bytes | 4 bytes (min) | n bytes | 75 * | | | | 76 * ------------------------------------------------------------ 77 */ 78 79 /* Define the magic number */ 80 #define AUDIO_AU_FILE_MAGIC ((uint32_t)0x2e736e64) /* ".snd" */ 81 82 /* Unknown header size */ 83 #define AUDIO_AU_UNKNOWN_SIZE ((unsigned)(~0)) /* (unsigned) -1 */ 84 85 /* Define the AU encoding fields */ 86 #define AUDIO_AU_ENCODING_ULAW (1) /* 8-bit u-law */ 87 #define AUDIO_AU_ENCODING_LINEAR_8 (2) /* 8-bit linear PCM */ 88 #define AUDIO_AU_ENCODING_LINEAR_16 (3) /* 16-bit linear PCM */ 89 #define AUDIO_AU_ENCODING_LINEAR_24 (4) /* 24-bit linear PCM */ 90 #define AUDIO_AU_ENCODING_LINEAR_32 (5) /* 32-bit linear PCM */ 91 #define AUDIO_AU_ENCODING_FLOAT (6) /* 32-bit IEEE floating point */ 92 #define AUDIO_AU_ENCODING_DOUBLE (7) /* 64-bit IEEE double */ 93 /* precision float */ 94 #define AUDIO_AU_ENCODING_FRAGMENTED (8) /* Fragmented sample data */ 95 #define AUDIO_AU_ENCODING_DSP (10) /* DSP program */ 96 #define AUDIO_AU_ENCODING_FIXED_8 (11) /* 8-bit fixed point */ 97 #define AUDIO_AU_ENCODING_FIXED_16 (12) /* 16-bit fixed point */ 98 #define AUDIO_AU_ENCODING_FIXED_24 (13) /* 24-bit fixed point */ 99 #define AUDIO_AU_ENCODING_FIXED_32 (14) /* 32-bit fixed point */ 100 #define AUDIO_AU_ENCODING_EMPHASIS (18) /* 16-bit linear with */ 101 /* emphasis */ 102 #define AUDIO_AU_ENCODING_COMPRESSED (19) /* 16-bit linear compressed */ 103 #define AUDIO_AU_ENCODING_EMP_COMP (20) /* 16-bit linear with */ 104 /* emphasis and compression */ 105 #define AUDIO_AU_ENCODING_MUSIC_KIT (21) /* Music kit DSP commands */ 106 #define AUDIO_AU_ENCODING_ADPCM_G721 (23) /* 4-bit CCITT G.721 ADPCM */ 107 #define AUDIO_AU_ENCODING_ADPCM_G722 (24) /* CCITT G.722 ADPCM */ 108 #define AUDIO_AU_ENCODING_ADPCM_G723_3 (25) /* CCITT G.723.3 ADPCM */ 109 #define AUDIO_AU_ENCODING_ADPCM_G723_5 (26) /* CCITT G.723.5 ADPCM */ 110 #define AUDIO_AU_ENCODING_ALAW (27) /* 8-bit A-law G.711 */ 111 112 113 /* Byte swapping routines */ 114 #if defined(_BIG_ENDIAN) 115 #define AUDIO_AU_FILE2HOST(from, to) *((long *)(to)) = *((long *)(from)) 116 #else 117 #define AUDIO_AU_FILE2HOST(from, to) \ 118 ((char *)(to))[0] = ((char *)(from))[3]; \ 119 ((char *)(to))[1] = ((char *)(from))[2]; \ 120 ((char *)(to))[2] = ((char *)(from))[1]; \ 121 ((char *)(to))[3] = ((char *)(from))[0]; 122 #endif /* byte swapping */ 123 124 #if defined(__sparc) || defined(__i386) || defined(__amd64) 125 #define AUDIO_AU_HOST2FILE(from, to) AUDIO_AU_FILE2HOST((from), (to)) 126 #else 127 #error unknown machine type; 128 #endif /* encode */ 129 130 #ifdef __cplusplus 131 } 132 #endif 133 134 #endif /* _AUDIO_AU_H */ 135