1 | /** @file
|
---|
2 | * PDM - Pluggable Device Manager, audio interfaces.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2015 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___VBox_vmm_pdmaudioifs_h
|
---|
27 | #define ___VBox_vmm_pdmaudioifs_h
|
---|
28 |
|
---|
29 | #include <VBox/types.h>
|
---|
30 | #include <iprt/list.h>
|
---|
31 |
|
---|
32 | typedef struct
|
---|
33 | {
|
---|
34 | int mute;
|
---|
35 | uint32_t r;
|
---|
36 | uint32_t l;
|
---|
37 | } volume_t;
|
---|
38 |
|
---|
39 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
40 | typedef uint32_t PDMAUDIODRVFLAGS;
|
---|
41 |
|
---|
42 | /** No flags set. */
|
---|
43 | #define PDMAUDIODRVFLAG_NONE 0
|
---|
44 | /** Marks a primary audio driver which is critical
|
---|
45 | * when running the VM. */
|
---|
46 | #define PDMAUDIODRVFLAG_PRIMARY RT_BIT(0)
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Audio format in signed or unsigned variants.
|
---|
50 | */
|
---|
51 | typedef enum PDMAUDIOFMT
|
---|
52 | {
|
---|
53 | AUD_FMT_INVALID,
|
---|
54 | AUD_FMT_U8,
|
---|
55 | AUD_FMT_S8,
|
---|
56 | AUD_FMT_U16,
|
---|
57 | AUD_FMT_S16,
|
---|
58 | AUD_FMT_U32,
|
---|
59 | AUD_FMT_S32,
|
---|
60 | /** Hack to blow the type up to 32-bit. */
|
---|
61 | AUD_FMT_32BIT_HACK = 0x7fffffff
|
---|
62 | } PDMAUDIOFMT;
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * Audio configuration of a certain backend.
|
---|
67 | */
|
---|
68 | typedef struct PDMAUDIOBACKENDCFG
|
---|
69 | {
|
---|
70 | size_t cbStreamOut;
|
---|
71 | size_t cbStreamIn;
|
---|
72 | uint32_t cMaxHstStrmsOut;
|
---|
73 | uint32_t cMaxHstStrmsIn;
|
---|
74 | } PDMAUDIOBACKENDCFG, *PPDMAUDIOBACKENDCFG;
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * An audio sample. At the moment stereo (left + right channels) only.
|
---|
78 | * @todo Replace this with a more generic union
|
---|
79 | * which then also could handle 2.1 or 5.1 sound.
|
---|
80 | */
|
---|
81 | typedef struct PDMAUDIOSAMPLE
|
---|
82 | {
|
---|
83 | int64_t u64LSample;
|
---|
84 | int64_t u64RSample;
|
---|
85 | } PDMAUDIOSAMPLE, *PPDMAUDIOSAMPLE;
|
---|
86 |
|
---|
87 | typedef enum PDMAUDIOENDIANESS
|
---|
88 | {
|
---|
89 | /** The usual invalid endian. */
|
---|
90 | PDMAUDIOENDIANESS_INVALID,
|
---|
91 | /** Little endian. */
|
---|
92 | PDMAUDIOENDIANESS_LITTLE,
|
---|
93 | /** Bit endian. */
|
---|
94 | PDMAUDIOENDIANESS_BIG,
|
---|
95 | /** Endianness doesn't have a meaning in the context. */
|
---|
96 | PDMAUDIOENDIANESS_NA,
|
---|
97 | /** The end of the valid endian values (exclusive). */
|
---|
98 | PDMAUDIOENDIANESS_END,
|
---|
99 | /** Hack to blow the type up to 32-bit. */
|
---|
100 | PDMAUDIOENDIANESS_32BIT_HACK = 0x7fffffff
|
---|
101 | } PDMAUDIOENDIANESS;
|
---|
102 |
|
---|
103 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
104 | typedef struct PDMAUDIOSTREAMCFG
|
---|
105 | {
|
---|
106 | /** Frequency in Hertz (Hz). */
|
---|
107 | uint32_t uHz;
|
---|
108 | /** Number of channels (2 for stereo). */
|
---|
109 | uint8_t cChannels;
|
---|
110 | /** Audio format. */
|
---|
111 | PDMAUDIOFMT enmFormat;
|
---|
112 | /** @todo Use RT_LE2H_*? */
|
---|
113 | PDMAUDIOENDIANESS enmEndianness;
|
---|
114 | } PDMAUDIOSTREAMCFG, *PPDMAUDIOSTREAMCFG;
|
---|
115 | #endif
|
---|
116 |
|
---|
117 | #if defined(RT_LITTLE_ENDIAN)
|
---|
118 | # define PDMAUDIOHOSTENDIANESS PDMAUDIOENDIANESS_LITTLE
|
---|
119 | #elif defined(RT_BIG_ENDIAN)
|
---|
120 | # define PDMAUDIOHOSTENDIANESS PDMAUDIOENDIANESS_BIG
|
---|
121 | #else
|
---|
122 | # error "Port me!"
|
---|
123 | #endif
|
---|
124 |
|
---|
125 | typedef enum PDMAUDIODIR
|
---|
126 | {
|
---|
127 | PDMAUDIODIR_UNKNOWN = 0,
|
---|
128 | PDMAUDIODIR_IN = 1,
|
---|
129 | PDMAUDIODIR_OUT = 2,
|
---|
130 | PDMAUDIODIR_BOTH = 3
|
---|
131 | } PDMAUDIODIR;
|
---|
132 |
|
---|
133 | typedef enum PDMAUDIOMIXERCTL
|
---|
134 | {
|
---|
135 | PDMAUDIOMIXERCTL_UNKNOWN = 0,
|
---|
136 | PDMAUDIOMIXERCTL_VOLUME,
|
---|
137 | PDMAUDIOMIXERCTL_PCM,
|
---|
138 | PDMAUDIOMIXERCTL_LINE_IN,
|
---|
139 | /** Hack to blow the type up to 32-bit. */
|
---|
140 | PDMAUDIOMIXERCTL_32BIT_HACK = 0x7fffffff
|
---|
141 | } PDMAUDIOMIXERCTL;
|
---|
142 |
|
---|
143 | typedef enum PDMAUDIORECSOURCE
|
---|
144 | {
|
---|
145 | PDMAUDIORECSOURCE_UNKNOWN = 0,
|
---|
146 | PDMAUDIORECSOURCE_MIC,
|
---|
147 | PDMAUDIORECSOURCE_CD,
|
---|
148 | PDMAUDIORECSOURCE_VIDEO,
|
---|
149 | PDMAUDIORECSOURCE_AUX,
|
---|
150 | PDMAUDIORECSOURCE_LINE_IN,
|
---|
151 | PDMAUDIORECSOURCE_PHONE,
|
---|
152 | /** Hack to blow the type up to 32-bit. */
|
---|
153 | PDMAUDIORECSOURCE_32BIT_HACK = 0x7fffffff
|
---|
154 | } PDMAUDIORECSOURCE;
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * Audio stream commands. Used in the audio connector
|
---|
158 | * as well as in the actual host backends.
|
---|
159 | */
|
---|
160 | typedef enum PDMAUDIOSTREAMCMD
|
---|
161 | {
|
---|
162 | /** Unknown command, do not use. */
|
---|
163 | PDMAUDIOSTREAMCMD_UNKNOWN = 0,
|
---|
164 | /** Enables the stream. */
|
---|
165 | PDMAUDIOSTREAMCMD_ENABLE,
|
---|
166 | /** Disables the stream. */
|
---|
167 | PDMAUDIOSTREAMCMD_DISABLE,
|
---|
168 | /** Hack to blow the type up to 32-bit. */
|
---|
169 | PDMAUDIOSTREAMCMD_32BIT_HACK = 0x7fffffff
|
---|
170 | } PDMAUDIOSTREAMCMD;
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * Properties of audio streams for host/guest
|
---|
174 | * for in or out directions.
|
---|
175 | */
|
---|
176 | typedef struct PDMPCMPROPS
|
---|
177 | {
|
---|
178 | /** Sample width. Bits per sample. */
|
---|
179 | uint8_t cBits;
|
---|
180 | /** Signed or unsigned sample. */
|
---|
181 | bool fSigned;
|
---|
182 | /** Shift count used for faster calculation of various
|
---|
183 | * values, such as the alignment, bytes to samples and so on.
|
---|
184 | * Depends on number of stream channels and the stream format
|
---|
185 | * being used.
|
---|
186 | *
|
---|
187 | ** @todo Use some RTAsmXXX functions instead?
|
---|
188 | */
|
---|
189 | uint8_t cShift;
|
---|
190 | /** Number of audio channels. */
|
---|
191 | uint8_t cChannels;
|
---|
192 | /** Alignment mask. */
|
---|
193 | uint32_t uAlign;
|
---|
194 | /** Sample frequency in Hertz (Hz). */
|
---|
195 | uint32_t uHz;
|
---|
196 | /** Bandwidth (bytes/s). */
|
---|
197 | uint32_t cbPerSec;
|
---|
198 | /** Whether the endianess is swapped or not. */
|
---|
199 | bool fSwapEndian;
|
---|
200 | } PDMPCMPROPS, *PPDMPCMPROPS;
|
---|
201 |
|
---|
202 | /**
|
---|
203 | * Structure for holding rate processing information
|
---|
204 | * of a source + destination audio stream. This is needed
|
---|
205 | * because both streams can differ regarding their rates
|
---|
206 | * and therefore need to be treated accordingly.
|
---|
207 | */
|
---|
208 | typedef struct PDMAUDIOSTRMRATE
|
---|
209 | {
|
---|
210 | /** Current (absolute) offset in the output
|
---|
211 | * (destination) stream. */
|
---|
212 | uint64_t dstOffset;
|
---|
213 | /** Increment for moving dstOffset for the
|
---|
214 | * destination stream. This is needed because the
|
---|
215 | * source <-> destination rate might be different. */
|
---|
216 | uint64_t dstInc;
|
---|
217 | /** Current (absolute) offset in the input
|
---|
218 | * stream. */
|
---|
219 | uint32_t srcOffset;
|
---|
220 | /** Last processed sample of the input stream.
|
---|
221 | * Needed for interpolation. */
|
---|
222 | PDMAUDIOSAMPLE srcSampleLast;
|
---|
223 | } PDMAUDIOSTRMRATE, *PPDMAUDIOSTRMRATE;
|
---|
224 |
|
---|
225 | /**
|
---|
226 | * Note: All internal handling is done in samples,
|
---|
227 | * not in bytes!
|
---|
228 | */
|
---|
229 | typedef uint32_t PDMAUDIOMIXBUFFMT;
|
---|
230 | typedef PDMAUDIOMIXBUFFMT *PPDMAUDIOMIXBUFFMT;
|
---|
231 |
|
---|
232 | typedef struct PDMAUDIOMIXBUF *PPDMAUDIOMIXBUF;
|
---|
233 | typedef struct PDMAUDIOMIXBUF
|
---|
234 | {
|
---|
235 | RTLISTNODE Node;
|
---|
236 | /** Name of the buffer. */
|
---|
237 | char *pszName;
|
---|
238 | /** Sample buffer. */
|
---|
239 | PPDMAUDIOSAMPLE pSamples;
|
---|
240 | /** Size of the sample buffer (in samples). */
|
---|
241 | uint32_t cSamples;
|
---|
242 | /** The current read/write position (in samples)
|
---|
243 | * in the samples buffer. */
|
---|
244 | uint32_t offReadWrite;
|
---|
245 | /** Total samples already mixed down to the
|
---|
246 | * parent buffer (if any). Always starting at
|
---|
247 | * the parent's offReadWrite position.
|
---|
248 | * Note: Count always is specified in parent samples,
|
---|
249 | * as the sample count can differ between parent
|
---|
250 | * and child. */
|
---|
251 | uint32_t cMixed;
|
---|
252 | uint32_t cProcessed;
|
---|
253 | /** Pointer to parent buffer (if any). */
|
---|
254 | PPDMAUDIOMIXBUF pParent;
|
---|
255 | /** List of children mix buffers to keep
|
---|
256 | * in sync with (if being a parent buffer). */
|
---|
257 | RTLISTANCHOR lstBuffers;
|
---|
258 | /** Intermediate structure for buffer
|
---|
259 | * conversion tasks. */
|
---|
260 | PPDMAUDIOSTRMRATE pRate;
|
---|
261 | /** This buffer's audio format. */
|
---|
262 | PDMAUDIOMIXBUFFMT AudioFmt;
|
---|
263 | /**
|
---|
264 | * Ratio of the associated parent stream's frequency by this stream's
|
---|
265 | * frequency (1<<32), represented as a signed 64 bit integer.
|
---|
266 | *
|
---|
267 | * For example, if the parent stream has a frequency of 44 khZ, and this
|
---|
268 | * stream has a frequency of 11 kHz, the ration then would be
|
---|
269 | * (44/11 * (1 << 32)).
|
---|
270 | *
|
---|
271 | * Currently this does not get changed once assigned.
|
---|
272 | */
|
---|
273 | int64_t iFreqRatio;
|
---|
274 | /* For quickly converting samples <-> bytes and
|
---|
275 | * vice versa. */
|
---|
276 | uint8_t cShift;
|
---|
277 | } PDMAUDIOMIXBUF;
|
---|
278 |
|
---|
279 | /**
|
---|
280 | * Represents an audio input on the host of a certain
|
---|
281 | * backend (e.g. DirectSound, PulseAudio etc).
|
---|
282 | *
|
---|
283 | * One host audio input is assigned to exactly one parent
|
---|
284 | * guest input stream.
|
---|
285 | */
|
---|
286 | struct PDMAUDIOGSTSTRMIN;
|
---|
287 | typedef PDMAUDIOGSTSTRMIN *PPDMAUDIOGSTSTRMIN;
|
---|
288 |
|
---|
289 | typedef struct PDMAUDIOHSTSTRMIN
|
---|
290 | {
|
---|
291 | /** List node. */
|
---|
292 | RTLISTNODE Node;
|
---|
293 | /** PCM properties. */
|
---|
294 | PDMPCMPROPS Props;
|
---|
295 | /** Whether this input is enabled or not. */
|
---|
296 | bool fEnabled;
|
---|
297 | /** This stream's mixing buffer. */
|
---|
298 | PDMAUDIOMIXBUF MixBuf;
|
---|
299 | /** Pointer to (parent) guest stream. */
|
---|
300 | PPDMAUDIOGSTSTRMIN pGstStrmIn;
|
---|
301 | } PDMAUDIOHSTSTRMIN, *PPDMAUDIOHSTSTRMIN;
|
---|
302 |
|
---|
303 | /*
|
---|
304 | * Represents an audio output on the host through a certain
|
---|
305 | * backend (e.g. DirectSound, PulseAudio etc).
|
---|
306 | *
|
---|
307 | * One host audio output can have multiple (1:N) guest outputs
|
---|
308 | * assigned.
|
---|
309 | */
|
---|
310 | typedef struct PDMAUDIOHSTSTRMOUT
|
---|
311 | {
|
---|
312 | /** List node. */
|
---|
313 | RTLISTNODE Node;
|
---|
314 | /** Stream properites. */
|
---|
315 | PDMPCMPROPS Props;
|
---|
316 | /** Enabled or disabled flag. */
|
---|
317 | bool fEnabled;
|
---|
318 | /** Whether this stream was marked as being disabled
|
---|
319 | * but there are still associated guest output streams
|
---|
320 | * which rely on its data. */
|
---|
321 | bool fPendingDisable;
|
---|
322 | /** This stream's mixing buffer. */
|
---|
323 | PDMAUDIOMIXBUF MixBuf;
|
---|
324 | /** Associated guest output streams. */
|
---|
325 | RTLISTANCHOR lstGstStrmOut;
|
---|
326 | } PDMAUDIOHSTSTRMOUT, *PPDMAUDIOHSTSTRMOUT;
|
---|
327 |
|
---|
328 | /**
|
---|
329 | * Guest audio stream state.
|
---|
330 | */
|
---|
331 | typedef struct PDMAUDIOGSTSTRMSTATE
|
---|
332 | {
|
---|
333 | /** Guest audio out stream active or not. */
|
---|
334 | bool fActive;
|
---|
335 | /** Guest audio output stream has some samples or not. */
|
---|
336 | bool fEmpty;
|
---|
337 | /** Set to @c true if this stream is muted, @c false if not. */
|
---|
338 | bool fMuted;
|
---|
339 | /** Name of this stream. */
|
---|
340 | char *pszName;
|
---|
341 | /** Left channel volume. */
|
---|
342 | uint32_t uVolumeLeft;
|
---|
343 | /** Right channel volume. */
|
---|
344 | uint32_t uVolumeRight;
|
---|
345 | } PDMAUDIOGSTSTRMSTATE, *PPDMAUDIOGSTSTRMSTATE;
|
---|
346 |
|
---|
347 | /**
|
---|
348 | * Represents an audio input from the guest (that is, from the
|
---|
349 | * emulated device, e.g. Intel HDA).
|
---|
350 | *
|
---|
351 | * Each guest input can have multiple host input streams.
|
---|
352 | */
|
---|
353 | typedef struct PDMAUDIOGSTSTRMIN
|
---|
354 | {
|
---|
355 | /** Guest stream properites. */
|
---|
356 | PDMPCMPROPS Props;
|
---|
357 | /** Current stream state. */
|
---|
358 | PDMAUDIOGSTSTRMSTATE State;
|
---|
359 | /** This stream's mixing buffer. */
|
---|
360 | PDMAUDIOMIXBUF MixBuf;
|
---|
361 | /** Pointer to associated host input stream. */
|
---|
362 | PPDMAUDIOHSTSTRMIN pHstStrmIn;
|
---|
363 | } PDMAUDIOGSTSTRMIN, *PPDMAUDIOGSTSTRMIN;
|
---|
364 |
|
---|
365 | /**
|
---|
366 | * Represents an audio output from the guest (that is, from the
|
---|
367 | * emulated device, e.g. Intel HDA).
|
---|
368 | *
|
---|
369 | * Each guest output is assigned to a single host output.
|
---|
370 | */
|
---|
371 | typedef struct PDMAUDIOGSTSTRMOUT
|
---|
372 | {
|
---|
373 | /** List node. */
|
---|
374 | RTLISTNODE Node;
|
---|
375 | /** Guest output stream properites. */
|
---|
376 | PDMPCMPROPS Props;
|
---|
377 | /** Current stream state. */
|
---|
378 | PDMAUDIOGSTSTRMSTATE State;
|
---|
379 | /** This stream's mixing buffer. */
|
---|
380 | PDMAUDIOMIXBUF MixBuf;
|
---|
381 | /** Pointer to the associated host output stream. */
|
---|
382 | PPDMAUDIOHSTSTRMOUT pHstStrmOut;
|
---|
383 | } PDMAUDIOGSTSTRMOUT, *PPDMAUDIOGSTSTRMOUT;
|
---|
384 |
|
---|
385 | #ifdef VBOX_WITH_PDM_AUDIO_DRIVER
|
---|
386 |
|
---|
387 | /** Pointer to a audio connector interface. */
|
---|
388 | typedef struct PDMIAUDIOCONNECTOR *PPDMIAUDIOCONNECTOR;
|
---|
389 | /**
|
---|
390 | * Audio connector interface (up).
|
---|
391 | */
|
---|
392 | typedef struct PDMIAUDIOCONNECTOR
|
---|
393 | {
|
---|
394 | DECLR3CALLBACKMEMBER(int, pfnQueryStatus, (PPDMIAUDIOCONNECTOR pInterface, uint32_t *pcbAvailIn, uint32_t *pcbFreeOut, uint32_t *pcSamplesLive));
|
---|
395 |
|
---|
396 | /**
|
---|
397 | * Reads PCM audio data from the host (input).
|
---|
398 | *
|
---|
399 | * @returns VBox status code.
|
---|
400 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
401 | * @param pGstStrmIn Pointer to guest input stream to write to.
|
---|
402 | * @param pvBuf Where to store the read data.
|
---|
403 | * @param cbSize Number of bytes to read.
|
---|
404 | * @param pcbRead Bytes of audio data read. Optional.
|
---|
405 | */
|
---|
406 | DECLR3CALLBACKMEMBER(int, pfnRead, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMIN pGstStrmIn, void *pvBuf, size_t cbSize, uint32_t *pcbRead));
|
---|
407 |
|
---|
408 | /**
|
---|
409 | * Writes PCM audio data to the host (output).
|
---|
410 | *
|
---|
411 | * @returns VBox status code.
|
---|
412 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
413 | * @param pGstStrmOut Pointer to guest output stream to read from.
|
---|
414 | * @param pvBuf Audio data to be written.
|
---|
415 | * @param cbSize Number of bytes to be written.
|
---|
416 | * @param pcbWritten Bytes of audio data written. Optional.
|
---|
417 | */
|
---|
418 | DECLR3CALLBACKMEMBER(int, pfnWrite, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut, const void *pvBuf, size_t cbSize, uint32_t *pcbWritten));
|
---|
419 |
|
---|
420 | /**
|
---|
421 | * Checks whether the specified guest input stream is in a working state.
|
---|
422 | *
|
---|
423 | * @returns True if a host voice in is available, false if not.
|
---|
424 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
425 | * @param pGstStrmIn Pointer to guest input stream to check.
|
---|
426 | */
|
---|
427 | DECLR3CALLBACKMEMBER(bool, pfnIsInputOK, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMIN pGstStrmIn));
|
---|
428 |
|
---|
429 | /**
|
---|
430 | * Checks whether the specified guest output stream is in a working state.
|
---|
431 | *
|
---|
432 | * @returns True if a host voice out is available, false if not.
|
---|
433 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
434 | * @param pGstStrmOut Pointer to guest output stream to check.
|
---|
435 | */
|
---|
436 | DECLR3CALLBACKMEMBER(bool, pfnIsOutputOK, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut));
|
---|
437 |
|
---|
438 | /**
|
---|
439 | * Initializes the NULL audio driver as a fallback in case no host backend is available.
|
---|
440 | *
|
---|
441 | * @returns VBox status code.
|
---|
442 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
443 | */
|
---|
444 | DECLR3CALLBACKMEMBER(int, pfnInitNull, (PPDMIAUDIOCONNECTOR pInterface));
|
---|
445 |
|
---|
446 | /**
|
---|
447 | * Sets the audio volume of a specific guest output stream.
|
---|
448 | *
|
---|
449 | * @returns VBox status code.
|
---|
450 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
451 | * @param pGstStrmOut Pointer to guest output stream.
|
---|
452 | * @param fMute Whether to mute or not.
|
---|
453 | * @param uVolLeft Left audio stream volume.
|
---|
454 | * @param uVolRight Right audio stream volume.
|
---|
455 | */
|
---|
456 | DECLR3CALLBACKMEMBER(int, pfnSetVolumeOut, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut,
|
---|
457 | bool fMute, uint8_t uVolLeft, uint8_t uVolRight));
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Sets the overall audio volume.
|
---|
461 | *
|
---|
462 | * @returns VBox status code.
|
---|
463 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
464 | * @param fMute Whether to mute or not.
|
---|
465 | * @param uVolLeft Left audio stream volume.
|
---|
466 | * @param uVolRight Right audio stream volume.
|
---|
467 | */
|
---|
468 | DECLR3CALLBACKMEMBER(int, pfnSetVolume, (PPDMIAUDIOCONNECTOR pInterface,
|
---|
469 | bool fMute, uint8_t uVolLeft, uint8_t uVolRight));
|
---|
470 |
|
---|
471 | /**
|
---|
472 | * Enables a specific guest output stream and starts the audio device.
|
---|
473 | *
|
---|
474 | * @returns VBox status code.
|
---|
475 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
476 | * @param pGstStrmOut Pointer to guest output stream.
|
---|
477 | * @param fEnable Whether to enable or disable the specified output stream.
|
---|
478 | */
|
---|
479 | DECLR3CALLBACKMEMBER(int, pfnEnableOut, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut, bool fEnable));
|
---|
480 |
|
---|
481 | /**
|
---|
482 | * Enables a specific guest input stream and starts the audio device.
|
---|
483 | *
|
---|
484 | * @returns VBox status code.
|
---|
485 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
486 | * @param pGstStrmIn Pointer to guest input stream.
|
---|
487 | * @param fEnable Whether to enable or disable the specified input stream.
|
---|
488 | */
|
---|
489 | DECLR3CALLBACKMEMBER(int, pfnEnableIn, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMIN pGstStrmIn, bool fEnable));
|
---|
490 |
|
---|
491 | /**
|
---|
492 | * Closes a specific guest input stream.
|
---|
493 | *
|
---|
494 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
495 | * @param pGstStrmIn Pointer to guest input stream.
|
---|
496 | */
|
---|
497 | DECLR3CALLBACKMEMBER(void, pfnCloseIn, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMIN pGstStrmIn));
|
---|
498 |
|
---|
499 | /**
|
---|
500 | * Closes a specific guest output stream.
|
---|
501 | *
|
---|
502 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
503 | * @param pGstStrmOut Pointer to guest output stream.
|
---|
504 | */
|
---|
505 | DECLR3CALLBACKMEMBER(void, pfnCloseOut, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut));
|
---|
506 |
|
---|
507 | /**
|
---|
508 | * Opens an input audio channel.
|
---|
509 | *
|
---|
510 | * @returns VBox status code.
|
---|
511 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
512 | * @param pszName Name of the audio channel.
|
---|
513 | * @param enmRecSource Specifies the type of recording source to be opened.
|
---|
514 | * @param pCfg Pointer to PDMAUDIOSTREAMCFG to use.
|
---|
515 | * @param ppGstStrmIn Pointer where to return the guest guest input stream on success.
|
---|
516 | */
|
---|
517 | DECLR3CALLBACKMEMBER(int, pfnOpenIn, (PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
|
---|
518 | PDMAUDIORECSOURCE enmRecSource, PPDMAUDIOSTREAMCFG pCfg,
|
---|
519 | PPDMAUDIOGSTSTRMIN *ppGstStrmIn));
|
---|
520 |
|
---|
521 | /**
|
---|
522 | * Opens an output audio channel.
|
---|
523 | *
|
---|
524 | * @returns VBox status code.
|
---|
525 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
526 | * @param pszName Name of the audio channel.
|
---|
527 | * @param pCfg Pointer to PDMAUDIOSTREAMCFG to use.
|
---|
528 | * @param ppGstStrmOut Pointer where to return the guest guest input stream on success.
|
---|
529 | */
|
---|
530 | DECLR3CALLBACKMEMBER(int, pfnOpenOut, (PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
|
---|
531 | PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOGSTSTRMOUT *ppGstStrmOut));
|
---|
532 |
|
---|
533 | DECLR3CALLBACKMEMBER(int, pfnPlayOut, (PPDMIAUDIOCONNECTOR pInterface, uint32_t *pcSamplesPlayed));
|
---|
534 |
|
---|
535 | /**
|
---|
536 | * Checks whether a specific guest input stream is active or not.
|
---|
537 | *
|
---|
538 | * @returns Whether the specified stream is active or not.
|
---|
539 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
540 | * @param pGstStrmIn Pointer to guest input stream.
|
---|
541 | */
|
---|
542 | DECLR3CALLBACKMEMBER(bool, pfnIsActiveIn, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMIN pGstStrmIn));
|
---|
543 |
|
---|
544 | /**
|
---|
545 | * Checks whether a specific guest output stream is active or not.
|
---|
546 | *
|
---|
547 | * @returns Whether the specified stream is active or not.
|
---|
548 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
549 | * @param pGstStrmOut Pointer to guest output stream.
|
---|
550 | */
|
---|
551 | DECLR3CALLBACKMEMBER(bool, pfnIsActiveOut, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut));
|
---|
552 |
|
---|
553 | } PDMIAUDIOCONNECTOR;
|
---|
554 |
|
---|
555 | /** PDMIAUDIOCONNECTOR interface ID. */
|
---|
556 | #define PDMIAUDIOCONNECTOR_IID "a41ca770-ed07-4f57-a0a6-41377d9d484f"
|
---|
557 |
|
---|
558 | /** Defines all needed interface callbacks for an audio backend. */
|
---|
559 | #define PDMAUDIO_IHOSTAUDIO_CALLBACKS(_aDrvName) \
|
---|
560 | pThis->IHostAudio.pfnCaptureIn = _aDrvName##CaptureIn; \
|
---|
561 | pThis->IHostAudio.pfnControlIn = _aDrvName##ControlIn; \
|
---|
562 | pThis->IHostAudio.pfnControlOut = _aDrvName##ControlOut; \
|
---|
563 | pThis->IHostAudio.pfnFiniIn = _aDrvName##FiniIn; \
|
---|
564 | pThis->IHostAudio.pfnFiniOut = _aDrvName##FiniOut; \
|
---|
565 | pThis->IHostAudio.pfnGetConf = _aDrvName##GetConf; \
|
---|
566 | pThis->IHostAudio.pfnInit = _aDrvName##Init; \
|
---|
567 | pThis->IHostAudio.pfnInitIn = _aDrvName##InitIn; \
|
---|
568 | pThis->IHostAudio.pfnInitOut = _aDrvName##InitOut; \
|
---|
569 | pThis->IHostAudio.pfnIsEnabled = _aDrvName##IsEnabled; \
|
---|
570 | pThis->IHostAudio.pfnPlayOut = _aDrvName##PlayOut; \
|
---|
571 | pThis->IHostAudio.pfnShutdown = _aDrvName##Shutdown;
|
---|
572 |
|
---|
573 | /** Pointer to a host audio interface. */
|
---|
574 | typedef struct PDMIHOSTAUDIO *PPDMIHOSTAUDIO;
|
---|
575 | /**
|
---|
576 | * PDM host audio interface.
|
---|
577 | */
|
---|
578 | typedef struct PDMIHOSTAUDIO
|
---|
579 | {
|
---|
580 | /**
|
---|
581 | * Initialize the host-specific audio device.
|
---|
582 | *
|
---|
583 | * @returns VBox status code.
|
---|
584 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
585 | */
|
---|
586 | DECLR3CALLBACKMEMBER(int, pfnInit, (PPDMIHOSTAUDIO pInterface));
|
---|
587 |
|
---|
588 | /**
|
---|
589 | * Shuts down the host-specific audio device.
|
---|
590 | *
|
---|
591 | * @returns VBox status code.
|
---|
592 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
593 | */
|
---|
594 | DECLR3CALLBACKMEMBER(void, pfnShutdown, (PPDMIHOSTAUDIO pInterface));
|
---|
595 |
|
---|
596 | /**
|
---|
597 | * Initialize the host-specific audio device for input stream.
|
---|
598 | *
|
---|
599 | * @returns VBox status code.
|
---|
600 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
601 | * @param pHstStrmIn Pointer to host input stream.
|
---|
602 | * @param pStreamCfg Pointer to stream configuration.
|
---|
603 | * @param enmRecSource Specifies the type of recording source to be initialized.
|
---|
604 | * @param pcSamples Returns how many samples the backend can handle. Optional.
|
---|
605 | */
|
---|
606 | DECLR3CALLBACKMEMBER(int, pfnInitIn, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMIN pHstStrmIn, PPDMAUDIOSTREAMCFG pStreamCfg, PDMAUDIORECSOURCE enmRecSource, uint32_t *pcSamples));
|
---|
607 |
|
---|
608 | /**
|
---|
609 | * Initialize the host-specific output device for output stream.
|
---|
610 | *
|
---|
611 | * @returns VBox status code.
|
---|
612 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
613 | * @param pHstStrmOut Pointer to host output stream.
|
---|
614 | * @param pStreamCfg Pointer to stream configuration.
|
---|
615 | * @param pcSamples Returns how many samples the backend can handle. Optional.
|
---|
616 | */
|
---|
617 | DECLR3CALLBACKMEMBER(int, pfnInitOut, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMOUT pHstStrmOut, PPDMAUDIOSTREAMCFG pStreamCfg, uint32_t *pcSamples));
|
---|
618 |
|
---|
619 | /**
|
---|
620 | * Control the host audio device for an input stream.
|
---|
621 | *
|
---|
622 | * @returns VBox status code.
|
---|
623 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
624 | * @param pHstStrmOut Pointer to host output stream.
|
---|
625 | * @param enmStreamCmd The stream command to issue.
|
---|
626 | */
|
---|
627 | DECLR3CALLBACKMEMBER(int, pfnControlOut, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMOUT pHstStrmOut, PDMAUDIOSTREAMCMD enmStreamCmd));
|
---|
628 |
|
---|
629 | /**
|
---|
630 | * Control the host audio device for an output stream.
|
---|
631 | *
|
---|
632 | * @returns VBox status code.
|
---|
633 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
634 | * @param pHstStrmOut Pointer to host output stream.
|
---|
635 | * @param enmStreamCmd The stream command to issue.
|
---|
636 | */
|
---|
637 | DECLR3CALLBACKMEMBER(int, pfnControlIn, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMIN pHstStrmIn, PDMAUDIOSTREAMCMD enmStreamCmd));
|
---|
638 |
|
---|
639 | /**
|
---|
640 | * Ends the host audio input streamm.
|
---|
641 | *
|
---|
642 | * @returns VBox status code.
|
---|
643 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
644 | * @param pHstStrmIn Pointer to host input stream.
|
---|
645 | */
|
---|
646 | DECLR3CALLBACKMEMBER(int, pfnFiniIn, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMIN pHstStrmIn));
|
---|
647 |
|
---|
648 | /**
|
---|
649 | * Ends the host output stream.
|
---|
650 | *
|
---|
651 | * @returns VBox status code.
|
---|
652 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
653 | * @param pHstStrmOut Pointer to host output stream.
|
---|
654 | */
|
---|
655 | DECLR3CALLBACKMEMBER(int, pfnFiniOut, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMOUT pHstStrmOut));
|
---|
656 |
|
---|
657 | DECLR3CALLBACKMEMBER(bool, pfnIsEnabled, (PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir));
|
---|
658 |
|
---|
659 | /**
|
---|
660 | * Plays a host audio stream.
|
---|
661 | *
|
---|
662 | * @returns VBox status code.
|
---|
663 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
664 | * @param pHstStrmOut Pointer to host output stream.
|
---|
665 | * @param pcSamplesPlayed Pointer to number of samples captured.
|
---|
666 | */
|
---|
667 | DECLR3CALLBACKMEMBER(int, pfnPlayOut, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMOUT pHstStrmOut, uint32_t *pcSamplesPlayed));
|
---|
668 |
|
---|
669 | /**
|
---|
670 | * Records audio to input stream.
|
---|
671 | *
|
---|
672 | * @returns VBox status code.
|
---|
673 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
674 | * @param pHstStrmIn Pointer to host input stream.
|
---|
675 | * @param pcSamplesCaptured Pointer to number of samples captured.
|
---|
676 | */
|
---|
677 | DECLR3CALLBACKMEMBER(int, pfnCaptureIn, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHSTSTRMIN pHstStrmIn, uint32_t *pcSamplesCaptured));
|
---|
678 |
|
---|
679 | /**
|
---|
680 | * Gets the configuration from the host audio (backend) driver.
|
---|
681 | *
|
---|
682 | * @returns VBox status code.
|
---|
683 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
684 | * @param pBackendCfg Pointer where to store the backend audio configuration to.
|
---|
685 | */
|
---|
686 | DECLR3CALLBACKMEMBER(int, pfnGetConf, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg));
|
---|
687 |
|
---|
688 | } PDMIHOSTAUDIO;
|
---|
689 | #define PDMIHOSTAUDIO_IID "39feea4f-c824-4197-bcff-7d4a6ede7420"
|
---|
690 |
|
---|
691 | #endif /* VBOX_WITH_PDM_AUDIO_DRIVER */
|
---|
692 |
|
---|
693 | #endif /* ___VBox_vmm_pdmaudioifs_h */
|
---|
694 |
|
---|