root / audio / audio.h @ 64e58fe5
History | View | Annotate | Download (4.9 kB)
1 | 85571bc7 | bellard | /*
|
---|---|---|---|
2 | 85571bc7 | bellard | * QEMU Audio subsystem header
|
3 | 1d14ffa9 | bellard | *
|
4 | 1d14ffa9 | bellard | * Copyright (c) 2003-2005 Vassili Karpov (malc)
|
5 | 1d14ffa9 | bellard | *
|
6 | 85571bc7 | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | 85571bc7 | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | 85571bc7 | bellard | * in the Software without restriction, including without limitation the rights
|
9 | 85571bc7 | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | 85571bc7 | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | 85571bc7 | bellard | * furnished to do so, subject to the following conditions:
|
12 | 85571bc7 | bellard | *
|
13 | 85571bc7 | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | 85571bc7 | bellard | * all copies or substantial portions of the Software.
|
15 | 85571bc7 | bellard | *
|
16 | 85571bc7 | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | 85571bc7 | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | 85571bc7 | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | 85571bc7 | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | 85571bc7 | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | 85571bc7 | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | 85571bc7 | bellard | * THE SOFTWARE.
|
23 | 85571bc7 | bellard | */
|
24 | 85571bc7 | bellard | #ifndef QEMU_AUDIO_H
|
25 | 85571bc7 | bellard | #define QEMU_AUDIO_H
|
26 | 85571bc7 | bellard | |
27 | 5fa0ab8f | bellard | #include "config-host.h" |
28 | 72cf2d4f | Blue Swirl | #include "qemu-queue.h" |
29 | c0fe3827 | bellard | |
30 | cb4f03e8 | malc | typedef void (*audio_callback_fn) (void *opaque, int avail); |
31 | 85571bc7 | bellard | |
32 | 85571bc7 | bellard | typedef enum { |
33 | c0fe3827 | bellard | AUD_FMT_U8, |
34 | c0fe3827 | bellard | AUD_FMT_S8, |
35 | c0fe3827 | bellard | AUD_FMT_U16, |
36 | f941aa25 | ths | AUD_FMT_S16, |
37 | f941aa25 | ths | AUD_FMT_U32, |
38 | f941aa25 | ths | AUD_FMT_S32 |
39 | 85571bc7 | bellard | } audfmt_e; |
40 | 85571bc7 | bellard | |
41 | e2542fe2 | Juan Quintela | #ifdef HOST_WORDS_BIGENDIAN
|
42 | d929eba5 | bellard | #define AUDIO_HOST_ENDIANNESS 1 |
43 | d929eba5 | bellard | #else
|
44 | d929eba5 | bellard | #define AUDIO_HOST_ENDIANNESS 0 |
45 | d929eba5 | bellard | #endif
|
46 | d929eba5 | bellard | |
47 | 1ea879e5 | malc | struct audsettings {
|
48 | c0fe3827 | bellard | int freq;
|
49 | c0fe3827 | bellard | int nchannels;
|
50 | c0fe3827 | bellard | audfmt_e fmt; |
51 | d929eba5 | bellard | int endianness;
|
52 | 1ea879e5 | malc | }; |
53 | c0fe3827 | bellard | |
54 | ec36b695 | bellard | typedef enum { |
55 | ec36b695 | bellard | AUD_CNOTIFY_ENABLE, |
56 | ec36b695 | bellard | AUD_CNOTIFY_DISABLE |
57 | ec36b695 | bellard | } audcnotification_e; |
58 | ec36b695 | bellard | |
59 | 8ead62cf | bellard | struct audio_capture_ops {
|
60 | ec36b695 | bellard | void (*notify) (void *opaque, audcnotification_e cmd); |
61 | 8ead62cf | bellard | void (*capture) (void *opaque, void *buf, int size); |
62 | ec36b695 | bellard | void (*destroy) (void *opaque); |
63 | 8ead62cf | bellard | }; |
64 | 8ead62cf | bellard | |
65 | ec36b695 | bellard | struct capture_ops {
|
66 | ec36b695 | bellard | void (*info) (void *opaque); |
67 | ec36b695 | bellard | void (*destroy) (void *opaque); |
68 | ec36b695 | bellard | }; |
69 | ec36b695 | bellard | |
70 | ec36b695 | bellard | typedef struct CaptureState { |
71 | ec36b695 | bellard | void *opaque;
|
72 | ec36b695 | bellard | struct capture_ops ops;
|
73 | 72cf2d4f | Blue Swirl | QLIST_ENTRY (CaptureState) entries; |
74 | ec36b695 | bellard | } CaptureState; |
75 | ec36b695 | bellard | |
76 | 1d14ffa9 | bellard | typedef struct SWVoiceOut SWVoiceOut; |
77 | ec36b695 | bellard | typedef struct CaptureVoiceOut CaptureVoiceOut; |
78 | 1d14ffa9 | bellard | typedef struct SWVoiceIn SWVoiceIn; |
79 | 1d14ffa9 | bellard | |
80 | c0fe3827 | bellard | typedef struct QEMUSoundCard { |
81 | c0fe3827 | bellard | char *name;
|
82 | 72cf2d4f | Blue Swirl | QLIST_ENTRY (QEMUSoundCard) entries; |
83 | c0fe3827 | bellard | } QEMUSoundCard; |
84 | c0fe3827 | bellard | |
85 | 1d14ffa9 | bellard | typedef struct QEMUAudioTimeStamp { |
86 | 1d14ffa9 | bellard | uint64_t old_ts; |
87 | 1d14ffa9 | bellard | } QEMUAudioTimeStamp; |
88 | 1d14ffa9 | bellard | |
89 | 1d14ffa9 | bellard | void AUD_vlog (const char *cap, const char *fmt, va_list ap); |
90 | 1d14ffa9 | bellard | void AUD_log (const char *cap, const char *fmt, ...) |
91 | 1d14ffa9 | bellard | #ifdef __GNUC__
|
92 | 1d14ffa9 | bellard | __attribute__ ((__format__ (__printf__, 2, 3))) |
93 | 1d14ffa9 | bellard | #endif
|
94 | 1d14ffa9 | bellard | ; |
95 | 85571bc7 | bellard | |
96 | 1d14ffa9 | bellard | void AUD_help (void); |
97 | 1a7dafce | malc | void AUD_register_card (const char *name, QEMUSoundCard *card); |
98 | c0fe3827 | bellard | void AUD_remove_card (QEMUSoundCard *card);
|
99 | ec36b695 | bellard | CaptureVoiceOut *AUD_add_capture ( |
100 | 1ea879e5 | malc | struct audsettings *as,
|
101 | 8ead62cf | bellard | struct audio_capture_ops *ops,
|
102 | 8ead62cf | bellard | void *opaque
|
103 | 8ead62cf | bellard | ); |
104 | ec36b695 | bellard | void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque); |
105 | 1d14ffa9 | bellard | |
106 | c0fe3827 | bellard | SWVoiceOut *AUD_open_out ( |
107 | c0fe3827 | bellard | QEMUSoundCard *card, |
108 | 1d14ffa9 | bellard | SWVoiceOut *sw, |
109 | 1d14ffa9 | bellard | const char *name, |
110 | 1d14ffa9 | bellard | void *callback_opaque,
|
111 | cb4f03e8 | malc | audio_callback_fn callback_fn, |
112 | 1ea879e5 | malc | struct audsettings *settings
|
113 | 1d14ffa9 | bellard | ); |
114 | c0fe3827 | bellard | |
115 | c0fe3827 | bellard | void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw);
|
116 | c0fe3827 | bellard | int AUD_write (SWVoiceOut *sw, void *pcm_buf, int size); |
117 | c0fe3827 | bellard | int AUD_get_buffer_size_out (SWVoiceOut *sw);
|
118 | c0fe3827 | bellard | void AUD_set_active_out (SWVoiceOut *sw, int on); |
119 | c0fe3827 | bellard | int AUD_is_active_out (SWVoiceOut *sw);
|
120 | c0fe3827 | bellard | |
121 | c0fe3827 | bellard | void AUD_init_time_stamp_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
|
122 | c0fe3827 | bellard | uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts); |
123 | c0fe3827 | bellard | |
124 | 683efdcb | balrog | void AUD_set_volume_out (SWVoiceOut *sw, int mute, uint8_t lvol, uint8_t rvol); |
125 | 683efdcb | balrog | void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol); |
126 | 683efdcb | balrog | |
127 | c0fe3827 | bellard | SWVoiceIn *AUD_open_in ( |
128 | c0fe3827 | bellard | QEMUSoundCard *card, |
129 | 1d14ffa9 | bellard | SWVoiceIn *sw, |
130 | 1d14ffa9 | bellard | const char *name, |
131 | 1d14ffa9 | bellard | void *callback_opaque,
|
132 | cb4f03e8 | malc | audio_callback_fn callback_fn, |
133 | 1ea879e5 | malc | struct audsettings *settings
|
134 | 1d14ffa9 | bellard | ); |
135 | c0fe3827 | bellard | |
136 | c0fe3827 | bellard | void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw);
|
137 | c0fe3827 | bellard | int AUD_read (SWVoiceIn *sw, void *pcm_buf, int size); |
138 | c0fe3827 | bellard | void AUD_set_active_in (SWVoiceIn *sw, int on); |
139 | c0fe3827 | bellard | int AUD_is_active_in (SWVoiceIn *sw);
|
140 | c0fe3827 | bellard | |
141 | c0fe3827 | bellard | void AUD_init_time_stamp_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
|
142 | c0fe3827 | bellard | uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts); |
143 | 85571bc7 | bellard | |
144 | 85571bc7 | bellard | static inline void *advance (void *p, int incr) |
145 | 85571bc7 | bellard | { |
146 | 85571bc7 | bellard | uint8_t *d = p; |
147 | 85571bc7 | bellard | return (d + incr);
|
148 | 85571bc7 | bellard | } |
149 | 85571bc7 | bellard | |
150 | 1d14ffa9 | bellard | #ifdef __GNUC__
|
151 | 1d14ffa9 | bellard | #define audio_MIN(a, b) ( __extension__ ({ \
|
152 | 1d14ffa9 | bellard | __typeof (a) ta = a; \ |
153 | 1d14ffa9 | bellard | __typeof (b) tb = b; \ |
154 | 1d14ffa9 | bellard | ((ta)>(tb)?(tb):(ta)); \ |
155 | 1d14ffa9 | bellard | })) |
156 | 1d14ffa9 | bellard | |
157 | 1d14ffa9 | bellard | #define audio_MAX(a, b) ( __extension__ ({ \
|
158 | 1d14ffa9 | bellard | __typeof (a) ta = a; \ |
159 | 1d14ffa9 | bellard | __typeof (b) tb = b; \ |
160 | 1d14ffa9 | bellard | ((ta)<(tb)?(tb):(ta)); \ |
161 | 1d14ffa9 | bellard | })) |
162 | 1d14ffa9 | bellard | #else
|
163 | 85571bc7 | bellard | #define audio_MIN(a, b) ((a)>(b)?(b):(a))
|
164 | 85571bc7 | bellard | #define audio_MAX(a, b) ((a)<(b)?(b):(a))
|
165 | 1d14ffa9 | bellard | #endif
|
166 | 85571bc7 | bellard | |
167 | 295e390f | blueswir1 | int wav_start_capture (CaptureState *s, const char *path, int freq, |
168 | 295e390f | blueswir1 | int bits, int nchannels); |
169 | 295e390f | blueswir1 | |
170 | 85571bc7 | bellard | #endif /* audio.h */ |