VirtualBox

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

Last change on this file since 65121 was 65100, checked in by vboxsync, 8 years ago

Devices/Audio: doxygen fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 43.1 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, audio interfaces.
3 */
4
5/*
6 * Copyright (C) 2006-2016 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 <iprt/circbuf.h>
30#include <iprt/list.h>
31
32#include <VBox/types.h>
33#ifdef VBOX_WITH_STATISTICS
34# include <VBox/vmm/stam.h>
35#endif
36
37/** @defgroup grp_pdm_ifs_audio PDM Audio Interfaces
38 * @ingroup grp_pdm_interfaces
39 * @{
40 */
41
42/** PDM audio driver instance flags. */
43typedef uint32_t PDMAUDIODRVFLAGS;
44
45/** No flags set. */
46#define PDMAUDIODRVFLAGS_NONE 0
47/** Marks a primary audio driver which is critical
48 * when running the VM. */
49#define PDMAUDIODRVFLAGS_PRIMARY RT_BIT(0)
50
51/**
52 * Audio format in signed or unsigned variants.
53 */
54typedef enum PDMAUDIOFMT
55{
56 /** Invalid format, do not use. */
57 PDMAUDIOFMT_INVALID,
58 /** 8-bit, unsigned. */
59 PDMAUDIOFMT_U8,
60 /** 8-bit, signed. */
61 PDMAUDIOFMT_S8,
62 /** 16-bit, unsigned. */
63 PDMAUDIOFMT_U16,
64 /** 16-bit, signed. */
65 PDMAUDIOFMT_S16,
66 /** 32-bit, unsigned. */
67 PDMAUDIOFMT_U32,
68 /** 32-bit, signed. */
69 PDMAUDIOFMT_S32,
70 /** Hack to blow the type up to 32-bit. */
71 PDMAUDIOFMT_32BIT_HACK = 0x7fffffff
72} PDMAUDIOFMT;
73
74/**
75 * Audio direction.
76 */
77typedef enum PDMAUDIODIR
78{
79 /** Unknown direction. */
80 PDMAUDIODIR_UNKNOWN = 0,
81 /** Input. */
82 PDMAUDIODIR_IN = 1,
83 /** Output. */
84 PDMAUDIODIR_OUT = 2,
85 /** Duplex handling. */
86 PDMAUDIODIR_ANY = 3,
87 /** Hack to blow the type up to 32-bit. */
88 PDMAUDIODIR_32BIT_HACK = 0x7fffffff
89} PDMAUDIODIR;
90
91/** Device latency spec in milliseconds (ms). */
92typedef uint32_t PDMAUDIODEVLATSPECMS;
93
94/** Device latency spec in seconds (s). */
95typedef uint32_t PDMAUDIODEVLATSPECSEC;
96
97/** Audio device flags. Use with PDMAUDIODEV_FLAG_ flags. */
98typedef uint32_t PDMAUDIODEVFLAG;
99
100/** No flags set. */
101#define PDMAUDIODEV_FLAGS_NONE 0
102/** The device marks the default device within the host OS. */
103#define PDMAUDIODEV_FLAGS_DEFAULT RT_BIT(0)
104/** The device can be removed at any time and we have to deal with it. */
105#define PDMAUDIODEV_FLAGS_HOTPLUG RT_BIT(1)
106/** The device is known to be buggy and needs special treatment. */
107#define PDMAUDIODEV_FLAGS_BUGGY RT_BIT(2)
108/** Ignore the device, no matter what. */
109#define PDMAUDIODEV_FLAGS_IGNORE RT_BIT(3)
110/** The device is present but marked as locked by some other application. */
111#define PDMAUDIODEV_FLAGS_LOCKED RT_BIT(4)
112/** The device is present but not in an alive state (dead). */
113#define PDMAUDIODEV_FLAGS_DEAD RT_BIT(5)
114
115/**
116 * Audio device type.
117 */
118typedef enum PDMAUDIODEVICETYPE
119{
120 /** Unknown device type. This is the default. */
121 PDMAUDIODEVICETYPE_UNKNOWN = 0,
122 /** Dummy device; for backends which are not able to report
123 * actual device information (yet). */
124 PDMAUDIODEVICETYPE_DUMMY,
125 /** The device is built into the host (non-removable). */
126 PDMAUDIODEVICETYPE_BUILTIN,
127 /** The device is an (external) USB device. */
128 PDMAUDIODEVICETYPE_USB,
129 /** Hack to blow the type up to 32-bit. */
130 PDMAUDIODEVICETYPE_32BIT_HACK = 0x7fffffff
131} PDMAUDIODEVICETYPE;
132
133/**
134 * Audio device instance data.
135 */
136typedef struct PDMAUDIODEVICE
137{
138 /** List node. */
139 RTLISTNODE Node;
140 /** Friendly name of the device, if any. */
141 char szName[64];
142 /** The device type. */
143 PDMAUDIODEVICETYPE enmType;
144 /** Reference count indicating how many audio streams currently are relying on this device. */
145 uint8_t cRefCount;
146 /** Usage of the device. */
147 PDMAUDIODIR enmUsage;
148 /** Device flags. */
149 PDMAUDIODEVFLAG fFlags;
150 /** Maximum number of input audio channels the device supports. */
151 uint8_t cMaxInputChannels;
152 /** Maximum number of output audio channels the device supports. */
153 uint8_t cMaxOutputChannels;
154 /** Additional data which might be relevant for the current context. */
155 void *pvData;
156 /** Size of the additional data. */
157 size_t cbData;
158 /** Device type union, based on enmType. */
159 union
160 {
161 /** USB type specifics. */
162 struct
163 {
164 /** Vendor ID. */
165 int16_t VID;
166 /** Product ID. */
167 int16_t PID;
168 } USB;
169 } Type;
170} PDMAUDIODEVICE, *PPDMAUDIODEVICE;
171
172/**
173 * Structure for keeping an audio device enumeration.
174 */
175typedef struct PDMAUDIODEVICEENUM
176{
177 /** Number of audio devices in the list. */
178 uint16_t cDevices;
179 /** List of audio devices. */
180 RTLISTANCHOR lstDevices;
181} PDMAUDIODEVICEENUM, *PPDMAUDIODEVICEENUM;
182
183/**
184 * Audio (static) configuration of an audio host backend.
185 */
186typedef struct PDMAUDIOBACKENDCFG
187{
188 /** Size (in bytes) of the host backend's audio output stream structure. */
189 size_t cbStreamOut;
190 /** Size (in bytes) of the host backend's audio input stream structure. */
191 size_t cbStreamIn;
192 /** Number of concurrent output streams supported on the host.
193 * UINT32_MAX for unlimited concurrent streams, 0 if no concurrent input streams are supported. */
194 uint32_t cMaxStreamsOut;
195 /** Number of concurrent input streams supported on the host.
196 * UINT32_MAX for unlimited concurrent streams, 0 if no concurrent input streams are supported. */
197 uint32_t cMaxStreamsIn;
198} PDMAUDIOBACKENDCFG, *PPDMAUDIOBACKENDCFG;
199
200/**
201 * A single audio sample, representing left and right channels (stereo).
202 */
203typedef struct PDMAUDIOSAMPLE
204{
205 /** Left channel. */
206 int64_t i64LSample;
207 /** Right channel. */
208 int64_t i64RSample;
209} PDMAUDIOSAMPLE;
210/** Pointer to a single (stereo) audio sample. */
211typedef PDMAUDIOSAMPLE *PPDMAUDIOSAMPLE;
212/** Pointer to a const single (stereo) audio sample. */
213typedef PDMAUDIOSAMPLE const *PCPDMAUDIOSAMPLE;
214
215typedef enum PDMAUDIOENDIANNESS
216{
217 /** The usual invalid endian. */
218 PDMAUDIOENDIANNESS_INVALID,
219 /** Little endian. */
220 PDMAUDIOENDIANNESS_LITTLE,
221 /** Bit endian. */
222 PDMAUDIOENDIANNESS_BIG,
223 /** Endianness doesn't have a meaning in the context. */
224 PDMAUDIOENDIANNESS_NA,
225 /** The end of the valid endian values (exclusive). */
226 PDMAUDIOENDIANNESS_END,
227 /** Hack to blow the type up to 32-bit. */
228 PDMAUDIOENDIANNESS_32BIT_HACK = 0x7fffffff
229} PDMAUDIOENDIANNESS;
230
231/**
232 * Audio playback destinations.
233 */
234typedef enum PDMAUDIOPLAYBACKDEST
235{
236 /** Unknown destination. */
237 PDMAUDIOPLAYBACKDEST_UNKNOWN = 0,
238 /** Front channel. */
239 PDMAUDIOPLAYBACKDEST_FRONT,
240 /** Center / LFE (Subwoofer) channel. */
241 PDMAUDIOPLAYBACKDEST_CENTER_LFE,
242 /** Rear channel. */
243 PDMAUDIOPLAYBACKDEST_REAR,
244 /** Hack to blow the type up to 32-bit. */
245 PDMAUDIOPLAYBACKDEST_32BIT_HACK = 0x7fffffff
246} PDMAUDIOPLAYBACKDEST;
247
248/**
249 * Audio recording sources.
250 */
251typedef enum PDMAUDIORECSOURCE
252{
253 /** Unknown recording source. */
254 PDMAUDIORECSOURCE_UNKNOWN = 0,
255 /** Microphone-In. */
256 PDMAUDIORECSOURCE_MIC,
257 /** CD. */
258 PDMAUDIORECSOURCE_CD,
259 /** Video-In. */
260 PDMAUDIORECSOURCE_VIDEO,
261 /** AUX. */
262 PDMAUDIORECSOURCE_AUX,
263 /** Line-In. */
264 PDMAUDIORECSOURCE_LINE,
265 /** Phone-In. */
266 PDMAUDIORECSOURCE_PHONE,
267 /** Hack to blow the type up to 32-bit. */
268 PDMAUDIORECSOURCE_32BIT_HACK = 0x7fffffff
269} PDMAUDIORECSOURCE;
270
271/**
272 * Audio stream (data) layout.
273 */
274typedef enum PDMAUDIOSTREAMLAYOUT
275{
276 /** Unknown access type; do not use. */
277 PDMAUDIOSTREAMLAYOUT_UNKNOWN = 0,
278 /** Non-interleaved access, that is, consecutive
279 * access to the data. */
280 PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED,
281 /** Interleaved access, where the data can be
282 * mixed together with data of other audio streams. */
283 PDMAUDIOSTREAMLAYOUT_INTERLEAVED,
284 /** Complex layout, which does not fit into the
285 * interleaved / non-interleaved layouts. */
286 PDMAUDIOSTREAMLAYOUT_COMPLEX,
287 /** Hack to blow the type up to 32-bit. */
288 PDMAUDIOSTREAMLAYOUT_32BIT_HACK = 0x7fffffff
289} PDMAUDIOSTREAMLAYOUT, *PPDMAUDIOSTREAMLAYOUT;
290
291/** No stream channel data flags defined. */
292#define PDMAUDIOSTREAMCHANNELDATA_FLAG_NONE 0
293
294/**
295 * Structure for keeping a stream channel data block around.
296 */
297typedef struct PDMAUDIOSTREAMCHANNELDATA
298{
299 /** Circular buffer for the channel data. */
300 PRTCIRCBUF pCircBuf;
301 size_t cbAcq;
302 /** Channel data flags. */
303 uint32_t fFlags;
304} PDMAUDIOSTREAMCHANNELDATA, *PPDMAUDIOSTREAMCHANNELDATA;
305
306/**
307 * Structure for a single channel of an audio stream.
308 * An audio stream consists of one or multiple channels,
309 * depending on the configuration.
310 */
311typedef struct PDMAUDIOSTREAMCHANNEL
312{
313 /** Channel ID. */
314 uint8_t uChannel;
315 /** Step size (in bytes) to the channel's next frame. */
316 size_t cbStep;
317 /** Frame size (in bytes) of this channel. */
318 size_t cbFrame;
319 /** Offset (in bytes) to first sample in the data block. */
320 size_t cbFirst;
321 /** Currente offset (in bytes) in the data stream. */
322 size_t cbOff;
323 /** Associated data buffer. */
324 PDMAUDIOSTREAMCHANNELDATA Data;
325} PDMAUDIOSTREAMCHANNEL, *PPDMAUDIOSTREAMCHANNEL;
326
327/**
328 * Union for keeping an audio stream destination or source.
329 */
330typedef union PDMAUDIODESTSOURCE
331{
332 /** Desired playback destination (for an output stream). */
333 PDMAUDIOPLAYBACKDEST Dest;
334 /** Desired recording source (for an input stream). */
335 PDMAUDIORECSOURCE Source;
336} PDMAUDIODESTSOURCE, *PPDMAUDIODESTSOURCE;
337
338/**
339 * Structure for keeping an audio stream configuration.
340 */
341typedef struct PDMAUDIOSTREAMCFG
342{
343 /** Friendly name of the stream. */
344 char szName[64];
345 /** Direction of the stream. */
346 PDMAUDIODIR enmDir;
347 /** Destination / source indicator, depending on enmDir. */
348 PDMAUDIODESTSOURCE DestSource;
349 /** Frequency in Hertz (Hz). */
350 uint32_t uHz;
351 /** Number of audio channels (2 for stereo, 1 for mono). */
352 uint8_t cChannels;
353 /** Audio format. */
354 PDMAUDIOFMT enmFormat;
355 /** @todo Use RT_LE2H_*? */
356 PDMAUDIOENDIANNESS enmEndianness;
357 /** Hint about the optimal sample buffer size (in audio samples).
358 * 0 if no hint is given. */
359 uint32_t cSampleBufferSize;
360} PDMAUDIOSTREAMCFG, *PPDMAUDIOSTREAMCFG;
361
362#if defined(RT_LITTLE_ENDIAN)
363# define PDMAUDIOHOSTENDIANNESS PDMAUDIOENDIANNESS_LITTLE
364#elif defined(RT_BIG_ENDIAN)
365# define PDMAUDIOHOSTENDIANNESS PDMAUDIOENDIANNESS_BIG
366#else
367# error "Port me!"
368#endif
369
370/**
371 * Audio mixer controls.
372 */
373typedef enum PDMAUDIOMIXERCTL
374{
375 /** Unknown mixer control. */
376 PDMAUDIOMIXERCTL_UNKNOWN = 0,
377 /** Master volume. */
378 PDMAUDIOMIXERCTL_VOLUME_MASTER,
379 /** Front. */
380 PDMAUDIOMIXERCTL_FRONT,
381 /** Center / LFE (Subwoofer). */
382 PDMAUDIOMIXERCTL_CENTER_LFE,
383 /** Rear. */
384 PDMAUDIOMIXERCTL_REAR,
385 /** Line-In. */
386 PDMAUDIOMIXERCTL_LINE_IN,
387 /** Microphone-In. */
388 PDMAUDIOMIXERCTL_MIC_IN,
389 /** Hack to blow the type up to 32-bit. */
390 PDMAUDIOMIXERCTL_32BIT_HACK = 0x7fffffff
391} PDMAUDIOMIXERCTL;
392
393/**
394 * Audio stream commands. Used in the audio connector
395 * as well as in the actual host backends.
396 */
397typedef enum PDMAUDIOSTREAMCMD
398{
399 /** Unknown command, do not use. */
400 PDMAUDIOSTREAMCMD_UNKNOWN = 0,
401 /** Enables the stream. */
402 PDMAUDIOSTREAMCMD_ENABLE,
403 /** Disables the stream. */
404 PDMAUDIOSTREAMCMD_DISABLE,
405 /** Pauses the stream. */
406 PDMAUDIOSTREAMCMD_PAUSE,
407 /** Resumes the stream. */
408 PDMAUDIOSTREAMCMD_RESUME,
409 /** Hack to blow the type up to 32-bit. */
410 PDMAUDIOSTREAMCMD_32BIT_HACK = 0x7fffffff
411} PDMAUDIOSTREAMCMD;
412
413/**
414 * Properties of audio streams for host/guest
415 * for in or out directions.
416 */
417typedef struct PDMAUDIOPCMPROPS
418{
419 /** Sample width. Bits per sample. */
420 uint8_t cBits;
421 /** Signed or unsigned sample. */
422 bool fSigned;
423 /** Shift count used for faster calculation of various
424 * values, such as the alignment, bytes to samples and so on.
425 * Depends on number of stream channels and the stream format
426 * being used.
427 *
428 ** @todo Use some RTAsmXXX functions instead?
429 */
430 uint8_t cShift;
431 /** Number of audio channels. */
432 uint8_t cChannels;
433 /** Alignment mask. */
434 uint32_t uAlign;
435 /** Sample frequency in Hertz (Hz). */
436 uint32_t uHz;
437 /** Bitrate (in bytes/s). */
438 uint32_t cbBitrate;
439 /** Whether the endianness is swapped or not. */
440 bool fSwapEndian;
441} PDMAUDIOPCMPROPS, *PPDMAUDIOPCMPROPS;
442
443/**
444 * Audio volume parameters.
445 */
446typedef struct PDMAUDIOVOLUME
447{
448 /** Set to @c true if this stream is muted, @c false if not. */
449 bool fMuted;
450 /** Left channel volume.
451 * Range is from [0 ... 255], whereas 0 specifies
452 * the most silent and 255 the loudest value. */
453 uint8_t uLeft;
454 /** Right channel volume.
455 * Range is from [0 ... 255], whereas 0 specifies
456 * the most silent and 255 the loudest value. */
457 uint8_t uRight;
458} PDMAUDIOVOLUME, *PPDMAUDIOVOLUME;
459
460/** Defines the minimum volume allowed. */
461#define PDMAUDIO_VOLUME_MIN (0)
462/** Defines the maximum volume allowed. */
463#define PDMAUDIO_VOLUME_MAX (255)
464
465/**
466 * Structure for holding rate processing information
467 * of a source + destination audio stream. This is needed
468 * because both streams can differ regarding their rates
469 * and therefore need to be treated accordingly.
470 */
471typedef struct PDMAUDIOSTRMRATE
472{
473 /** Current (absolute) offset in the output
474 * (destination) stream. */
475 uint64_t dstOffset;
476 /** Increment for moving dstOffset for the
477 * destination stream. This is needed because the
478 * source <-> destination rate might be different. */
479 uint64_t dstInc;
480 /** Current (absolute) offset in the input
481 * stream. */
482 uint32_t srcOffset;
483 /** Last processed sample of the input stream.
484 * Needed for interpolation. */
485 PDMAUDIOSAMPLE srcSampleLast;
486} PDMAUDIOSTRMRATE, *PPDMAUDIOSTRMRATE;
487
488/**
489 * Structure for holding mixing buffer volume parameters.
490 * The volume values are in fixed point style and must
491 * be converted to/from before using with e.g. PDMAUDIOVOLUME.
492 */
493typedef struct PDMAUDMIXBUFVOL
494{
495 /** Set to @c true if this stream is muted, @c false if not. */
496 bool fMuted;
497 /** Left volume to apply during conversion. Pass 0
498 * to convert the original values. May not apply to
499 * all conversion functions. */
500 uint32_t uLeft;
501 /** Right volume to apply during conversion. Pass 0
502 * to convert the original values. May not apply to
503 * all conversion functions. */
504 uint32_t uRight;
505} PDMAUDMIXBUFVOL, *PPDMAUDMIXBUFVOL;
506
507/**
508 * Structure for holding sample conversion parameters for
509 * the audioMixBufConvFromXXX / audioMixBufConvToXXX macros.
510 */
511typedef struct PDMAUDMIXBUFCONVOPTS
512{
513 /** Number of audio samples to convert. */
514 uint32_t cSamples;
515 union
516 {
517 struct
518 {
519 /** Volume to use for conversion. */
520 PDMAUDMIXBUFVOL Volume;
521 } From;
522 };
523} PDMAUDMIXBUFCONVOPTS;
524/** Pointer to conversion parameters for the audio mixer. */
525typedef PDMAUDMIXBUFCONVOPTS *PPDMAUDMIXBUFCONVOPTS;
526/** Pointer to const conversion parameters for the audio mixer. */
527typedef PDMAUDMIXBUFCONVOPTS const *PCPDMAUDMIXBUFCONVOPTS;
528
529/**
530 * Note: All internal handling is done in samples,
531 * not in bytes!
532 */
533typedef uint32_t PDMAUDIOMIXBUFFMT;
534typedef PDMAUDIOMIXBUFFMT *PPDMAUDIOMIXBUFFMT;
535
536/**
537 * Convertion-from function used by the PDM audio buffer mixer.
538 *
539 * @returns Number of samples returned.
540 * @param paDst Where to return the converted samples.
541 * @param pvSrc The source samples bytes.
542 * @param cbSrc Number of bytes to convert.
543 * @param pOpts Conversion options.
544 */
545typedef DECLCALLBACK(uint32_t) FNPDMAUDIOMIXBUFCONVFROM(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc,
546 PCPDMAUDMIXBUFCONVOPTS pOpts);
547/** Pointer to a convertion-from function used by the PDM audio buffer mixer. */
548typedef FNPDMAUDIOMIXBUFCONVFROM *PFNPDMAUDIOMIXBUFCONVFROM;
549
550/**
551 * Convertion-to function used by the PDM audio buffer mixer.
552 *
553 * @param pvDst Output buffer.
554 * @param paSrc The input samples.
555 * @param pOpts Conversion options.
556 */
557typedef DECLCALLBACK(void) FNPDMAUDIOMIXBUFCONVTO(void *pvDst, PCPDMAUDIOSAMPLE paSrc, PCPDMAUDMIXBUFCONVOPTS pOpts);
558/** Pointer to a convertion-to function used by the PDM audio buffer mixer. */
559typedef FNPDMAUDIOMIXBUFCONVTO *PFNPDMAUDIOMIXBUFCONVTO;
560
561typedef struct PDMAUDIOMIXBUF *PPDMAUDIOMIXBUF;
562typedef struct PDMAUDIOMIXBUF
563{
564 RTLISTNODE Node;
565 /** Name of the buffer. */
566 char *pszName;
567 /** Sample buffer. */
568 PPDMAUDIOSAMPLE pSamples;
569 /** Size of the sample buffer (in samples). */
570 uint32_t cSamples;
571 /** The current read position (in samples). */
572 uint32_t offRead;
573 /** The current write position (in samples). */
574 uint32_t offWrite;
575 /**
576 * Total samples already mixed down to the parent buffer (if any). Always starting at
577 * the parent's offRead position.
578 *
579 * Note: Count always is specified in parent samples, as the sample count can differ between parent
580 * and child.
581 */
582 uint32_t cMixed;
583 /** How much audio samples are currently being used
584 * in this buffer.
585 * Note: This also is known as the distance in ring buffer terms. */
586 uint32_t cUsed;
587 /** Pointer to parent buffer (if any). */
588 PPDMAUDIOMIXBUF pParent;
589 /** List of children mix buffers to keep in sync with (if being a parent buffer). */
590 RTLISTANCHOR lstChildren;
591 /** Intermediate structure for buffer conversion tasks. */
592 PPDMAUDIOSTRMRATE pRate;
593 /** Internal representation of current volume used for mixing. */
594 PDMAUDMIXBUFVOL Volume;
595 /** This buffer's audio format. */
596 PDMAUDIOMIXBUFFMT AudioFmt;
597 /** Standard conversion-to function for set AudioFmt. */
598 PFNPDMAUDIOMIXBUFCONVTO pfnConvTo;
599 /** Standard conversion-from function for set AudioFmt. */
600 PFNPDMAUDIOMIXBUFCONVFROM pfnConvFrom;
601 /**
602 * Ratio of the associated parent stream's frequency by this stream's
603 * frequency (1<<32), represented as a signed 64 bit integer.
604 *
605 * For example, if the parent stream has a frequency of 44 khZ, and this
606 * stream has a frequency of 11 kHz, the ration then would be
607 * (44/11 * (1 << 32)).
608 *
609 * Currently this does not get changed once assigned.
610 */
611 int64_t iFreqRatio;
612 /** For quickly converting samples <-> bytes and vice versa. */
613 uint8_t cShift;
614} PDMAUDIOMIXBUF;
615
616typedef uint32_t PDMAUDIOFILEFLAGS;
617
618/* No flags defined. */
619#define PDMAUDIOFILEFLAG_NONE 0
620
621/**
622 * Audio file types.
623 */
624typedef enum PDMAUDIOFILETYPE
625{
626 /** Unknown type, do not use. */
627 PDMAUDIOFILETYPE_UNKNOWN = 0,
628 /** Wave (.WAV) file. */
629 PDMAUDIOFILETYPE_WAV,
630 /** Hack to blow the type up to 32-bit. */
631 PDMAUDIOFILETYPE_32BIT_HACK = 0x7fffffff
632} PDMAUDIOFILETYPE;
633
634/**
635 * Structure for an audio file handle.
636 */
637typedef struct PDMAUDIOFILE
638{
639 /** Type of the audio file. */
640 PDMAUDIOFILETYPE enmType;
641 /** File name. */
642 char szName[255];
643 /** Actual file handle. */
644 RTFILE hFile;
645 /** Data needed for the specific audio file type implemented.
646 * Optional, can be NULL. */
647 void *pvData;
648 /** Data size (in bytes). */
649 size_t cbData;
650} PDMAUDIOFILE, *PPDMAUDIOFILE;
651
652/** Stream status flag. To be used with PDMAUDIOSTRMSTS_FLAG_ flags. */
653typedef uint32_t PDMAUDIOSTRMSTS;
654
655/** No flags being set. */
656#define PDMAUDIOSTRMSTS_FLAG_NONE 0
657/** Whether this stream has been initialized by the
658 * backend or not. */
659#define PDMAUDIOSTRMSTS_FLAG_INITIALIZED RT_BIT_32(0)
660/** Whether this stream is enabled or disabled. */
661#define PDMAUDIOSTRMSTS_FLAG_ENABLED RT_BIT_32(1)
662/** Whether this stream has been paused or not. This also implies
663 * that this is an enabled stream! */
664#define PDMAUDIOSTRMSTS_FLAG_PAUSED RT_BIT_32(2)
665/** Whether this stream was marked as being disabled
666 * but there are still associated guest output streams
667 * which rely on its data. */
668#define PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE RT_BIT_32(3)
669/** Data can be read from the stream. */
670#define PDMAUDIOSTRMSTS_FLAG_DATA_READABLE RT_BIT_32(4)
671/** Data can be written to the stream. */
672#define PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE RT_BIT_32(5)
673/** Whether this stream is in re-initialization phase.
674 * All other bits remain untouched to be able to restore
675 * the stream's state after the re-initialization bas been
676 * finished. */
677#define PDMAUDIOSTRMSTS_FLAG_PENDING_REINIT RT_BIT_32(6)
678/** Validation mask. */
679#define PDMAUDIOSTRMSTS_VALID_MASK UINT32_C(0x0000007F)
680
681/**
682 * Enumeration presenting a backend's current status.
683 */
684typedef enum PDMAUDIOBACKENDSTS
685{
686 /** Unknown/invalid status. */
687 PDMAUDIOBACKENDSTS_UNKNOWN = 0,
688 /** The backend is in its initialization phase.
689 * Not all backends support this status. */
690 PDMAUDIOBACKENDSTS_INITIALIZING,
691 /** The backend has stopped its operation. */
692 PDMAUDIOBACKENDSTS_STOPPED,
693 /** The backend is up and running. */
694 PDMAUDIOBACKENDSTS_RUNNING,
695 /** The backend ran into an error and is unable to recover.
696 * A manual re-initialization might help. */
697 PDMAUDIOBACKENDSTS_ERROR,
698 /** Hack to blow the type up to 32-bit. */
699 PDMAUDIOBACKENDSTS_32BIT_HACK = 0x7fffffff
700} PDMAUDIOBACKENDSTS;
701
702/**
703 * Audio stream context.
704 */
705typedef enum PDMAUDIOSTREAMCTX
706{
707 /** No context set / invalid. */
708 PDMAUDIOSTREAMCTX_UNKNOWN = 0,
709 /** Host stream, connected to a backend. */
710 PDMAUDIOSTREAMCTX_HOST,
711 /** Guest stream, connected to the device emulation. */
712 PDMAUDIOSTREAMCTX_GUEST,
713 /** Hack to blow the type up to 32-bit. */
714 PDMAUDIOSTREAMCTX_32BIT_HACK = 0x7fffffff
715} PDMAUDIOSTREAMCTX;
716
717/**
718 * Structure for keeping audio input stream specifics.
719 * Do not use directly. Instead, use PDMAUDIOSTREAM.
720 */
721typedef struct PDMAUDIOSTREAMIN
722{
723 /** Timestamp (in ms) since last read. */
724 uint64_t tsLastReadMS;
725#ifdef VBOX_WITH_STATISTICS
726 STAMCOUNTER StatBytesElapsed;
727 STAMCOUNTER StatBytesTotalRead;
728 STAMCOUNTER StatSamplesCaptured;
729#endif
730} PDMAUDIOSTREAMIN, *PPDMAUDIOSTREAMIN;
731
732/**
733 * Structure for keeping audio output stream specifics.
734 * Do not use directly. Instead, use PDMAUDIOSTREAM.
735 */
736typedef struct PDMAUDIOSTREAMOUT
737{
738 /** Timestamp (in ms) since last write. */
739 uint64_t tsLastWriteMS;
740#ifdef VBOX_WITH_STATISTICS
741 STAMCOUNTER StatBytesElapsed;
742 STAMCOUNTER StatBytesTotalWritten;
743 STAMCOUNTER StatSamplesPlayed;
744#endif
745} PDMAUDIOSTREAMOUT, *PPDMAUDIOSTREAMOUT;
746
747struct PDMAUDIOSTREAM;
748typedef PDMAUDIOSTREAM *PPDMAUDIOSTREAM;
749
750/**
751 * Structure for maintaining an nput/output audio stream.
752 */
753typedef struct PDMAUDIOSTREAM
754{
755 /** List node. */
756 RTLISTNODE Node;
757 /** Pointer to the other pair of this stream.
758 * This might be the host or guest side. */
759 PPDMAUDIOSTREAM pPair;
760 /** Name of this stream. */
761 char szName[64];
762 /** Number of references to this stream. Only can be
763 * destroyed if the reference count is reaching 0. */
764 uint32_t cRefs;
765 /** The stream's audio configuration. */
766 PDMAUDIOSTREAMCFG Cfg;
767 /** Stream status flag. */
768 PDMAUDIOSTRMSTS fStatus;
769 /** This stream's mixing buffer. */
770 PDMAUDIOMIXBUF MixBuf;
771 /** Audio direction of this stream. */
772 PDMAUDIODIR enmDir;
773 /** Context of this stream. */
774 PDMAUDIOSTREAMCTX enmCtx;
775 /** Timestamp (in ms) since last iteration. */
776 uint64_t tsLastIterateMS;
777 /** Union for input/output specifics. */
778 union
779 {
780 PDMAUDIOSTREAMIN In;
781 PDMAUDIOSTREAMOUT Out;
782 };
783} PDMAUDIOSTREAM, *PPDMAUDIOSTREAM;
784
785/** Pointer to a audio connector interface. */
786typedef struct PDMIAUDIOCONNECTOR *PPDMIAUDIOCONNECTOR;
787
788/**
789 * Audio callback types.
790 * Those callbacks are being sent from the backends to the audio connector.
791 */
792typedef enum PDMAUDIOCBTYPE
793{
794 /** Invalid, do not use. */
795 PDMAUDIOCBTYPE_INVALID = 0,
796 /** The backend's status has changed. */
797 PDMAUDIOCBTYPE_STATUS,
798 /** One or more host audio devices have changed. */
799 PDMAUDIOCBTYPE_DEVICES_CHANGED,
800 /** Data is availabe as input for passing to the device emulation. */
801 PDMAUDIOCBTYPE_DATA_INPUT,
802 /** Free data for the device emulation to write to the backend. */
803 PDMAUDIOCBTYPE_DATA_OUTPUT
804} PDMAUDIOCBTYPE;
805
806/**
807 * Callback data for audio input.
808 */
809typedef struct PDMAUDIOCBDATA_DATA_INPUT
810{
811 /** Input: How many bytes are availabe as input for passing
812 * to the device emulation. */
813 uint32_t cbInAvail;
814 /** Output: How many bytes have been read. */
815 uint32_t cbOutRead;
816} PDMAUDIOCBDATA_DATA_INPUT, *PPDMAUDIOCBDATA_DATA_INPUT;
817
818/**
819 * Callback data for audio output.
820 */
821typedef struct PDMAUDIOCBDATA_DATA_OUTPUT
822{
823 /** Input: How many bytes are free for the device emulation to write. */
824 uint32_t cbInFree;
825 /** Output: How many bytes were written by the device emulation. */
826 uint32_t cbOutWritten;
827} PDMAUDIOCBDATA_DATA_OUTPUT, *PPDMAUDIOCBDATA_DATA_OUTPUT;
828
829/** Pointer to a host audio interface. */
830typedef struct PDMIHOSTAUDIO *PPDMIHOSTAUDIO;
831
832/**
833 * Host audio (backend) callback function.
834 *
835 * @returns IPRT status code.
836 * @param pDrvIns Pointer to driver instance which called us.
837 * @param enmType Callback type.
838 * @param pvUser User argument.
839 * @param cbUser Size (in bytes) of user argument.
840 */
841typedef DECLCALLBACK(int) FNPDMHOSTAUDIOCALLBACK(PPDMDRVINS pDrvIns, PDMAUDIOCBTYPE enmType, void *pvUser, size_t cbUser);
842/** Pointer to a FNPDMHOSTAUDIOCALLBACK(). */
843typedef FNPDMHOSTAUDIOCALLBACK *PFNPDMHOSTAUDIOCALLBACK;
844
845#ifdef VBOX_WITH_AUDIO_DEVICE_CALLBACKS
846/**
847 * Structure for keeping a registered audio callback around.
848 */
849typedef struct PDMAUDIOCALLBACK
850{
851 /** List node. */
852 RTLISTANCHOR Node;
853 /** Callback type. */
854 PDMAUDIOCBTYPE enmType;
855 /** Pointer to context data. Optional. */
856 void *pvCtx;
857 /** Size (in bytes) of context data.
858 * Must be 0 if pvCtx is NULL. */
859 size_t cbCtx;
860 /** Actual callback function to call. */
861 PFNPDMAUDIOCALLBACK pFn;
862} PDMAUDIOCALLBACK, *PPDMAUDIOCALLBACK;
863#endif /* VBOX_WITH_AUDIO_DEVICE_CALLBACKS */
864
865/**
866 * Audio connector interface (up).
867 */
868typedef struct PDMIAUDIOCONNECTOR
869{
870 /**
871 * Retrieves the current configuration of the host audio backend.
872 *
873 * @returns VBox status code.
874 * @param pInterface Pointer to the interface structure containing the called function pointer.
875 * @param pCfg Where to store the host audio backend configuration data.
876 */
877 DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOBACKENDCFG pCfg));
878
879 /**
880 * Retrieves the current status of the host audio backend.
881 *
882 * @returns Status of the host audio backend.
883 * @param pInterface Pointer to the interface structure containing the called function pointer.
884 * @param enmDir Audio direction to check host audio backend for. Specify PDMAUDIODIR_ANY for the overall
885 * backend status.
886 */
887 DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir));
888
889 /**
890 * Creates an audio stream.
891 *
892 * @returns VBox status code.
893 * @param pInterface Pointer to the interface structure containing the called function pointer.
894 * @param pCfgHost Stream configuration for host side.
895 * @param pCfgGuest Stream configuration for guest side.
896 * @param ppStream Pointer where to return the created audio stream on success.
897 */
898 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest, PPDMAUDIOSTREAM *ppStream));
899
900 /**
901 * Destroys an audio stream.
902 *
903 * @param pInterface Pointer to the interface structure containing the called function pointer.
904 * @param pStream Pointer to audio stream.
905 */
906 DECLR3CALLBACKMEMBER(int, pfnStreamDestroy, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
907
908 /**
909 * Adds a reference to the specified audio stream.
910 *
911 * @returns New reference count. UINT32_MAX on error.
912 * @param pInterface Pointer to the interface structure containing the called function pointer.
913 * @param pStream Pointer to audio stream adding the reference to.
914 */
915 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamRetain, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
916
917 /**
918 * Releases a reference from the specified stream.
919 *
920 * @returns New reference count. UINT32_MAX on error.
921 * @param pInterface Pointer to the interface structure containing the called function pointer.
922 * @param pStream Pointer to audio stream releasing a reference from.
923 */
924 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamRelease, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
925
926 /**
927 * Reads PCM audio data from the host (input).
928 *
929 * @returns VBox status code.
930 * @param pInterface Pointer to the interface structure containing the called function pointer.
931 * @param pStream Pointer to audio stream to write to.
932 * @param pvBuf Where to store the read data.
933 * @param cbBuf Number of bytes to read.
934 * @param pcbRead Bytes of audio data read. Optional.
935 */
936 DECLR3CALLBACKMEMBER(int, pfnStreamRead, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead));
937
938 /**
939 * Writes PCM audio data to the host (output).
940 *
941 * @returns VBox status code.
942 * @param pInterface Pointer to the interface structure containing the called function pointer.
943 * @param pStream Pointer to audio stream to read from.
944 * @param pvBuf Audio data to be written.
945 * @param cbBuf Number of bytes to be written.
946 * @param pcbWritten Bytes of audio data written. Optional.
947 */
948 DECLR3CALLBACKMEMBER(int, pfnStreamWrite, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten));
949
950 /**
951 * Controls a specific audio stream.
952 *
953 * @returns VBox status code.
954 * @param pInterface Pointer to the interface structure containing the called function pointer.
955 * @param pStream Pointer to audio stream.
956 * @param enmStreamCmd The stream command to issue.
957 */
958 DECLR3CALLBACKMEMBER(int, pfnStreamControl, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd));
959
960 /**
961 * Processes stream data.
962 *
963 * @param pInterface Pointer to the interface structure containing the called function pointer.
964 * @param pStream Pointer to audio stream.
965 */
966 DECLR3CALLBACKMEMBER(int, pfnStreamIterate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
967
968 /**
969 * Returns the number of readable data (in bytes) of a specific audio input stream.
970 *
971 * @returns Number of readable data (in bytes).
972 * @param pInterface Pointer to the interface structure containing the called function pointer.
973 * @param pStream Pointer to audio stream.
974 */
975 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetReadable, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
976
977 /**
978 * Returns the number of writable data (in bytes) of a specific audio output stream.
979 *
980 * @returns Number of writable data (in bytes).
981 * @param pInterface Pointer to the interface structure containing the called function pointer.
982 * @param pStream Pointer to audio stream.
983 */
984 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetWritable, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
985
986 /**
987 * Returns the status of a specific audio stream.
988 *
989 * @returns Audio stream status
990 * @param pInterface Pointer to the interface structure containing the called function pointer.
991 * @param pStream Pointer to audio stream.
992 */
993 DECLR3CALLBACKMEMBER(PDMAUDIOSTRMSTS, pfnStreamGetStatus, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
994
995 /**
996 * Sets the audio volume of a specific audio stream.
997 *
998 * @returns VBox status code.
999 * @param pInterface Pointer to the interface structure containing the called function pointer.
1000 * @param pStream Pointer to audio stream.
1001 * @param pVol Pointer to audio volume structure to set the stream's audio volume to.
1002 */
1003 DECLR3CALLBACKMEMBER(int, pfnStreamSetVolume, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOVOLUME pVol));
1004
1005 /**
1006 * Plays (transfers) available audio samples via the host backend. Only works with output streams.
1007 *
1008 * @returns VBox status code.
1009 * @param pInterface Pointer to the interface structure containing the called function pointer.
1010 * @param pStream Pointer to audio stream.
1011 * @param pcSamplesPlayed Number of samples played. Optional.
1012 */
1013 DECLR3CALLBACKMEMBER(int, pfnStreamPlay, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed));
1014
1015 /**
1016 * Captures (transfers) available audio samples from the host backend. Only works with input streams.
1017 *
1018 * @returns VBox status code.
1019 * @param pInterface Pointer to the interface structure containing the called function pointer.
1020 * @param pStream Pointer to audio stream.
1021 * @param pcSamplesCaptured Number of samples captured. Optional.
1022 */
1023 DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesCaptured));
1024
1025#ifdef VBOX_WITH_AUDIO_DEVICE_CALLBACKS
1026 DECLR3CALLBACKMEMBER(int, pfnRegisterCallbacks, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOCALLBACK paCallbacks, size_t cCallbacks));
1027 DECLR3CALLBACKMEMBER(int, pfnCallback, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIOCBTYPE enmType, void *pvUser, size_t cbUser));
1028#endif
1029
1030} PDMIAUDIOCONNECTOR;
1031
1032/** PDMIAUDIOCONNECTOR interface ID. */
1033#define PDMIAUDIOCONNECTOR_IID "FF2044D1-F8D9-4F42-BE9E-0E9AD14F4552"
1034
1035/**
1036 * Assigns all needed interface callbacks for an audio backend.
1037 *
1038 * @param a_Prefix The function name prefix.
1039 */
1040#define PDMAUDIO_IHOSTAUDIO_CALLBACKS(a_Prefix) \
1041 do { \
1042 pThis->IHostAudio.pfnInit = RT_CONCAT(a_Prefix,Init); \
1043 pThis->IHostAudio.pfnShutdown = RT_CONCAT(a_Prefix,Shutdown); \
1044 pThis->IHostAudio.pfnGetConfig = RT_CONCAT(a_Prefix,GetConfig); \
1045 /** @todo Add pfnGetDevices here as soon as supported by all backends. */ \
1046 pThis->IHostAudio.pfnGetStatus = RT_CONCAT(a_Prefix,GetStatus); \
1047 /** @todo Ditto for pfnSetCallback. */ \
1048 pThis->IHostAudio.pfnStreamCreate = RT_CONCAT(a_Prefix,StreamCreate); \
1049 pThis->IHostAudio.pfnStreamDestroy = RT_CONCAT(a_Prefix,StreamDestroy); \
1050 pThis->IHostAudio.pfnStreamControl = RT_CONCAT(a_Prefix,StreamControl); \
1051 pThis->IHostAudio.pfnStreamGetStatus = RT_CONCAT(a_Prefix,StreamGetStatus); \
1052 pThis->IHostAudio.pfnStreamIterate = RT_CONCAT(a_Prefix,StreamIterate); \
1053 pThis->IHostAudio.pfnStreamPlay = RT_CONCAT(a_Prefix,StreamPlay); \
1054 pThis->IHostAudio.pfnStreamCapture = RT_CONCAT(a_Prefix,StreamCapture); \
1055 } while (0)
1056
1057/**
1058 * PDM host audio interface.
1059 */
1060typedef struct PDMIHOSTAUDIO
1061{
1062 /**
1063 * Initializes the host backend (driver).
1064 *
1065 * @returns VBox status code.
1066 * @param pInterface Pointer to the interface structure containing the called function pointer.
1067 */
1068 DECLR3CALLBACKMEMBER(int, pfnInit, (PPDMIHOSTAUDIO pInterface));
1069
1070 /**
1071 * Shuts down the host backend (driver).
1072 *
1073 * @returns VBox status code.
1074 * @param pInterface Pointer to the interface structure containing the called function pointer.
1075 */
1076 DECLR3CALLBACKMEMBER(void, pfnShutdown, (PPDMIHOSTAUDIO pInterface));
1077
1078 /**
1079 * Returns the host backend's configuration (backend).
1080 *
1081 * @returns VBox status code.
1082 * @param pInterface Pointer to the interface structure containing the called function pointer.
1083 * @param pBackendCfg Where to store the backend audio configuration to.
1084 */
1085 DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg));
1086
1087 /**
1088 * Returns (enumerates) host audio device information.
1089 *
1090 * @returns VBox status code.
1091 * @param pInterface Pointer to the interface structure containing the called function pointer.
1092 * @param pDeviceEnum Where to return the enumerated audio devices.
1093 */
1094 DECLR3CALLBACKMEMBER(int, pfnGetDevices, (PPDMIHOSTAUDIO pInterface, PPDMAUDIODEVICEENUM pDeviceEnum));
1095
1096 /**
1097 * Returns the current status from the audio backend.
1098 *
1099 * @returns PDMAUDIOBACKENDSTS enum.
1100 * @param pInterface Pointer to the interface structure containing the called function pointer.
1101 * @param enmDir Audio direction to get status for. Pass PDMAUDIODIR_ANY for overall status.
1102 */
1103 DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir));
1104
1105 /**
1106 * Sets a callback the audio backend can call. Optional.
1107 *
1108 * @returns VBox status code.
1109 * @param pInterface Pointer to the interface structure containing the called function pointer.
1110 * @param pfnCallback The callback function to use, or NULL when unregistering.
1111 */
1112 DECLR3CALLBACKMEMBER(int, pfnSetCallback, (PPDMIHOSTAUDIO pInterface, PFNPDMHOSTAUDIOCALLBACK pfnCallback));
1113
1114 /**
1115 * Creates an audio stream using the requested stream configuration.
1116 * If a backend is not able to create this configuration, it will return its best match in the acquired configuration
1117 * structure on success.
1118 *
1119 * @returns VBox status code.
1120 * @param pInterface Pointer to the interface structure containing the called function pointer.
1121 * @param pStream Pointer to audio stream.
1122 * @param pCfgReq Pointer to requested stream configuration.
1123 * @param pCfgAcq Pointer to acquired stream configuration.
1124 */
1125 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq));
1126
1127 /**
1128 * Destroys an audio stream.
1129 *
1130 * @returns VBox status code.
1131 * @param pInterface Pointer to the interface structure containing the called function pointer.
1132 * @param pStream Pointer to audio stream.
1133 */
1134 DECLR3CALLBACKMEMBER(int, pfnStreamDestroy, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream));
1135
1136 /**
1137 * Controls an audio stream.
1138 *
1139 * @returns VBox status code.
1140 * @param pInterface Pointer to the interface structure containing the called function pointer.
1141 * @param pStream Pointer to audio stream.
1142 * @param enmStreamCmd The stream command to issue.
1143 */
1144 DECLR3CALLBACKMEMBER(int, pfnStreamControl, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd));
1145
1146 /**
1147 * Returns whether the specified audio direction in the backend is enabled or not.
1148 *
1149 * @returns PDMAUDIOSTRMSTS
1150 * @param pInterface Pointer to the interface structure containing the called function pointer.
1151 * @param pStream Pointer to audio stream.
1152 */
1153 DECLR3CALLBACKMEMBER(PDMAUDIOSTRMSTS, pfnStreamGetStatus, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream));
1154
1155 /**
1156 * Gives the host backend the chance to do some (necessary) iteration work.
1157 *
1158 * @returns VBox status code.
1159 * @param pInterface Pointer to the interface structure containing the called function pointer.
1160 * @param pStream Pointer to audio stream.
1161 */
1162 DECLR3CALLBACKMEMBER(int, pfnStreamIterate, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream));
1163
1164 /**
1165 * Plays (writes to) an audio (output) stream.
1166 *
1167 * @returns VBox status code.
1168 * @param pInterface Pointer to the interface structure containing the called function pointer.
1169 * @param pStream Pointer to audio stream.
1170 * @param pvBuf Pointer to audio data buffer to play. Currently not used and must be NULL.
1171 * @param cbBuf Size (in bytes) of audio data buffer. Currently not used and must be 0.
1172 * @param pcbWritten Returns number of bytes written. Optional.
1173 */
1174 DECLR3CALLBACKMEMBER(int, pfnStreamPlay, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten));
1175
1176 /**
1177 * Captures (reads from) an audio (input) stream.
1178 *
1179 * @returns VBox status code.
1180 * @param pInterface Pointer to the interface structure containing the called function pointer.
1181 * @param pStream Pointer to audio stream.
1182 * @param pvBuf Buffer where to store read audio data. Currently not used and must be NULL.
1183 * @param cbBuf Size (in bytes) of buffer. Currently not used and must be 0.
1184 * @param pcbRead Returns number of bytes read. Optional.
1185 */
1186 DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead));
1187
1188} PDMIHOSTAUDIO;
1189
1190/** PDMIHOSTAUDIO interface ID. */
1191#define PDMIHOSTAUDIO_IID "C45550DE-03C0-4A45-9A96-C5EB956F806D"
1192
1193/** @} */
1194
1195#endif /* !___VBox_vmm_pdmaudioifs_h */
1196
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