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