VirtualBox

source: vbox/trunk/include/VBox/vmm/pdmaudioifs.h@ 55461

Last change on this file since 55461 was 55340, checked in by vboxsync, 10 years ago

Audio: Fixed warnings, largely inconsistent types.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette