0.6.1-alt1
[qemu] / qemu / audio / audio.h
1 /*
2  * QEMU Audio subsystem header
3  * 
4  * Copyright (c) 2003-2004 Vassili Karpov (malc)
5  * 
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #ifndef QEMU_AUDIO_H
25 #define QEMU_AUDIO_H
26
27 #include "mixeng.h"
28
29 typedef enum {
30   AUD_FMT_U8,
31   AUD_FMT_S8,
32   AUD_FMT_U16,
33   AUD_FMT_S16
34 } audfmt_e;
35
36 typedef struct SWVoice SWVoice;
37
38 SWVoice * AUD_open (SWVoice *sw, const char *name, int freq,
39                     int nchannels, audfmt_e fmt);
40 void   AUD_init (void);
41 void   AUD_log (const char *cap, const char *fmt, ...)
42     __attribute__ ((__format__ (__printf__, 2, 3)));;
43 void   AUD_close (SWVoice *sw);
44 int    AUD_write (SWVoice *sw, void *pcm_buf, int size);
45 void   AUD_adjust (SWVoice *sw, int leftover);
46 void   AUD_reset (SWVoice *sw);
47 int    AUD_get_free (SWVoice *sw);
48 int    AUD_get_buffer_size (SWVoice *sw);
49 void   AUD_run (void);
50 void   AUD_enable (SWVoice *sw, int on);
51 int    AUD_calc_elapsed (SWVoice *sw);
52
53 static inline void *advance (void *p, int incr)
54 {
55     uint8_t *d = p;
56     return (d + incr);
57 }
58
59 uint32_t popcount (uint32_t u);
60 inline uint32_t lsbindex (uint32_t u);
61
62 #define audio_MIN(a, b) ((a)>(b)?(b):(a))
63 #define audio_MAX(a, b) ((a)<(b)?(b):(a))
64
65 #endif  /* audio.h */