VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/audio_int.h@ 2564

最後變更 在這個檔案從2564是 1636,由 vboxsync 提交於 18 年 前

warnings.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 7.7 KB
 
1/*
2 * QEMU Audio subsystem header
3 *
4 * Copyright (c) 2003-2005 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_INT_H
25#define QEMU_AUDIO_INT_H
26
27#ifdef CONFIG_COREAUDIO
28#ifndef VBOX
29#define FLOAT_MIXENG
30#else
31#undef FLOAT_MIXENG
32#endif
33/* #define RECIPROCAL */
34#endif
35
36#include <limits.h>
37#include "mixeng.h"
38
39#define qemu_malloc RTMemAlloc
40#define qemu_mallocz RTMemAllocZ
41#define qemu_free RTMemFree
42#define qemu_strdup RTStrDup
43
44struct audio_pcm_ops;
45
46typedef enum {
47 AUD_OPT_INT,
48 AUD_OPT_FMT,
49 AUD_OPT_STR,
50 AUD_OPT_BOOL
51} audio_option_tag_e;
52
53struct audio_option {
54 const char *name;
55 audio_option_tag_e tag;
56 void *valp;
57 const char *descr;
58 int *overridenp;
59 int overriden;
60};
61
62struct audio_callback {
63 void *opaque;
64 audio_callback_fn_t fn;
65};
66
67struct audio_pcm_info {
68 int bits;
69 int sign;
70 int freq;
71 int nchannels;
72 int align;
73 int shift;
74 int bytes_per_second;
75 int swap_endianness;
76};
77
78typedef struct SWVoiceCap SWVoiceCap;
79
80typedef struct HWVoiceOut {
81 int enabled;
82 int pending_disable;
83 struct audio_pcm_info info;
84
85 f_sample *clip;
86
87 int rpos;
88 uint64_t ts_helper;
89
90 st_sample_t *mix_buf;
91
92 int samples;
93 LIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head;
94 LIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head;
95 struct audio_pcm_ops *pcm_ops;
96 LIST_ENTRY (HWVoiceOut) entries;
97} HWVoiceOut;
98
99typedef struct HWVoiceIn {
100 int enabled;
101 struct audio_pcm_info info;
102
103 t_sample *conv;
104
105 int wpos;
106 int total_samples_captured;
107 uint64_t ts_helper;
108
109 st_sample_t *conv_buf;
110
111 int samples;
112 LIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head;
113 struct audio_pcm_ops *pcm_ops;
114 LIST_ENTRY (HWVoiceIn) entries;
115} HWVoiceIn;
116
117struct SWVoiceOut {
118 struct audio_pcm_info info;
119 t_sample *conv;
120 int64_t ratio;
121 st_sample_t *buf;
122 void *rate;
123 int total_hw_samples_mixed;
124 int active;
125 int empty;
126 HWVoiceOut *hw;
127 char *name;
128 volume_t vol;
129 struct audio_callback callback;
130 LIST_ENTRY (SWVoiceOut) entries;
131};
132
133struct SWVoiceIn {
134 int active;
135 struct audio_pcm_info info;
136 int64_t ratio;
137 void *rate;
138 int total_hw_samples_acquired;
139 st_sample_t *buf;
140 f_sample *clip;
141 HWVoiceIn *hw;
142 char *name;
143 volume_t vol;
144 struct audio_callback callback;
145 LIST_ENTRY (SWVoiceIn) entries;
146};
147
148struct audio_driver {
149 const char *name;
150 const char *descr;
151 struct audio_option *options;
152 void *(*init) (void);
153 void (*fini) (void *);
154 struct audio_pcm_ops *pcm_ops;
155 int can_be_default;
156 int max_voices_out;
157 int max_voices_in;
158 int voice_size_out;
159 int voice_size_in;
160};
161
162struct audio_pcm_ops {
163 int (*init_out)(HWVoiceOut *hw, audsettings_t *as);
164 void (*fini_out)(HWVoiceOut *hw);
165 int (*run_out) (HWVoiceOut *hw);
166 int (*write) (SWVoiceOut *sw, void *buf, int size);
167 int (*ctl_out) (HWVoiceOut *hw, int cmd, ...);
168
169 int (*init_in) (HWVoiceIn *hw, audsettings_t *as);
170 void (*fini_in) (HWVoiceIn *hw);
171 int (*run_in) (HWVoiceIn *hw);
172 int (*read) (SWVoiceIn *sw, void *buf, int size);
173 int (*ctl_in) (HWVoiceIn *hw, int cmd, ...);
174};
175
176struct capture_callback {
177 struct audio_capture_ops ops;
178 void *opaque;
179 LIST_ENTRY (capture_callback) entries;
180};
181
182struct CaptureVoiceOut {
183 HWVoiceOut hw;
184 void *buf;
185 LIST_HEAD (cb_listhead, capture_callback) cb_head;
186 LIST_ENTRY (CaptureVoiceOut) entries;
187};
188
189struct SWVoiceCap {
190 SWVoiceOut sw;
191 CaptureVoiceOut *cap;
192 LIST_ENTRY (SWVoiceCap) entries;
193};
194
195struct AudioState {
196 struct audio_driver *drv;
197 void *drv_opaque;
198
199 QEMUTimer *ts;
200 LIST_HEAD (card_listhead, QEMUSoundCard) card_head;
201 LIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in;
202 LIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out;
203 LIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
204 int nb_hw_voices_out;
205 int nb_hw_voices_in;
206 PPDMDRVINS pDrvIns;
207};
208
209extern struct audio_driver no_audio_driver;
210extern struct audio_driver oss_audio_driver;
211extern struct audio_driver sdl_audio_driver;
212extern struct audio_driver wav_audio_driver;
213extern struct audio_driver fmod_audio_driver;
214extern struct audio_driver alsa_audio_driver;
215extern struct audio_driver coreaudio_audio_driver;
216extern struct audio_driver dsound_audio_driver;
217extern volume_t nominal_volume;
218#ifdef VBOX
219extern volume_t pcm_out_volume;
220extern volume_t pcm_in_volume;
221#endif
222
223uint64_t audio_get_clock (void);
224uint64_t audio_get_ticks_per_sec (void);
225
226void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as);
227void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);
228
229int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int len);
230int audio_pcm_hw_get_live_in (HWVoiceIn *hw);
231
232int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int len);
233int audio_pcm_hw_get_live_out (HWVoiceOut *hw);
234int audio_pcm_hw_get_live_out2 (HWVoiceOut *hw, int *nb_live);
235
236int audio_bug (const char *funcname, int cond);
237void *audio_calloc (const char *funcname, int nmemb, size_t size);
238
239#define VOICE_ENABLE 1
240#define VOICE_DISABLE 2
241
242static inline int audio_ring_dist (int dst, int src, int len)
243{
244 return (dst >= src) ? (dst - src) : (len - src + dst);
245}
246
247#if defined __GNUC__ && !defined VBOX /* VBox: oh, please, just shut up. */
248#define GCC_ATTR __attribute__ ((__unused__, __format__ (__printf__, 1, 2)))
249#if __STDC_VERSION__ > 199901L
250#define INIT_FIELD(f) . f
251#else
252#define INIT_FIELD(f) /**/
253#endif
254#define GCC_FMT_ATTR(n, m) __attribute__ ((__format__ (__printf__, n, m)))
255#else
256#define GCC_ATTR /**/
257#define INIT_FIELD(f) /**/
258#define GCC_FMT_ATTR(n, m)
259#endif
260
261#ifndef VBOX
262static void GCC_ATTR dolog (const char *fmt, ...)
263#else
264DECLINLINE(void) GCC_ATTR dolog (const char *fmt, ...) /* shuts up unused warnings. */
265#endif
266{
267 va_list ap;
268
269 va_start (ap, fmt);
270 AUD_vlog (AUDIO_CAP, fmt, ap);
271 va_end (ap);
272}
273
274#ifdef DEBUG
275static void GCC_ATTR ldebug (const char *fmt, ...)
276{
277 va_list ap;
278
279 va_start (ap, fmt);
280 AUD_vlog (AUDIO_CAP, fmt, ap);
281 va_end (ap);
282}
283#else
284#if defined NDEBUG && defined __GNUC__
285#define ldebug(...)
286#elif defined NDEBUG && defined _MSC_VER
287#define ldebug __noop
288#else
289#ifndef VBOX
290static void GCC_ATTR ldebug (const char *fmt, ...)
291#else
292DECLINLINE(void) GCC_ATTR ldebug (const char *fmt, ...) /* shuts up unused warnings. */
293#endif
294{
295 (void) fmt;
296}
297#endif
298#endif
299
300#undef GCC_ATTR
301
302#define AUDIO_STRINGIFY_(n) #n
303#define AUDIO_STRINGIFY(n) AUDIO_STRINGIFY_(n)
304
305#if defined _MSC_VER || defined __GNUC__
306#define AUDIO_FUNC __FUNCTION__
307#else
308#define AUDIO_FUNC __FILE__ ":" AUDIO_STRINGIFY (__LINE__)
309#endif
310
311DECLCALLBACK(bool) sniffer_run_out (HWVoiceOut *hw, void *pvSamples,
312 unsigned cSamples);
313
314#endif /* audio_int.h */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette