VirtualBox

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

Last change on this file since 5063 was 5050, checked in by vboxsync, 17 years ago

Moved the ALSA code into a separate shared object loaded at runtime

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