VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/audio.h@ 5085

Last change on this file since 5085 was 5076, checked in by vboxsync, 17 years ago

Reverted the changes to load the ALSA code dynamically...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
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_H
25#define QEMU_AUDIO_H
26
27#include "sys-queue.h"
28
29#if defined __STDC_VERSION__ && __STDC_VERSION__ > 199901L
30#define FMTZ "z"
31#else
32#define FMTZ
33#endif
34
35typedef void (*audio_callback_fn_t) (void *opaque, int avail);
36
37typedef enum {
38 AUD_FMT_U8,
39 AUD_FMT_S8,
40 AUD_FMT_U16,
41 AUD_FMT_S16
42} audfmt_e;
43
44#define AUDIO_HOST_ENDIANNESS 0
45
46typedef struct {
47 int freq;
48 int nchannels;
49 audfmt_e fmt;
50 int endianness;
51} audsettings_t;
52
53typedef enum {
54 AUD_CNOTIFY_ENABLE,
55 AUD_CNOTIFY_DISABLE
56} audcnotification_e;
57
58typedef enum
59{
60 AUD_MIXER_VOLUME,
61 AUD_MIXER_PCM,
62 AUD_MIXER_LINE_IN
63} audmixerctl_t;
64
65typedef enum
66{
67 AUD_REC_MIC,
68 AUD_REC_CD,
69 AUD_REC_VIDEO,
70 AUD_REC_AUX,
71 AUD_REC_LINE_IN,
72 AUD_REC_PHONE
73} audrecsource_t;
74
75struct audio_capture_ops {
76 void (*notify) (void *opaque, audcnotification_e cmd);
77 void (*capture) (void *opaque, void *buf, int size);
78 void (*destroy) (void *opaque);
79};
80
81struct capture_ops {
82 void (*info) (void *opaque);
83 void (*destroy) (void *opaque);
84};
85
86typedef struct CaptureState {
87 void *opaque;
88 struct capture_ops ops;
89 LIST_ENTRY (CaptureState) entries;
90} CaptureState;
91
92typedef struct AudioState AudioState;
93typedef struct SWVoiceOut SWVoiceOut;
94typedef struct CaptureVoiceOut CaptureVoiceOut;
95typedef struct SWVoiceIn SWVoiceIn;
96
97typedef struct QEMUSoundCard {
98 AudioState *audio;
99 char *name;
100 LIST_ENTRY (QEMUSoundCard) entries;
101} QEMUSoundCard;
102
103typedef struct QEMUAudioTimeStamp {
104 uint64_t old_ts;
105} QEMUAudioTimeStamp;
106
107void AUD_vlog (const char *cap, const char *fmt, va_list ap);
108void AUD_log (const char *cap, const char *fmt, ...)
109#if defined (__GNUC__) && !defined (VBOX) /* VBox: oh, please, shut up. */
110 __attribute__ ((__format__ (__printf__, 2, 3)))
111#endif
112 ;
113
114void AUD_register_card (const char *name, QEMUSoundCard *card);
115void AUD_remove_card (QEMUSoundCard *card);
116
117CaptureVoiceOut *AUD_add_capture (
118 AudioState *s,
119 audsettings_t *as,
120 struct audio_capture_ops *ops,
121 void *opaque
122 );
123void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque);
124
125SWVoiceOut *AUD_open_out (
126 QEMUSoundCard *card,
127 SWVoiceOut *sw,
128 const char *name,
129 void *callback_opaque,
130 audio_callback_fn_t callback_fn,
131 audsettings_t *settings
132 );
133
134void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw);
135int AUD_write (SWVoiceOut *sw, void *pcm_buf, int size);
136int AUD_get_buffer_size_out (SWVoiceOut *sw);
137void AUD_set_active_out (SWVoiceOut *sw, int on);
138int AUD_is_active_out (SWVoiceOut *sw);
139
140void AUD_init_time_stamp_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
141uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
142
143SWVoiceIn *AUD_open_in (
144 QEMUSoundCard *card,
145 SWVoiceIn *sw,
146 const char *name,
147 void *callback_opaque,
148 audio_callback_fn_t callback_fn,
149 audsettings_t *settings
150 );
151
152void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw);
153int AUD_read (SWVoiceIn *sw, void *pcm_buf, int size);
154void AUD_set_active_in (SWVoiceIn *sw, int on);
155int AUD_is_active_in (SWVoiceIn *sw);
156
157void AUD_init_time_stamp_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
158uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
159
160void AUD_set_volume_out (SWVoiceOut *po, int mute, uint8_t lvol, uint8_t rvol);
161void AUD_set_volume (audmixerctl_t mt, int *mute, uint8_t *lvol, uint8_t *rvol);
162void AUD_set_record_source (audrecsource_t *ars, audrecsource_t *als);
163
164int AUD_init_null(void);
165
166static inline void *advance (void *p, int incr)
167{
168#ifndef VBOX
169 uint8_t *d = p;
170#else
171 uint8_t *d = (uint8_t*)p;
172#endif
173 return (d + incr);
174}
175
176uint32_t popcount (uint32_t u);
177uint32_t lsbindex (uint32_t u);
178
179#ifdef __GNUC__
180#define audio_MIN(a, b) ( __extension__ ({ \
181 __typeof (a) ta = a; \
182 __typeof (b) tb = b; \
183 ((ta)>(tb)?(tb):(ta)); \
184 }))
185
186#define audio_MAX(a, b) ( __extension__ ({ \
187 __typeof (a) ta = a; \
188 __typeof (b) tb = b; \
189 ((ta)<(tb)?(tb):(ta)); \
190 }))
191#else
192#define audio_MIN(a, b) ((a)>(b)?(b):(a))
193#define audio_MAX(a, b) ((a)<(b)?(b):(a))
194#endif
195
196#endif /* audio.h */
Note: See TracBrowser for help on using the repository browser.

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