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