VirtualBox

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

Last change on this file since 9074 was 6140, checked in by vboxsync, 17 years ago

Pass the VM name to the audio driver. PulseAudio will name the name of the stream according to that name.

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