VirtualBox

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

最後變更 在這個檔案從64696是 63865,由 vboxsync 提交於 9 年 前

Audio: Added device flags PDMAUDIODEV_FLAGS_LOCKED and PDMAUDIODEV_FLAGS_DEAD.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 42.9 KB
 
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.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 <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 * Structure for keeping an audio stream configuration.
329 */
330typedef struct PDMAUDIOSTREAMCFG
331{
332 /** Friendly name of the stream. */
333 char szName[64];
334 /** Direction of the stream. */
335 PDMAUDIODIR enmDir;
336 union
337 {
338 /** Desired playback destination (for an output stream). */
339 PDMAUDIOPLAYBACKDEST Dest;
340 /** Desired recording source (for an input stream). */
341 PDMAUDIORECSOURCE Source;
342 } DestSource;
343 /** Frequency in Hertz (Hz). */
344 uint32_t uHz;
345 /** Number of audio channels (2 for stereo, 1 for mono). */
346 uint8_t cChannels;
347 /** Audio format. */
348 PDMAUDIOFMT enmFormat;
349 /** @todo Use RT_LE2H_*? */
350 PDMAUDIOENDIANNESS enmEndianness;
351 /** Hint about the optimal sample buffer size (in audio samples).
352 * 0 if no hint is given. */
353 uint32_t cSampleBufferSize;
354} PDMAUDIOSTREAMCFG, *PPDMAUDIOSTREAMCFG;
355
356#if defined(RT_LITTLE_ENDIAN)
357# define PDMAUDIOHOSTENDIANNESS PDMAUDIOENDIANNESS_LITTLE
358#elif defined(RT_BIG_ENDIAN)
359# define PDMAUDIOHOSTENDIANNESS PDMAUDIOENDIANNESS_BIG
360#else
361# error "Port me!"
362#endif
363
364/**
365 * Audio mixer controls.
366 */
367typedef enum PDMAUDIOMIXERCTL
368{
369 /** Unknown mixer control. */
370 PDMAUDIOMIXERCTL_UNKNOWN = 0,
371 /** Master volume. */
372 PDMAUDIOMIXERCTL_VOLUME_MASTER,
373 /** Front. */
374 PDMAUDIOMIXERCTL_FRONT,
375 /** Center / LFE (Subwoofer). */
376 PDMAUDIOMIXERCTL_CENTER_LFE,
377 /** Rear. */
378 PDMAUDIOMIXERCTL_REAR,
379 /** Line-In. */
380 PDMAUDIOMIXERCTL_LINE_IN,
381 /** Microphone-In. */
382 PDMAUDIOMIXERCTL_MIC_IN,
383 /** Hack to blow the type up to 32-bit. */
384 PDMAUDIOMIXERCTL_32BIT_HACK = 0x7fffffff
385} PDMAUDIOMIXERCTL;
386
387/**
388 * Audio stream commands. Used in the audio connector
389 * as well as in the actual host backends.
390 */
391typedef enum PDMAUDIOSTREAMCMD
392{
393 /** Unknown command, do not use. */
394 PDMAUDIOSTREAMCMD_UNKNOWN = 0,
395 /** Enables the stream. */
396 PDMAUDIOSTREAMCMD_ENABLE,
397 /** Disables the stream. */
398 PDMAUDIOSTREAMCMD_DISABLE,
399 /** Pauses the stream. */
400 PDMAUDIOSTREAMCMD_PAUSE,
401 /** Resumes the stream. */
402 PDMAUDIOSTREAMCMD_RESUME,
403 /** Hack to blow the type up to 32-bit. */
404 PDMAUDIOSTREAMCMD_32BIT_HACK = 0x7fffffff
405} PDMAUDIOSTREAMCMD;
406
407/**
408 * Properties of audio streams for host/guest
409 * for in or out directions.
410 */
411typedef struct PDMAUDIOPCMPROPS
412{
413 /** Sample width. Bits per sample. */
414 uint8_t cBits;
415 /** Signed or unsigned sample. */
416 bool fSigned;
417 /** Shift count used for faster calculation of various
418 * values, such as the alignment, bytes to samples and so on.
419 * Depends on number of stream channels and the stream format
420 * being used.
421 *
422 ** @todo Use some RTAsmXXX functions instead?
423 */
424 uint8_t cShift;
425 /** Number of audio channels. */
426 uint8_t cChannels;
427 /** Alignment mask. */
428 uint32_t uAlign;
429 /** Sample frequency in Hertz (Hz). */
430 uint32_t uHz;
431 /** Bitrate (in bytes/s). */
432 uint32_t cbBitrate;
433 /** Whether the endianness is swapped or not. */
434 bool fSwapEndian;
435} PDMAUDIOPCMPROPS, *PPDMAUDIOPCMPROPS;
436
437/**
438 * Audio volume parameters.
439 */
440typedef struct PDMAUDIOVOLUME
441{
442 /** Set to @c true if this stream is muted, @c false if not. */
443 bool fMuted;
444 /** Left channel volume.
445 * Range is from [0 ... 255], whereas 0 specifies
446 * the most silent and 255 the loudest value. */
447 uint8_t uLeft;
448 /** Right channel volume.
449 * Range is from [0 ... 255], whereas 0 specifies
450 * the most silent and 255 the loudest value. */
451 uint8_t uRight;
452} PDMAUDIOVOLUME, *PPDMAUDIOVOLUME;
453
454/** Defines the minimum volume allowed. */
455#define PDMAUDIO_VOLUME_MIN (0)
456/** Defines the maximum volume allowed. */
457#define PDMAUDIO_VOLUME_MAX (255)
458
459/**
460 * Structure for holding rate processing information
461 * of a source + destination audio stream. This is needed
462 * because both streams can differ regarding their rates
463 * and therefore need to be treated accordingly.
464 */
465typedef struct PDMAUDIOSTRMRATE
466{
467 /** Current (absolute) offset in the output
468 * (destination) stream. */
469 uint64_t dstOffset;
470 /** Increment for moving dstOffset for the
471 * destination stream. This is needed because the
472 * source <-> destination rate might be different. */
473 uint64_t dstInc;
474 /** Current (absolute) offset in the input
475 * stream. */
476 uint32_t srcOffset;
477 /** Last processed sample of the input stream.
478 * Needed for interpolation. */
479 PDMAUDIOSAMPLE srcSampleLast;
480} PDMAUDIOSTRMRATE, *PPDMAUDIOSTRMRATE;
481
482/**
483 * Structure for holding mixing buffer volume parameters.
484 * The volume values are in fixed point style and must
485 * be converted to/from before using with e.g. PDMAUDIOVOLUME.
486 */
487typedef struct PDMAUDMIXBUFVOL
488{
489 /** Set to @c true if this stream is muted, @c false if not. */
490 bool fMuted;
491 /** Left volume to apply during conversion. Pass 0
492 * to convert the original values. May not apply to
493 * all conversion functions. */
494 uint32_t uLeft;
495 /** Right volume to apply during conversion. Pass 0
496 * to convert the original values. May not apply to
497 * all conversion functions. */
498 uint32_t uRight;
499} PDMAUDMIXBUFVOL, *PPDMAUDMIXBUFVOL;
500
501/**
502 * Structure for holding sample conversion parameters for
503 * the audioMixBufConvFromXXX / audioMixBufConvToXXX macros.
504 */
505typedef struct PDMAUDMIXBUFCONVOPTS
506{
507 /** Number of audio samples to convert. */
508 uint32_t cSamples;
509 union
510 {
511 struct
512 {
513 /** Volume to use for conversion. */
514 PDMAUDMIXBUFVOL Volume;
515 } From;
516 };
517} PDMAUDMIXBUFCONVOPTS;
518/** Pointer to conversion parameters for the audio mixer. */
519typedef PDMAUDMIXBUFCONVOPTS *PPDMAUDMIXBUFCONVOPTS;
520/** Pointer to const conversion parameters for the audio mixer. */
521typedef PDMAUDMIXBUFCONVOPTS const *PCPDMAUDMIXBUFCONVOPTS;
522
523/**
524 * Note: All internal handling is done in samples,
525 * not in bytes!
526 */
527typedef uint32_t PDMAUDIOMIXBUFFMT;
528typedef PDMAUDIOMIXBUFFMT *PPDMAUDIOMIXBUFFMT;
529
530/**
531 * Convertion-from function used by the PDM audio buffer mixer.
532 *
533 * @returns Number of samples returned.
534 * @param paDst Where to return the converted samples.
535 * @param pvSrc The source samples bytes.
536 * @param cbSrc Number of bytes to convert.
537 * @param pOpts Conversion options.
538 */
539typedef DECLCALLBACK(uint32_t) FNPDMAUDIOMIXBUFCONVFROM(PPDMAUDIOSAMPLE paDst, const void *pvSrc, uint32_t cbSrc,
540 PCPDMAUDMIXBUFCONVOPTS pOpts);
541/** Pointer to a convertion-from function used by the PDM audio buffer mixer. */
542typedef FNPDMAUDIOMIXBUFCONVFROM *PFNPDMAUDIOMIXBUFCONVFROM;
543
544/**
545 * Convertion-to function used by the PDM audio buffer mixer.
546 *
547 * @param pvDst Output buffer.
548 * @param paSrc The input samples.
549 * @param pOpts Conversion options.
550 */
551typedef DECLCALLBACK(void) FNPDMAUDIOMIXBUFCONVTO(void *pvDst, PCPDMAUDIOSAMPLE paSrc, PCPDMAUDMIXBUFCONVOPTS pOpts);
552/** Pointer to a convertion-to function used by the PDM audio buffer mixer. */
553typedef FNPDMAUDIOMIXBUFCONVTO *PFNPDMAUDIOMIXBUFCONVTO;
554
555typedef struct PDMAUDIOMIXBUF *PPDMAUDIOMIXBUF;
556typedef struct PDMAUDIOMIXBUF
557{
558 RTLISTNODE Node;
559 /** Name of the buffer. */
560 char *pszName;
561 /** Sample buffer. */
562 PPDMAUDIOSAMPLE pSamples;
563 /** Size of the sample buffer (in samples). */
564 uint32_t cSamples;
565 /** The current read position (in samples). */
566 uint32_t offRead;
567 /** The current write position (in samples). */
568 uint32_t offWrite;
569 /**
570 * Total samples already mixed down to the parent buffer (if any). Always starting at
571 * the parent's offRead position.
572 *
573 * Note: Count always is specified in parent samples, as the sample count can differ between parent
574 * and child.
575 */
576 uint32_t cMixed;
577 /** How much audio samples are currently being used
578 * in this buffer.
579 * Note: This also is known as the distance in ring buffer terms. */
580 uint32_t cUsed;
581 /** Pointer to parent buffer (if any). */
582 PPDMAUDIOMIXBUF pParent;
583 /** List of children mix buffers to keep in sync with (if being a parent buffer). */
584 RTLISTANCHOR lstChildren;
585 /** Intermediate structure for buffer conversion tasks. */
586 PPDMAUDIOSTRMRATE pRate;
587 /** Internal representation of current volume used for mixing. */
588 PDMAUDMIXBUFVOL Volume;
589 /** This buffer's audio format. */
590 PDMAUDIOMIXBUFFMT AudioFmt;
591 /** Standard conversion-to function for set AudioFmt. */
592 PFNPDMAUDIOMIXBUFCONVTO pfnConvTo;
593 /** Standard conversion-from function for set AudioFmt. */
594 PFNPDMAUDIOMIXBUFCONVFROM pfnConvFrom;
595 /**
596 * Ratio of the associated parent stream's frequency by this stream's
597 * frequency (1<<32), represented as a signed 64 bit integer.
598 *
599 * For example, if the parent stream has a frequency of 44 khZ, and this
600 * stream has a frequency of 11 kHz, the ration then would be
601 * (44/11 * (1 << 32)).
602 *
603 * Currently this does not get changed once assigned.
604 */
605 int64_t iFreqRatio;
606 /** For quickly converting samples <-> bytes and vice versa. */
607 uint8_t cShift;
608} PDMAUDIOMIXBUF;
609
610typedef uint32_t PDMAUDIOFILEFLAGS;
611
612/* No flags defined. */
613#define PDMAUDIOFILEFLAG_NONE 0
614
615/**
616 * Audio file types.
617 */
618typedef enum PDMAUDIOFILETYPE
619{
620 /** Unknown type, do not use. */
621 PDMAUDIOFILETYPE_UNKNOWN = 0,
622 /** Wave (.WAV) file. */
623 PDMAUDIOFILETYPE_WAV,
624 /** Hack to blow the type up to 32-bit. */
625 PDMAUDIOFILETYPE_32BIT_HACK = 0x7fffffff
626} PDMAUDIOFILETYPE;
627
628/**
629 * Structure for an audio file handle.
630 */
631typedef struct PDMAUDIOFILE
632{
633 /** Type of the audio file. */
634 PDMAUDIOFILETYPE enmType;
635 /** File name. */
636 char szName[255];
637 /** Actual file handle. */
638 RTFILE hFile;
639 /** Data needed for the specific audio file type implemented.
640 * Optional, can be NULL. */
641 void *pvData;
642 /** Data size (in bytes). */
643 size_t cbData;
644} PDMAUDIOFILE, *PPDMAUDIOFILE;
645
646/** Stream status flag. To be used with PDMAUDIOSTRMSTS_FLAG_ flags. */
647typedef uint32_t PDMAUDIOSTRMSTS;
648
649/** No flags being set. */
650#define PDMAUDIOSTRMSTS_FLAG_NONE 0
651/** Whether this stream has been initialized by the
652 * backend or not. */
653#define PDMAUDIOSTRMSTS_FLAG_INITIALIZED RT_BIT_32(0)
654/** Whether this stream is enabled or disabled. */
655#define PDMAUDIOSTRMSTS_FLAG_ENABLED RT_BIT_32(1)
656/** Whether this stream has been paused or not. This also implies
657 * that this is an enabled stream! */
658#define PDMAUDIOSTRMSTS_FLAG_PAUSED RT_BIT_32(2)
659/** Whether this stream was marked as being disabled
660 * but there are still associated guest output streams
661 * which rely on its data. */
662#define PDMAUDIOSTRMSTS_FLAG_PENDING_DISABLE RT_BIT_32(3)
663/** Data can be read from the stream. */
664#define PDMAUDIOSTRMSTS_FLAG_DATA_READABLE RT_BIT_32(4)
665/** Data can be written to the stream. */
666#define PDMAUDIOSTRMSTS_FLAG_DATA_WRITABLE RT_BIT_32(5)
667/** Whether this stream is in re-initialization phase.
668 * All other bits remain untouched to be able to restore
669 * the stream's state after the re-initialization bas been
670 * finished. */
671#define PDMAUDIOSTRMSTS_FLAG_PENDING_REINIT RT_BIT_32(6)
672/** Validation mask. */
673#define PDMAUDIOSTRMSTS_VALID_MASK UINT32_C(0x0000007F)
674
675/**
676 * Enumeration presenting a backend's current status.
677 */
678typedef enum PDMAUDIOBACKENDSTS
679{
680 /** Unknown/invalid status. */
681 PDMAUDIOBACKENDSTS_UNKNOWN = 0,
682 /** The backend is in its initialization phase.
683 * Not all backends support this status. */
684 PDMAUDIOBACKENDSTS_INITIALIZING,
685 /** The backend has stopped its operation. */
686 PDMAUDIOBACKENDSTS_STOPPED,
687 /** The backend is up and running. */
688 PDMAUDIOBACKENDSTS_RUNNING,
689 /** The backend ran into an error and is unable to recover.
690 * A manual re-initialization might help. */
691 PDMAUDIOBACKENDSTS_ERROR,
692 /** Hack to blow the type up to 32-bit. */
693 PDMAUDIOBACKENDSTS_32BIT_HACK = 0x7fffffff
694} PDMAUDIOBACKENDSTS;
695
696/**
697 * Audio stream context.
698 */
699typedef enum PDMAUDIOSTREAMCTX
700{
701 /** No context set / invalid. */
702 PDMAUDIOSTREAMCTX_UNKNOWN = 0,
703 /** Host stream, connected to a backend. */
704 PDMAUDIOSTREAMCTX_HOST,
705 /** Guest stream, connected to the device emulation. */
706 PDMAUDIOSTREAMCTX_GUEST,
707 /** Hack to blow the type up to 32-bit. */
708 PDMAUDIOSTREAMCTX_32BIT_HACK = 0x7fffffff
709} PDMAUDIOSTREAMCTX;
710
711/**
712 * Structure for keeping audio input stream specifics.
713 * Do not use directly. Instead, use PDMAUDIOSTREAM.
714 */
715typedef struct PDMAUDIOSTREAMIN
716{
717 /** Timestamp (in ms) since last read. */
718 uint64_t tsLastReadMS;
719#ifdef VBOX_WITH_STATISTICS
720 STAMCOUNTER StatBytesElapsed;
721 STAMCOUNTER StatBytesTotalRead;
722 STAMCOUNTER StatSamplesCaptured;
723#endif
724} PDMAUDIOSTREAMIN, *PPDMAUDIOSTREAMIN;
725
726/**
727 * Structure for keeping audio output stream specifics.
728 * Do not use directly. Instead, use PDMAUDIOSTREAM.
729 */
730typedef struct PDMAUDIOSTREAMOUT
731{
732 /** Timestamp (in ms) since last write. */
733 uint64_t tsLastWriteMS;
734#ifdef VBOX_WITH_STATISTICS
735 STAMCOUNTER StatBytesElapsed;
736 STAMCOUNTER StatBytesTotalWritten;
737 STAMCOUNTER StatSamplesPlayed;
738#endif
739} PDMAUDIOSTREAMOUT, *PPDMAUDIOSTREAMOUT;
740
741struct PDMAUDIOSTREAM;
742typedef PDMAUDIOSTREAM *PPDMAUDIOSTREAM;
743
744/**
745 * Structure for maintaining an nput/output audio stream.
746 */
747typedef struct PDMAUDIOSTREAM
748{
749 /** List node. */
750 RTLISTNODE Node;
751 /** Pointer to the other pair of this stream.
752 * This might be the host or guest side. */
753 PPDMAUDIOSTREAM pPair;
754 /** Name of this stream. */
755 char szName[64];
756 /** Number of references to this stream. Only can be
757 * destroyed if the reference count is reaching 0. */
758 uint32_t cRefs;
759 /** The stream's audio configuration. */
760 PDMAUDIOSTREAMCFG Cfg;
761 /** Stream status flag. */
762 PDMAUDIOSTRMSTS fStatus;
763 /** This stream's mixing buffer. */
764 PDMAUDIOMIXBUF MixBuf;
765 /** Audio direction of this stream. */
766 PDMAUDIODIR enmDir;
767 /** Context of this stream. */
768 PDMAUDIOSTREAMCTX enmCtx;
769 /** Timestamp (in ms) since last iteration. */
770 uint64_t tsLastIterateMS;
771 /** Union for input/output specifics. */
772 union
773 {
774 PDMAUDIOSTREAMIN In;
775 PDMAUDIOSTREAMOUT Out;
776 };
777} PDMAUDIOSTREAM, *PPDMAUDIOSTREAM;
778
779/** Pointer to a audio connector interface. */
780typedef struct PDMIAUDIOCONNECTOR *PPDMIAUDIOCONNECTOR;
781
782/**
783 * Audio callback types.
784 * Those callbacks are being sent from the backends to the audio connector.
785 */
786typedef enum PDMAUDIOCBTYPE
787{
788 /** Invalid, do not use. */
789 PDMAUDIOCBTYPE_INVALID = 0,
790 /** The backend's status has changed. */
791 PDMAUDIOCBTYPE_STATUS,
792 /** One or more host audio devices have changed. */
793 PDMAUDIOCBTYPE_DEVICES_CHANGED,
794 /** Data is availabe as input for passing to the device emulation. */
795 PDMAUDIOCBTYPE_DATA_INPUT,
796 /** Free data for the device emulation to write to the backend. */
797 PDMAUDIOCBTYPE_DATA_OUTPUT
798} PDMAUDIOCBTYPE;
799
800/**
801 * Callback data for audio input.
802 */
803typedef struct PDMAUDIOCBDATA_DATA_INPUT
804{
805 /** Input: How many bytes are availabe as input for passing
806 * to the device emulation. */
807 uint32_t cbInAvail;
808 /** Output: How many bytes have been read. */
809 uint32_t cbOutRead;
810} PDMAUDIOCBDATA_DATA_INPUT, *PPDMAUDIOCBDATA_DATA_INPUT;
811
812/**
813 * Callback data for audio output.
814 */
815typedef struct PDMAUDIOCBDATA_DATA_OUTPUT
816{
817 /** Input: How many bytes are free for the device emulation to write. */
818 uint32_t cbInFree;
819 /** Output: How many bytes were written by the device emulation. */
820 uint32_t cbOutWritten;
821} PDMAUDIOCBDATA_DATA_OUTPUT, *PPDMAUDIOCBDATA_DATA_OUTPUT;
822
823/** Pointer to a host audio interface. */
824typedef struct PDMIHOSTAUDIO *PPDMIHOSTAUDIO;
825
826/**
827 * Host audio (backend) callback function.
828 *
829 * @returns IPRT status code.
830 * @param pDrvIns Pointer to driver instance which called us.
831 * @param enmType Callback type.
832 * @param pvUser User argument.
833 * @param cbUser Size (in bytes) of user argument.
834 */
835typedef DECLCALLBACK(int) FNPDMHOSTAUDIOCALLBACK(PPDMDRVINS pDrvIns, PDMAUDIOCBTYPE enmType, void *pvUser, size_t cbUser);
836/** Pointer to a FNPDMHOSTAUDIOCALLBACK(). */
837typedef FNPDMHOSTAUDIOCALLBACK *PFNPDMHOSTAUDIOCALLBACK;
838
839#ifdef VBOX_WITH_AUDIO_DEVICE_CALLBACKS
840/**
841 * Structure for keeping a registered audio callback around.
842 */
843typedef struct PDMAUDIOCALLBACK
844{
845 /** List node. */
846 RTLISTANCHOR Node;
847 /** Callback type. */
848 PDMAUDIOCBTYPE enmType;
849 /** Pointer to context data. Optional. */
850 void *pvCtx;
851 /** Size (in bytes) of context data.
852 * Must be 0 if pvCtx is NULL. */
853 size_t cbCtx;
854 /** Actual callback function to call. */
855 PFNPDMAUDIOCALLBACK pFn;
856} PDMAUDIOCALLBACK, *PPDMAUDIOCALLBACK;
857#endif /* VBOX_WITH_AUDIO_DEVICE_CALLBACKS */
858
859/**
860 * Audio connector interface (up).
861 */
862typedef struct PDMIAUDIOCONNECTOR
863{
864 /**
865 * Retrieves the current configuration of the host audio backend.
866 *
867 * @returns VBox status code.
868 * @param pInterface Pointer to the interface structure containing the called function pointer.
869 * @param pCfg Where to store the host audio backend configuration data.
870 */
871 DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOBACKENDCFG pCfg));
872
873 /**
874 * Retrieves the current status of the host audio backend.
875 *
876 * @returns Status of the host audio backend.
877 * @param pInterface Pointer to the interface structure containing the called function pointer.
878 * @param enmDir Audio direction to check host audio backend for. Specify PDMAUDIODIR_ANY for the overall
879 * backend status.
880 */
881 DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir));
882
883 /**
884 * Creates an audio stream.
885 *
886 * @returns VBox status code.
887 * @param pInterface Pointer to the interface structure containing the called function pointer.
888 * @param pCfgHost Stream configuration for host side.
889 * @param pCfgGuest Stream configuration for guest side.
890 * @param ppStream Pointer where to return the created audio stream on success.
891 */
892 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest, PPDMAUDIOSTREAM *ppStream));
893
894 /**
895 * Destroys an audio stream.
896 *
897 * @param pInterface Pointer to the interface structure containing the called function pointer.
898 * @param pStream Pointer to audio stream.
899 */
900 DECLR3CALLBACKMEMBER(int, pfnStreamDestroy, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
901
902 /**
903 * Adds a reference to the specified audio stream.
904 *
905 * @returns New reference count. UINT32_MAX on error.
906 * @param pInterface Pointer to the interface structure containing the called function pointer.
907 * @param pStream Pointer to audio stream adding the reference to.
908 */
909 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamRetain, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
910
911 /**
912 * Releases a reference from the specified stream.
913 *
914 * @returns New reference count. UINT32_MAX on error.
915 * @param pInterface Pointer to the interface structure containing the called function pointer.
916 * @param pStream Pointer to audio stream releasing a reference from.
917 */
918 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamRelease, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
919
920 /**
921 * Reads PCM audio data from the host (input).
922 *
923 * @returns VBox status code.
924 * @param pInterface Pointer to the interface structure containing the called function pointer.
925 * @param pStream Pointer to audio stream to write to.
926 * @param pvBuf Where to store the read data.
927 * @param cbBuf Number of bytes to read.
928 * @param pcbRead Bytes of audio data read. Optional.
929 */
930 DECLR3CALLBACKMEMBER(int, pfnStreamRead, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead));
931
932 /**
933 * Writes PCM audio data to the host (output).
934 *
935 * @returns VBox status code.
936 * @param pInterface Pointer to the interface structure containing the called function pointer.
937 * @param pStream Pointer to audio stream to read from.
938 * @param pvBuf Audio data to be written.
939 * @param cbBuf Number of bytes to be written.
940 * @param pcbWritten Bytes of audio data written. Optional.
941 */
942 DECLR3CALLBACKMEMBER(int, pfnStreamWrite, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten));
943
944 /**
945 * Controls a specific audio stream.
946 *
947 * @returns VBox status code.
948 * @param pInterface Pointer to the interface structure containing the called function pointer.
949 * @param pStream Pointer to audio stream.
950 * @param enmStreamCmd The stream command to issue.
951 */
952 DECLR3CALLBACKMEMBER(int, pfnStreamControl, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd));
953
954 /**
955 * Processes stream data.
956 *
957 * @param pInterface Pointer to the interface structure containing the called function pointer.
958 * @param pStream Pointer to audio stream.
959 * @param pcData Data (in audio samples) available. Optional.
960 */
961 DECLR3CALLBACKMEMBER(int, pfnStreamIterate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
962
963 /**
964 * Returns the number of readable data (in bytes) of a specific audio input stream.
965 *
966 * @returns Number of readable data (in bytes).
967 * @param pInterface Pointer to the interface structure containing the called function pointer.
968 * @param pStream Pointer to audio stream.
969 */
970 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetReadable, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
971
972 /**
973 * Returns the number of writable data (in bytes) of a specific audio output stream.
974 *
975 * @returns Number of writable data (in bytes).
976 * @param pInterface Pointer to the interface structure containing the called function pointer.
977 * @param pStream Pointer to audio stream.
978 */
979 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetWritable, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
980
981 /**
982 * Returns the status of a specific audio stream.
983 *
984 * @returns Audio stream status
985 * @param pInterface Pointer to the interface structure containing the called function pointer.
986 * @param pStream Pointer to audio stream.
987 */
988 DECLR3CALLBACKMEMBER(PDMAUDIOSTRMSTS, pfnStreamGetStatus, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
989
990 /**
991 * Sets the audio volume of a specific audio stream.
992 *
993 * @returns VBox status code.
994 * @param pInterface Pointer to the interface structure containing the called function pointer.
995 * @param pStream Pointer to audio stream.
996 * @param pVol Pointer to audio volume structure to set the stream's audio volume to.
997 */
998 DECLR3CALLBACKMEMBER(int, pfnStreamSetVolume, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOVOLUME pVol));
999
1000 /**
1001 * Plays (transfers) available audio samples via the host backend. Only works with output streams.
1002 *
1003 * @returns VBox status code.
1004 * @param pInterface Pointer to the interface structure containing the called function pointer.
1005 * @param pcSamplesPlayed Number of samples played. Optional.
1006 */
1007 DECLR3CALLBACKMEMBER(int, pfnStreamPlay, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed));
1008
1009 /**
1010 * Captures (transfers) available audio samples from the host backend. Only works with input streams.
1011 *
1012 * @returns VBox status code.
1013 * @param pInterface Pointer to the interface structure containing the called function pointer.
1014 * @param pcSamplesCaptured Number of samples captured. Optional.
1015 */
1016 DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesCaptured));
1017
1018#ifdef VBOX_WITH_AUDIO_DEVICE_CALLBACKS
1019 DECLR3CALLBACKMEMBER(int, pfnRegisterCallbacks, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOCALLBACK paCallbacks, size_t cCallbacks));
1020 DECLR3CALLBACKMEMBER(int, pfnCallback, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIOCBTYPE enmType, void *pvUser, size_t cbUser));
1021#endif
1022
1023} PDMIAUDIOCONNECTOR;
1024
1025/** PDMIAUDIOCONNECTOR interface ID. */
1026#define PDMIAUDIOCONNECTOR_IID "FF2044D1-F8D9-4F42-BE9E-0E9AD14F4552"
1027
1028/**
1029 * Assigns all needed interface callbacks for an audio backend.
1030 *
1031 * @param a_Prefix The function name prefix.
1032 */
1033#define PDMAUDIO_IHOSTAUDIO_CALLBACKS(a_Prefix) \
1034 do { \
1035 pThis->IHostAudio.pfnInit = RT_CONCAT(a_Prefix,Init); \
1036 pThis->IHostAudio.pfnShutdown = RT_CONCAT(a_Prefix,Shutdown); \
1037 pThis->IHostAudio.pfnGetConfig = RT_CONCAT(a_Prefix,GetConfig); \
1038 /** @todo Add pfnGetDevices here as soon as supported by all backends. */ \
1039 pThis->IHostAudio.pfnGetStatus = RT_CONCAT(a_Prefix,GetStatus); \
1040 /** @todo Ditto for pfnSetCallback. */ \
1041 pThis->IHostAudio.pfnStreamCreate = RT_CONCAT(a_Prefix,StreamCreate); \
1042 pThis->IHostAudio.pfnStreamDestroy = RT_CONCAT(a_Prefix,StreamDestroy); \
1043 pThis->IHostAudio.pfnStreamControl = RT_CONCAT(a_Prefix,StreamControl); \
1044 pThis->IHostAudio.pfnStreamGetStatus = RT_CONCAT(a_Prefix,StreamGetStatus); \
1045 pThis->IHostAudio.pfnStreamIterate = RT_CONCAT(a_Prefix,StreamIterate); \
1046 pThis->IHostAudio.pfnStreamPlay = RT_CONCAT(a_Prefix,StreamPlay); \
1047 pThis->IHostAudio.pfnStreamCapture = RT_CONCAT(a_Prefix,StreamCapture); \
1048 } while (0)
1049
1050/**
1051 * PDM host audio interface.
1052 */
1053typedef struct PDMIHOSTAUDIO
1054{
1055 /**
1056 * Initializes the host backend (driver).
1057 *
1058 * @returns VBox status code.
1059 * @param pInterface Pointer to the interface structure containing the called function pointer.
1060 */
1061 DECLR3CALLBACKMEMBER(int, pfnInit, (PPDMIHOSTAUDIO pInterface));
1062
1063 /**
1064 * Shuts down the host backend (driver).
1065 *
1066 * @returns VBox status code.
1067 * @param pInterface Pointer to the interface structure containing the called function pointer.
1068 */
1069 DECLR3CALLBACKMEMBER(void, pfnShutdown, (PPDMIHOSTAUDIO pInterface));
1070
1071 /**
1072 * Returns the host backend's configuration (backend).
1073 *
1074 * @returns VBox status code.
1075 * @param pInterface Pointer to the interface structure containing the called function pointer.
1076 * @param pBackendCfg Where to store the backend audio configuration to.
1077 */
1078 DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg));
1079
1080 /**
1081 * Returns (enumerates) host audio device information.
1082 *
1083 * @returns VBox status code.
1084 * @param pInterface Pointer to the interface structure containing the called function pointer.
1085 * @param pDeviceEnum Where to return the enumerated audio devices.
1086 */
1087 DECLR3CALLBACKMEMBER(int, pfnGetDevices, (PPDMIHOSTAUDIO pInterface, PPDMAUDIODEVICEENUM pDeviceEnum));
1088
1089 /**
1090 * Returns the current status from the audio backend.
1091 *
1092 * @returns PDMAUDIOBACKENDSTS enum.
1093 * @param pInterface Pointer to the interface structure containing the called function pointer.
1094 * @param enmDir Audio direction to get status for. Pass PDMAUDIODIR_ANY for overall status.
1095 */
1096 DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir));
1097
1098 /**
1099 * Sets a callback the audio backend can call. Optional.
1100 *
1101 * @returns VBox status code.
1102 * @param pInterface Pointer to the interface structure containing the called function pointer.
1103 * @param pfnCallback The callback function to use, or NULL when unregistering.
1104 */
1105 DECLR3CALLBACKMEMBER(int, pfnSetCallback, (PPDMIHOSTAUDIO pInterface, PFNPDMHOSTAUDIOCALLBACK pfnCallback));
1106
1107 /**
1108 * Creates an audio stream using the requested stream configuration.
1109 * If a backend is not able to create this configuration, it will return its best match in the acquired configuration
1110 * structure on success.
1111 *
1112 * @returns VBox status code.
1113 * @param pInterface Pointer to the interface structure containing the called function pointer.
1114 * @param pStream Pointer to audio stream.
1115 * @param pCfgReq Pointer to requested stream configuration.
1116 * @param pCfgAcq Pointer to acquired stream configuration.
1117 */
1118 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq));
1119
1120 /**
1121 * Destroys an audio stream.
1122 *
1123 * @returns VBox status code.
1124 * @param pInterface Pointer to the interface structure containing the called function pointer.
1125 * @param pStream Pointer to audio stream.
1126 */
1127 DECLR3CALLBACKMEMBER(int, pfnStreamDestroy, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream));
1128
1129 /**
1130 * Controls an audio stream.
1131 *
1132 * @returns VBox status code.
1133 * @param pInterface Pointer to the interface structure containing the called function pointer.
1134 * @param pStream Pointer to audio stream.
1135 * @param enmStreamCmd The stream command to issue.
1136 */
1137 DECLR3CALLBACKMEMBER(int, pfnStreamControl, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd));
1138
1139 /**
1140 * Returns whether the specified audio direction in the backend is enabled or not.
1141 *
1142 * @returns PDMAUDIOSTRMSTS
1143 * @param pInterface Pointer to the interface structure containing the called function pointer.
1144 * @param enmDir Audio direction to check status for.
1145 */
1146 DECLR3CALLBACKMEMBER(PDMAUDIOSTRMSTS, pfnStreamGetStatus, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream));
1147
1148 /**
1149 * Gives the host backend the chance to do some (necessary) iteration work.
1150 *
1151 * @returns VBox status code.
1152 * @param pInterface Pointer to the interface structure containing the called function pointer.
1153 * @param pStream Pointer to audio stream.
1154 */
1155 DECLR3CALLBACKMEMBER(int, pfnStreamIterate, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream));
1156
1157 /**
1158 * Plays (writes to) an audio (output) stream.
1159 *
1160 * @returns VBox status code.
1161 * @param pInterface Pointer to the interface structure containing the called function pointer.
1162 * @param pStream Pointer to audio stream.
1163 * @param pvBuf Pointer to audio data buffer to play. Currently not used and must be NULL.
1164 * @param cbBuf Size (in bytes) of audio data buffer. Currently not used and must be 0.
1165 * @param pcbWritten Returns number of bytes written. Optional.
1166 */
1167 DECLR3CALLBACKMEMBER(int, pfnStreamPlay, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten));
1168
1169 /**
1170 * Captures (reads from) an audio (input) stream.
1171 *
1172 * @returns VBox status code.
1173 * @param pInterface Pointer to the interface structure containing the called function pointer.
1174 * @param pStream Pointer to audio stream.
1175 * @param pvBuf Buffer where to store read audio data. Currently not used and must be NULL.
1176 * @param cbBuf Size (in bytes) of buffer. Currently not used and must be 0.
1177 * @param pcbRead Returns number of bytes read. Optional.
1178 */
1179 DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead));
1180
1181} PDMIHOSTAUDIO;
1182
1183/** PDMIHOSTAUDIO interface ID. */
1184#define PDMIHOSTAUDIO_IID "C45550DE-03C0-4A45-9A96-C5EB956F806D"
1185
1186/** @} */
1187
1188#endif /* !___VBox_vmm_pdmaudioifs_h */
1189
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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