doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
audio_core.h
Go to the documentation of this file.
1 #ifndef AUDIO_CORE_H
2 #define AUDIO_CORE_H
3 /*
4  * Copyright by 4Front Technologies 1993-2004
5  *
6  * All rights reserved.
7  */
8 
9 /*
10  * IMPORTANT NOTICE!
11  *
12  * This file contains internal structures used by Open Sound Systems.
13  * They will change without any notice between OSS versions. Care must be taken
14  * to make sure any software using this header gets properly re-compiled before
15  * use.
16  *
17  * 4Front Technologies (or anybody else) takes no responsibility of damages
18  * caused by use of this file.
19  */
20 
21 /* Max number of audio channels currently supported */
22 #define OSS_MAX_AUDIO_CHANNELS 8
23 
24 struct audio_operations;
25 
26 typedef struct
27 {
28  int fmt, speed, channels;
29  int convert;
30 }
32 
35 typedef int (*cnv_func_t) (adev_p adev, dmap_p dmap, void **srcp, int *srcl,
36  void **tgtp, sample_parms * source,
37  sample_parms * target);
38 
40 {
41 /*
42  * Static fields (not to be cleared during open)
43  */
44 #ifndef CONFIGURE_C
45  oss_mutex mutex;
46 #endif
47  sound_os_info *osp;
48  char *raw_buf;
49  oss_native_ulong raw_buf_phys;
50  int buffsize;
51  unsigned char *tmpbuf1, *tmpbuf2;
52  int dma; /* DMA channel */
55  /* Interrupt callback stuff */
56  void (*audio_callback) (int dev, int parm);
58 
59 #ifdef OS_DMA_PARMS
60  OS_DMA_PARMS
61 #endif
62 /*
63  * Dynamic fields (will be zeroed during open)
64  * Don't add anything before flags.
65  */
67  oss_native_ulong flags;
68 #define DMAP_NOTIMEOUT 0x00000001
69 #define DMAP_POST 0x00000002
70 #define DMAP_PREPARED 0x00000004
71 #define DMAP_FRAGFIXED 0x00000008 /* Fragment size fixed */
72 #define DMAP_STARTED 0x00000010
73 #define DMAP_COOKED 0x00000020
74 #define DMAP_ACTIVE 0x00000040 /* ISA DMA is running */
75  int dma_mode; /* DMODE_INPUT, DMODE_OUTPUT or DMODE_NONE */
76 #define DMODE_NONE 0
77 #define DMODE_OUTPUT PCM_ENABLE_OUTPUT
78 #define DMODE_INPUT PCM_ENABLE_INPUT
79 
80  /*
81  * Queue parameters.
82  */
83  int nbufs;
84  int frag_used;
87  int data_rate; /* Bytes/second */
90  int low_water;
91  volatile oss_native_ulonglong byte_counter;
92  volatile oss_native_ulonglong user_counter;
97 
99 #define DMA_MAP_MAPPED 0x00000001
101 
102 #ifdef SPARCAUDIO_EMU
103 #define EOFLIST_SIZE 16
104  void *devaudio_sigproc; /* A pref to which send a SIGPOLL signal */
105  int devaudio_sigmask;
106  int eof_head, eof_tail;
107  int eof_list[EOFLIST_SIZE], eof_counts[EOFLIST_SIZE];
108 #endif
109  int error;
114 
115  unsigned char *leftover_buf;
119  unsigned int convert_mode;
120  struct audio_buffer *(*user_import) (struct audio_operations * adev,
121  struct dma_buffparms * dmap,
122  sample_parms * parms,
123  unsigned char *cbuf, int len);
124  int (*user_export) (struct audio_operations * adev,
125  struct dma_buffparms * dmap, sample_parms * parms,
126  struct audio_buffer * buf, unsigned char *cbuf,
127  int maxbytes);
128  struct audio_buffer *(*device_read) (struct audio_operations * adev,
129  struct dma_buffparms * dmap,
130  sample_parms * parms,
131  unsigned char *cbuf, int len);
132  int (*device_write) (struct audio_operations * adev,
133  struct dma_buffparms * dmap,
134  void *frombuf, void *tobuf,
135  int maxspace, int *fromlen, int *tolen);
136 };
137 extern int dmap_get_qlen (dma_buffparms * dmap);
138 extern int dmap_get_qhead (dma_buffparms * dmap);
139 extern int dmap_get_qtail (dma_buffparms * dmap);
140 
142 {
143  int (*open) (int dev, int mode, int open_flags);
144  void (*close) (int dev, int mode);
145  void (*output_block) (int dev, oss_native_ulong buf,
146  int count, int fragsize, int intrflag);
147  void (*start_input) (int dev, oss_native_ulong buf,
148  int count, int fragsize, int intrflag);
149  int (*ioctl) (int dev, unsigned int cmd, ioctl_arg arg);
150  int (*prepare_for_input) (int dev, int bufsize, int nbufs);
151  int (*prepare_for_output) (int dev, int bufsize, int nbufs);
152  void (*halt_io) (int dev);
153  int (*local_qlen) (int dev);
154  int (*copy_user) (int dev, char *localbuf, int localoffs,
155  WR_BUF_CONST snd_rw_buf * userbuf, int useroffs,
156  int *len, int max_space);
157  void (*halt_input) (int dev);
158  void (*halt_output) (int dev);
159  void (*trigger) (int dev, int bits);
160  int (*set_speed) (int dev, int speed);
161  unsigned int (*set_bits) (int dev, unsigned int bits);
162  short (*set_channels) (int dev, short channels);
163  void (*postprocess_write) (int dev); /* Device spesific postprocessing for written data */
164  void (*preprocess_read) (int dev); /* Device spesific preprocessing for read data */
165  /* Timeout handlers for input and output */
166  int (*check_input) (int dev);
167  int (*check_output) (int dev);
168 
169  int (*alloc_buffer) (int dev, struct dma_buffparms * dmap, int direction);
170  int (*free_buffer) (int dev, struct dma_buffparms * dmap, int direction);
171  void (*lock_buffer) (int dev, int direction);
172  void *dummy;
173  int (*get_buffer_pointer) (int dev, struct dma_buffparms * dmap,
174  int direction);
175  int (*calibrate_speed) (int dev, int nominal_rate, int true_rate);
176 #define SYNC_PREPARE 1
177 #define SYNC_TRIGGER 2
178  int (*sync_control) (int dev, int event, int mode);
179  void (*prepare_to_stop) (int dev);
180  int (*get_input_pointer) (int dev, struct dma_buffparms * dmap,
181  int direction);
182  int (*get_output_pointer) (int dev, struct dma_buffparms * dmap,
183  int direction);
184  int (*bind) (int dev, unsigned int cmd, ioctl_arg arg);
185  void (*setup_fragments) (int dev, dmap_p dmap, int direction);
186 };
187 
189 {
190  char name[128];
191  char handle[32];
192  int dev; /* Device's own index */
193  int enabled;
194  struct audio_operations *next; /* Link to the next "shadow" device */
195  int flags;
197  int caps;
198  int magic; /* Secret low level driver ID */
199 #define NOTHING_SPECIAL 0x00
200 #define NEEDS_RESTART 0x01
201 #define DMA_AUTOMODE 0x02
202 #define DMA_DUPLEX 0x04
203 #define DMA_COLD 0x08
204 #define DMA_UNUSED1 0x10
205 #define DMA_UNUSED2 0x40
206 #define DMA_UNUSED3 0x80
207 #define DMA_ISA 0x100 /* ISA DMA buffer placement restrictions */
208 #define DMA_VIRTUAL 0x400 /* Virtual audio device */
209 #define DMA_OPENED 0x800 /* Will be set when the device is open */
210 #define DMA_NOCONVERT 0x1000 /* No implicit format conversions */
211 #define DMA_DUALBUF 0x2000 /* Alloc separate bufs for rec and play */
212 #define DMA_USEPHYSADDR 0x4000 /* Use raw_buf_phys when mmap()ing */
213 #define DMA_DISABLED 0x8000
214 #define DMA_NOINPUT 0x10000
215 #define DMA_NOOUTPUT 0x20000
216 #define DMA_FIXEDRATE 0x40000 /* Fixed sampling rate */
217 #define DMA_16BITONLY 0x80000 /* Only 16 bit support */
218 #define DMA_STEREOONLY 0x100000 /* Only stereo (requires 16BITONLY) */
219 #define DMA_HUSHOUTPUT 0x200000 /* Do not permit use with O_WRONLY */
220 #define DMA_SHADOW 0x400000 /* "shadow" device */
221 #define DMA_ISABUS 0x800000 /* ISA device */
222 #define DMA_NODMA 0x1000000 /* For ISA devices only */
223 #define DMA_8BITONLY 0x2000000 /* Only 8 bits */
224 #define DMA_32BITONLY 0x4000000 /* Only 24 or 32 bits */
225 #define DMA_NOSOFTOSS 0x8000000 /* Don't install SoftOSS automatically for this device */
226 #define DMA_NOSRC 0x10000000 /* Don't do any kind of SRC */
227 #define DMA_SPECIAL 0x20000000 /* Multich or otherwise special dev */
228 #define DMA_NOMMAP 0x40000000 /* No MMAP capability */
229 #define DMA_SOFTOSS_DISABLE 0x80000000 /* Not compatible with SoftOSS */
230 
231 
232  /*
233  * Sampling parameters
234  */
235 
237  int iformat_mask, oformat_mask; /* Bitmasks for supported audio formats */
238  int min_rate, max_rate; /* Sampling rate limits */
240  int xformat_mask; /* Format mask for current open mode */
241  int binding;
242  void *devc; /* Driver specific info */
243  struct audio_driver *d;
244  void *portc, *portc_play, *portc_record; /* Driver specific info */
248  int go;
250  int parent_dev; /* 0 -> no parent, 1 to n -> parent=parent_dev+1 */
251  int max_block; /* Maximum fragment size to be accepted */
252  int min_block; /* Minimum fragment size */
253  int max_intrate; /* Another form of min_block */
255  int vmix_flags; /* special flags sent to virtual mixer */
256 #define VMIX_MULTIFRAG 0x00000001 /* More than 2 fragments required (causes longer latencies) */
257  int src_rate;
259  pid_t pid;
260  char cmd[16];
261  sound_os_info *osp;
265  int dmask; /* Open dmaps */
266 #define DMASK_OUT 0x01
267 #define DMASK_IN 0x02
268  int nonblock;
272 #define SYNC_MASTER 0x01
273 #define SYNC_SLAVE 0x02
276  struct audio_operations *sync_next; /* Next device in sync group */
277 
279 #define MAX_SAMPLE_RATES 20 /* Cannot be changed (see soundcard.h) */
281 
282 #ifndef CONFIGURE_C
283  oss_mutex mutex;
284 #endif
285 
288  int real_dev;
289 
292 
293  void (*outputintr) (int dev, int xx);
294  void (*inputintr) (int dev);
295 };
296 
297 typedef struct oss_card_desc
298 {
299  char shortname[16];
300  char longname[128];
302 
303 #define UNIT_EXPAND 1024
304 
305 extern struct audio_operations **audio_devs;
306 extern int num_audiodevs;
307 extern oss_card_desc_p *oss_cardlist;
308 extern const char *oss_version_string;
309 extern const char *oss_checksum;
310 #endif
oss_mutex mutex
Definition: audio_core.h:45
unsigned int(* set_bits)(int dev, unsigned int bits)
Definition: audio_core.h:161
long driver_use_value
Definition: audio_core.h:54
int play_underruns
Definition: audio_core.h:110
const char * oss_checksum
unsigned char * tmpbuf1
Definition: audio_core.h:51
void(* preprocess_read)(int dev)
Definition: audio_core.h:164
struct dma_buffparms * dmap_out
Definition: audio_core.h:245
int dmap_get_qhead(dma_buffparms *dmap)
int mapping_flags
Definition: audio_core.h:98
void(* halt_io)(int dev)
Definition: audio_core.h:152
int(* free_buffer)(int dev, struct dma_buffparms *dmap, int direction)
Definition: audio_core.h:170
oss_mutex mutex
Definition: audio_core.h:283
struct oss_card_desc oss_card_desc_t
case const int
Definition: Callbacks.cpp:52
sample_parms user_parms
Definition: audio_core.h:236
int(* alloc_buffer)(int dev, struct dma_buffparms *dmap, int direction)
Definition: audio_core.h:169
int fragment_size
Definition: audio_core.h:85
volatile oss_native_ulonglong byte_counter
Definition: audio_core.h:91
int callback_parm
Definition: audio_core.h:57
void(* output_block)(int dev, oss_native_ulong buf, int count, int fragsize, int intrflag)
Definition: audio_core.h:145
char shortname[16]
Definition: audio_core.h:299
GLenum GLsizei len
Definition: glext.h:3472
int(* ioctl)(int dev, unsigned int cmd, ioctl_arg arg)
Definition: audio_core.h:149
int(* set_speed)(int dev, int speed)
Definition: audio_core.h:160
void(* postprocess_write)(int dev)
Definition: audio_core.h:163
int(* get_input_pointer)(int dev, struct dma_buffparms *dmap, int direction)
Definition: audio_core.h:180
int num_play_errors
Definition: audio_core.h:112
struct dma_buffparms * dmap_p
Definition: audio_core.h:34
void * portc_record
Definition: audio_core.h:244
int leftover_bytes
Definition: audio_core.h:116
int(* open)(int dev, int mode, int open_flags)
Definition: audio_core.h:143
GLsizei GLsizei GLcharARB * source
Definition: glext.h:3633
void(* halt_output)(int dev)
Definition: audio_core.h:158
GLuint GLuint GLsizei count
Definition: glext.h:2845
int(* check_output)(int dev)
Definition: audio_core.h:167
void(* outputintr)(int dev, int xx)
Definition: audio_core.h:293
int(* user_export)(struct audio_operations *adev, struct dma_buffparms *dmap, sample_parms *parms, struct audio_buffer *buf, unsigned char *cbuf, int maxbytes)
Definition: audio_core.h:124
sample_parms hw_parms
Definition: audio_core.h:236
#define OSS_MAX_AUDIO_CHANNELS
Definition: audio_core.h:22
int(* prepare_for_input)(int dev, int bufsize, int nbufs)
Definition: audio_core.h:150
void(* start_input)(int dev, oss_native_ulong buf, int count, int fragsize, int intrflag)
Definition: audio_core.h:147
struct audio_driver * d
Definition: audio_core.h:243
void * dummy
Definition: audio_core.h:172
void * driver_use_ptr
Definition: audio_core.h:53
oss_native_ulong flags
Definition: audio_core.h:67
void(* trigger)(int dev, int bits)
Definition: audio_core.h:159
void(* inputintr)(int dev)
Definition: audio_core.h:294
int(* copy_user)(int dev, char *localbuf, int localoffs, WR_BUF_CONST snd_rw_buf *userbuf, int useroffs, int *len, int max_space)
Definition: audio_core.h:154
void(* lock_buffer)(int dev, int direction)
Definition: audio_core.h:171
sound_os_info * osp
Definition: audio_core.h:261
struct audio_operations * adev_p
Definition: audio_core.h:33
cnv_func_t convert_func
Definition: audio_core.h:118
GLint mode
Definition: glext.h:4165
void(* halt_input)(int dev)
Definition: audio_core.h:157
void(* audio_callback)(int dev, int parm)
Definition: audio_core.h:56
int num_audiodevs
int rates[MAX_SAMPLE_RATES]
Definition: audio_core.h:280
int(* get_buffer_pointer)(int dev, struct dma_buffparms *dmap, int direction)
Definition: audio_core.h:173
struct audio_operations * next
Definition: audio_core.h:194
int(* local_qlen)(int dev)
Definition: audio_core.h:153
int interrupt_count
Definition: audio_core.h:94
short(* set_channels)(int dev, short channels)
Definition: audio_core.h:162
struct oss_card_desc * oss_card_desc_p
int dmap_get_qlen(dma_buffparms *dmap)
char longname[128]
Definition: audio_core.h:300
int(* get_output_pointer)(int dev, struct dma_buffparms *dmap, int direction)
Definition: audio_core.h:182
void(* setup_fragments)(int dev, dmap_p dmap, int direction)
Definition: audio_core.h:185
int(* prepare_for_output)(int dev, int bufsize, int nbufs)
Definition: audio_core.h:151
unsigned int convert_mode
Definition: audio_core.h:119
#define bits
Definition: Unzip.cpp:3797
struct dma_buffparms * dmap_in
Definition: audio_core.h:245
int(* sync_control)(int dev, int event, int mode)
Definition: audio_core.h:178
void(* close)(int dev, int mode)
Definition: audio_core.h:144
int(* bind)(int dev, unsigned int cmd, ioctl_arg arg)
Definition: audio_core.h:184
const GLcharARB * name
Definition: glext.h:3629
const char * oss_version_string
oss_native_ulong raw_buf_phys
Definition: audio_core.h:49
struct audio_operations ** audio_devs
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
int dmap_get_qtail(dma_buffparms *dmap)
unsigned char * leftover_buf
Definition: audio_core.h:115
int expand_factor
Definition: audio_core.h:96
char neutral_byte
Definition: audio_core.h:100
#define MAX_SAMPLE_RATES
Definition: audio_core.h:279
int bytes_in_use
Definition: audio_core.h:86
char * raw_buf
Definition: audio_core.h:48
int num_rec_errors
Definition: audio_core.h:113
oss_card_desc_p * oss_cardlist
int(* device_write)(struct audio_operations *adev, struct dma_buffparms *dmap, void *frombuf, void *tobuf, int maxspace, int *fromlen, int *tolen)
Definition: audio_core.h:132
int fragment_counter
Definition: audio_core.h:95
void * srcstate[OSS_MAX_AUDIO_CHANNELS]
Definition: audio_core.h:66
char handle[32]
Definition: audio_core.h:191
volatile oss_native_ulonglong user_counter
Definition: audio_core.h:92
void(* prepare_to_stop)(int dev)
Definition: audio_core.h:179
int(* calibrate_speed)(int dev, int nominal_rate, int true_rate)
Definition: audio_core.h:175
int(* check_input)(int dev)
Definition: audio_core.h:166
unsigned char * tmpbuf2
Definition: audio_core.h:51
struct audio_operations * sync_next
Definition: audio_core.h:276
sound_os_info * osp
Definition: audio_core.h:47
int(* cnv_func_t)(adev_p adev, dmap_p dmap, void **srcp, int *srcl, void **tgtp, sample_parms *source, sample_parms *target)
Definition: audio_core.h:35