VirtualBox

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

Last change on this file since 88892 was 88892, checked in by vboxsync, 4 years ago

Audio: Moved the PDMAUDIOSTREAM_STS_XXX stuff into DrvAudio as it's no longer used by any public interfaces any more. bugref:9890

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 65.3 KB
Line 
1/** @file
2 * PDM - Pluggable Device Manager, Audio interfaces.
3 */
4
5/*
6 * Copyright (C) 2006-2020 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/** @page pg_pdm_audio PDM Audio
27 *
28 * @section sec_pdm_audio_overview Audio architecture overview
29 *
30 * The audio architecture mainly consists of two PDM interfaces,
31 * PDMIAUDIOCONNECTOR and PDMIHOSTAUDIO.
32 *
33 * The PDMIAUDIOCONNECTOR interface is responsible of connecting a device
34 * emulation, such as SB16, AC'97 and HDA to one or multiple audio backend(s).
35 * Its API abstracts audio stream handling and I/O functions, device enumeration
36 * and so on.
37 *
38 * The PDMIHOSTAUDIO interface must be implemented by all audio backends to
39 * provide an abstract and common way of accessing needed functions, such as
40 * transferring output audio data for playing audio or recording input from the
41 * host.
42 *
43 * A device emulation can have one or more LUNs attached to it, whereas these
44 * LUNs in turn then all have their own PDMIAUDIOCONNECTOR, making it possible
45 * to connect multiple backends to a certain device emulation stream
46 * (multiplexing).
47 *
48 * An audio backend's job is to record and/or play audio data (depending on its
49 * capabilities). It highly depends on the host it's running on and needs very
50 * specific (host-OS-dependent) code. The backend itself only has very limited
51 * ways of accessing and/or communicating with the PDMIAUDIOCONNECTOR interface
52 * via callbacks, but never directly with the device emulation or other parts of
53 * the audio sub system.
54 *
55 *
56 * @section sec_pdm_audio_mixing Mixing
57 *
58 * The AUDIOMIXER API is optionally available to create and manage virtual audio
59 * mixers. Such an audio mixer in turn then can be used by the device emulation
60 * code to manage all the multiplexing to/from the connected LUN audio streams.
61 *
62 * Currently only input and output stream are supported. Duplex stream are not
63 * supported yet.
64 *
65 * This also is handy if certain LUN audio streams should be added or removed
66 * during runtime.
67 *
68 * To create a group of either input or output streams the AUDMIXSINK API can be
69 * used.
70 *
71 * For example: The device emulation has one hardware output stream (HW0), and
72 * that output stream shall be available to all connected LUN backends. For that
73 * to happen, an AUDMIXSINK sink has to be created and attached to the device's
74 * AUDIOMIXER object.
75 *
76 * As every LUN has its own AUDMIXSTREAM object, adding all those
77 * objects to the just created audio mixer sink will do the job.
78 *
79 * @note The AUDIOMIXER API is purely optional and is not used by all currently
80 * implemented device emulations (e.g. SB16).
81 *
82 *
83 * @section sec_pdm_audio_data_processing Data processing
84 *
85 * Audio input / output data gets handed off to/from the device emulation in an
86 * unmodified (raw) way. The actual audio frame / sample conversion is done via
87 * the AUDIOMIXBUF API.
88 *
89 * This concentrates the audio data processing in one place and makes it easier
90 * to test / benchmark such code.
91 *
92 * A PDMAUDIOFRAME is the internal representation of a single audio frame, which
93 * consists of a single left and right audio sample in time. Only mono (1) and
94 * stereo (2) channel(s) currently are supported.
95 *
96 *
97 * @section sec_pdm_audio_timing Timing
98 *
99 * Handling audio data in a virtual environment is hard, as the human perception
100 * is very sensitive to the slightest cracks and stutters in the audible data.
101 * This can happen if the VM's timing is lagging behind or not within the
102 * expected time frame.
103 *
104 * The two main components which unfortunately contradict each other is a) the
105 * audio device emulation and b) the audio backend(s) on the host. Those need to
106 * be served in a timely manner to function correctly. To make e.g. the device
107 * emulation rely on the pace the host backend(s) set - or vice versa - will not
108 * work, as the guest's audio system / drivers then will not be able to
109 * compensate this accordingly.
110 *
111 * So each component, the device emulation, the audio connector(s) and the
112 * backend(s) must do its thing *when* it needs to do it, independently of the
113 * others. For that we use various (small) ring buffers to (hopefully) serve all
114 * components with the amount of data *when* they need it.
115 *
116 * Additionally, the device emulation can run with a different audio frame size,
117 * while the backends(s) may require a different frame size (16 bit stereo
118 * -> 8 bit mono, for example).
119 *
120 * The device emulation can give the audio connector(s) a scheduling hint
121 * (optional), e.g. in which interval it expects any data processing.
122 *
123 * A data transfer for playing audio data from the guest on the host looks like
124 * this: (RB = Ring Buffer, MB = Mixing Buffer)
125 *
126 * (A) Device DMA -> (B) Device RB -> (C) Audio Connector %Guest MB -> (D) Audio
127 * Connector %Host MB -> (E) Backend RB (optional, up to the backend) -> (F)
128 * Backend audio framework.
129 *
130 * When capturing audio data the chain is similar to the above one, just in a
131 * different direction, of course.
132 *
133 * The audio connector hereby plays a key role when it comes to (pre-)buffering
134 * data to minimize any audio stutters and/or cracks. The following values,
135 * which also can be tweaked via CFGM / extra-data are available:
136 *
137 * - The pre-buffering time (in ms): Audio data which needs to be buffered
138 * before any playback (or capturing) can happen.
139 * - The actual buffer size (in ms): How big the mixing buffer (for C and D)
140 * will be.
141 * - The period size (in ms): How big a chunk of audio (often called period or
142 * fragment) for F must be to get handled correctly.
143 *
144 * The above values can be set on a per-driver level, whereas input and output
145 * streams for a driver also can be handled set independently. The verbose audio
146 * (release) log will tell about the (final) state of each audio stream.
147 *
148 *
149 * @section sec_pdm_audio_diagram Diagram
150 *
151 * @todo r=bird: Not quite able to make sense of this, esp. the
152 * AUDMIXSINK/AUDIOMIXER bits crossing the LUN connections.
153 *
154 * @verbatim
155 +----------------------------------+
156 |Device (SB16 / AC'97 / HDA) |
157 |----------------------------------|
158 |AUDIOMIXER (Optional) |
159 |AUDMIXSINK0 (Optional) |
160 |AUDMIXSINK1 (Optional) |
161 |AUDMIXSINKn (Optional) |
162 | |
163 | L L L |
164 | U U U |
165 | N N N |
166 | 0 1 n |
167 +-----+----+----+------------------+
168 | | |
169 | | |
170 +--------------+ | | | +-------------+
171 |AUDMIXSINK | | | | |AUDIOMIXER |
172 |--------------| | | | |-------------|
173 |AUDMIXSTREAM0 |+-|----|----|-->|AUDMIXSINK0 |
174 |AUDMIXSTREAM1 |+-|----|----|-->|AUDMIXSINK1 |
175 |AUDMIXSTREAMn |+-|----|----|-->|AUDMIXSINKn |
176 +--------------+ | | | +-------------+
177 | | |
178 | | |
179 +----+----+----+----+
180 |LUN |
181 |-------------------|
182 |PDMIAUDIOCONNECTOR |
183 |AUDMIXSTREAM |
184 | +------+
185 | | |
186 | | |
187 | | |
188 +-------------------+ |
189 |
190 +-------------------------+ |
191 +-------------------------+ +----+--------------------+
192 |PDMAUDIOSTREAM | |PDMIAUDIOCONNECTOR |
193 |-------------------------| |-------------------------|
194 |AUDIOMIXBUF |+------>|PDMAUDIOSTREAM Host |
195 |PDMAUDIOSTREAMCFG |+------>|PDMAUDIOSTREAM Guest |
196 | | |Device capabilities |
197 | | |Device configuration |
198 | | | |
199 | | +--+|PDMIHOSTAUDIO |
200 | | | |+-----------------------+|
201 +-------------------------+ | ||Backend storage space ||
202 | |+-----------------------+|
203 | +-------------------------+
204 |
205 +---------------------+ |
206 |PDMIHOSTAUDIO | |
207 |+--------------+ | |
208 ||DirectSound | | |
209 |+--------------+ | |
210 | | |
211 |+--------------+ | |
212 ||PulseAudio | | |
213 |+--------------+ |+-------+
214 | |
215 |+--------------+ |
216 ||Core Audio | |
217 |+--------------+ |
218 | |
219 | |
220 | |
221 | |
222 +---------------------+
223 @endverbatim
224 */
225
226#ifndef VBOX_INCLUDED_vmm_pdmaudioifs_h
227#define VBOX_INCLUDED_vmm_pdmaudioifs_h
228#ifndef RT_WITHOUT_PRAGMA_ONCE
229# pragma once
230#endif
231
232#include <iprt/assertcompile.h>
233#include <iprt/circbuf.h>
234#include <iprt/list.h>
235#include <iprt/path.h>
236
237#include <VBox/types.h>
238#include <VBox/vmm/pdmcommon.h>
239#include <VBox/vmm/stam.h>
240
241/** @defgroup grp_pdm_ifs_audio PDM Audio Interfaces
242 * @ingroup grp_pdm_interfaces
243 * @{
244 */
245
246#ifndef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH
247# if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
248# define VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "c:\\temp\\"
249# else
250# define VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "/tmp/"
251# endif
252#endif
253
254/** PDM audio driver instance flags. */
255typedef uint32_t PDMAUDIODRVFLAGS;
256
257/** No flags set. */
258#define PDMAUDIODRVFLAGS_NONE 0
259/** Marks a primary audio driver which is critical
260 * when running the VM. */
261#define PDMAUDIODRVFLAGS_PRIMARY RT_BIT(0)
262
263/**
264 * Audio format in signed or unsigned variants.
265 */
266typedef enum PDMAUDIOFMT
267{
268 /** Invalid format, do not use. */
269 PDMAUDIOFMT_INVALID = 0,
270 /** 8-bit, unsigned. */
271 PDMAUDIOFMT_U8,
272 /** 8-bit, signed. */
273 PDMAUDIOFMT_S8,
274 /** 16-bit, unsigned. */
275 PDMAUDIOFMT_U16,
276 /** 16-bit, signed. */
277 PDMAUDIOFMT_S16,
278 /** 32-bit, unsigned. */
279 PDMAUDIOFMT_U32,
280 /** 32-bit, signed. */
281 PDMAUDIOFMT_S32,
282 /** End of valid values. */
283 PDMAUDIOFMT_END,
284 /** Hack to blow the type up to 32-bit. */
285 PDMAUDIOFMT_32BIT_HACK = 0x7fffffff
286} PDMAUDIOFMT;
287
288/**
289 * Audio direction.
290 */
291typedef enum PDMAUDIODIR
292{
293 /** Invalid zero value as per usual (guards against using unintialized values). */
294 PDMAUDIODIR_INVALID = 0,
295 /** Unknown direction. */
296 PDMAUDIODIR_UNKNOWN,
297 /** Input. */
298 PDMAUDIODIR_IN,
299 /** Output. */
300 PDMAUDIODIR_OUT,
301 /** Duplex handling. */
302 PDMAUDIODIR_DUPLEX,
303 /** End of valid values. */
304 PDMAUDIODIR_END,
305 /** Hack to blow the type up to 32-bit. */
306 PDMAUDIODIR_32BIT_HACK = 0x7fffffff
307} PDMAUDIODIR;
308
309/** Device latency spec in milliseconds (ms). */
310typedef uint32_t PDMAUDIODEVLATSPECMS;
311
312/** Device latency spec in seconds (s). */
313typedef uint32_t PDMAUDIODEVLATSPECSEC;
314
315/** @name PDMAUDIOHOSTDEV_F_XXX
316 * @{ */
317/** No flags set. */
318#define PDMAUDIOHOSTDEV_F_NONE UINT32_C(0)
319/** The device marks the default device within the host OS. */
320#define PDMAUDIOHOSTDEV_F_DEFAULT RT_BIT_32(0)
321/** The device can be removed at any time and we have to deal with it. */
322#define PDMAUDIOHOSTDEV_F_HOTPLUG RT_BIT_32(1)
323/** The device is known to be buggy and needs special treatment. */
324#define PDMAUDIOHOSTDEV_F_BUGGY RT_BIT_32(2)
325/** Ignore the device, no matter what. */
326#define PDMAUDIOHOSTDEV_F_IGNORE RT_BIT_32(3)
327/** The device is present but marked as locked by some other application. */
328#define PDMAUDIOHOSTDEV_F_LOCKED RT_BIT_32(4)
329/** The device is present but not in an alive state (dead). */
330#define PDMAUDIOHOSTDEV_F_DEAD RT_BIT_32(5)
331/** Set if the extra backend specific data cannot be duplicated. */
332#define PDMAUDIOHOSTDEV_F_NO_DUP RT_BIT_32(31)
333/** @} */
334
335/**
336 * Audio device type.
337 */
338typedef enum PDMAUDIODEVICETYPE
339{
340 /** Invalid zero value as per usual (guards against using unintialized values). */
341 PDMAUDIODEVICETYPE_INVALID = 0,
342 /** Unknown device type. This is the default. */
343 PDMAUDIODEVICETYPE_UNKNOWN,
344 /** Dummy device; for backends which are not able to report
345 * actual device information (yet). */
346 PDMAUDIODEVICETYPE_DUMMY,
347 /** The device is built into the host (non-removable). */
348 PDMAUDIODEVICETYPE_BUILTIN,
349 /** The device is an (external) USB device. */
350 PDMAUDIODEVICETYPE_USB,
351 /** End of valid values. */
352 PDMAUDIODEVICETYPE_END,
353 /** Hack to blow the type up to 32-bit. */
354 PDMAUDIODEVICETYPE_32BIT_HACK = 0x7fffffff
355} PDMAUDIODEVICETYPE;
356
357/**
358 * Host audio device info, part of enumeration result.
359 *
360 * @sa PDMAUDIOHOSTENUM, PDMIHOSTAUDIO::pfnGetDevices
361 */
362typedef struct PDMAUDIOHOSTDEV
363{
364 /** List entry (like PDMAUDIOHOSTENUM::LstDevices). */
365 RTLISTNODE ListEntry;
366 /** Magic value (PDMAUDIOHOSTDEV_MAGIC). */
367 uint32_t uMagic;
368 /** Size of this structure and whatever backend specific data that follows it. */
369 uint32_t cbSelf;
370 /** The device type. */
371 PDMAUDIODEVICETYPE enmType;
372 /** Usage of the device. */
373 PDMAUDIODIR enmUsage;
374 /** Device flags, PDMAUDIOHOSTDEV_F_XXX. */
375 uint32_t fFlags;
376 /** Reference count indicating how many audio streams currently are relying on this device. */
377 uint8_t cRefCount;
378 /** Maximum number of input audio channels the device supports. */
379 uint8_t cMaxInputChannels;
380 /** Maximum number of output audio channels the device supports. */
381 uint8_t cMaxOutputChannels;
382 uint8_t bAlignment;
383 /** Device type union, based on enmType. */
384 union
385 {
386 /** USB type specifics. */
387 struct
388 {
389 /** Vendor ID. */
390 uint16_t idVendor;
391 /** Product ID. */
392 uint16_t idProduct;
393 } USB;
394 uint64_t uPadding[ARCH_BITS >= 64 ? 3 : 4];
395 } Type;
396 /** Friendly name of the device, if any. Could be truncated. */
397 char szName[64];
398} PDMAUDIOHOSTDEV;
399AssertCompileSizeAlignment(PDMAUDIOHOSTDEV, 16);
400/** Pointer to audio device info (enumeration result). */
401typedef PDMAUDIOHOSTDEV *PPDMAUDIOHOSTDEV;
402/** Pointer to a const audio device info (enumeration result). */
403typedef PDMAUDIOHOSTDEV const *PCPDMAUDIOHOSTDEV;
404
405/** Magic value for PDMAUDIOHOSTDEV. */
406#define PDMAUDIOHOSTDEV_MAGIC PDM_VERSION_MAKE(0xa0d0, 1, 0)
407
408
409/**
410 * A host audio device enumeration result.
411 *
412 * @sa PDMIHOSTAUDIO::pfnGetDevices
413 */
414typedef struct PDMAUDIOHOSTENUM
415{
416 /** Magic value (PDMAUDIOHOSTENUM_MAGIC). */
417 uint32_t uMagic;
418 /** Number of audio devices in the list. */
419 uint32_t cDevices;
420 /** List of audio devices (PDMAUDIOHOSTDEV). */
421 RTLISTANCHOR LstDevices;
422} PDMAUDIOHOSTENUM;
423/** Pointer to an audio device enumeration result. */
424typedef PDMAUDIOHOSTENUM *PPDMAUDIOHOSTENUM;
425/** Pointer to a const audio device enumeration result. */
426typedef PDMAUDIOHOSTENUM const *PCPDMAUDIOHOSTENUM;
427
428/** Magic for the host audio device enumeration. */
429#define PDMAUDIOHOSTENUM_MAGIC PDM_VERSION_MAKE(0xa0d1, 1, 0)
430
431
432/**
433 * Audio configuration (static) of an audio host backend.
434 */
435typedef struct PDMAUDIOBACKENDCFG
436{
437 /** The backend's friendly name. */
438 char szName[32];
439 /** The size of the backend specific stream data (in bytes). */
440 uint32_t cbStream;
441 /** PDMAUDIOBACKEND_F_XXX. */
442 uint32_t fFlags;
443 /** Number of concurrent output (playback) streams supported on the host.
444 * UINT32_MAX for unlimited concurrent streams, 0 if no concurrent input streams are supported. */
445 uint32_t cMaxStreamsOut;
446 /** Number of concurrent input (recording) streams supported on the host.
447 * UINT32_MAX for unlimited concurrent streams, 0 if no concurrent input streams are supported. */
448 uint32_t cMaxStreamsIn;
449} PDMAUDIOBACKENDCFG;
450/** Pointer to a static host audio audio configuration. */
451typedef PDMAUDIOBACKENDCFG *PPDMAUDIOBACKENDCFG;
452
453/** @name PDMAUDIOBACKEND_F_XXX - PDMAUDIOBACKENDCFG::fFlags
454 * @{ */
455/** PDMIHOSTAUDIO::pfnStreamConfigHint should preferably be called on a
456 * worker thread rather than EMT as it may take a good while. */
457#define PDMAUDIOBACKEND_F_ASYNC_HINT RT_BIT_32(0)
458/** @} */
459
460
461/**
462 * A single audio frame.
463 *
464 * Currently only two (2) channels, left and right, are supported.
465 *
466 * @note When changing this structure, make sure to also handle
467 * VRDP's input / output processing in DrvAudioVRDE, as VRDP
468 * expects audio data in st_sample_t format (historical reasons)
469 * which happens to be the same as PDMAUDIOFRAME for now.
470 *
471 * @todo r=bird: This is an internal AudioMixBuffer structure which should not
472 * be exposed here, I think. Only used to some sizeof statements in VRDE.
473 * (The problem with exposing it, is that we would like to move away from
474 * stereo and instead to anything from 1 to 16 channels. That means
475 * removing this structure entirely.)
476 */
477typedef struct PDMAUDIOFRAME
478{
479 /** Left channel. */
480 int64_t i64LSample;
481 /** Right channel. */
482 int64_t i64RSample;
483} PDMAUDIOFRAME;
484/** Pointer to a single (stereo) audio frame. */
485typedef PDMAUDIOFRAME *PPDMAUDIOFRAME;
486/** Pointer to a const single (stereo) audio frame. */
487typedef PDMAUDIOFRAME const *PCPDMAUDIOFRAME;
488
489/**
490 * Audio playback destinations.
491 */
492typedef enum PDMAUDIOPLAYBACKDST
493{
494 /** Invalid zero value as per usual (guards against using unintialized values). */
495 PDMAUDIOPLAYBACKDST_INVALID = 0,
496 /** Unknown destination. */
497 PDMAUDIOPLAYBACKDST_UNKNOWN,
498 /** Front channel. */
499 PDMAUDIOPLAYBACKDST_FRONT,
500 /** Center / LFE (Subwoofer) channel. */
501 PDMAUDIOPLAYBACKDST_CENTER_LFE,
502 /** Rear channel. */
503 PDMAUDIOPLAYBACKDST_REAR,
504 /** End of valid values. */
505 PDMAUDIOPLAYBACKDST_END,
506 /** Hack to blow the type up to 32-bit. */
507 PDMAUDIOPLAYBACKDST_32BIT_HACK = 0x7fffffff
508} PDMAUDIOPLAYBACKDST;
509
510/**
511 * Audio recording sources.
512 *
513 * @note Because this is almost exclusively used in PDMAUDIODSTSRCUNION where it
514 * overlaps with PDMAUDIOPLAYBACKDST, the values starts at 64 instead of 0.
515 */
516typedef enum PDMAUDIORECSRC
517{
518 /** Unknown recording source. */
519 PDMAUDIORECSRC_UNKNOWN = 64,
520 /** Microphone-In. */
521 PDMAUDIORECSRC_MIC,
522 /** CD. */
523 PDMAUDIORECSRC_CD,
524 /** Video-In. */
525 PDMAUDIORECSRC_VIDEO,
526 /** AUX. */
527 PDMAUDIORECSRC_AUX,
528 /** Line-In. */
529 PDMAUDIORECSRC_LINE,
530 /** Phone-In. */
531 PDMAUDIORECSRC_PHONE,
532 /** End of valid values. */
533 PDMAUDIORECSRC_END,
534 /** Hack to blow the type up to 32-bit. */
535 PDMAUDIORECSRC_32BIT_HACK = 0x7fffffff
536} PDMAUDIORECSRC;
537
538/**
539 * Union for keeping an audio stream destination or source.
540 */
541typedef union PDMAUDIODSTSRCUNION
542{
543 /** Desired playback destination (for an output stream). */
544 PDMAUDIOPLAYBACKDST enmDst;
545 /** Desired recording source (for an input stream). */
546 PDMAUDIORECSRC enmSrc;
547} PDMAUDIODSTSRCUNION;
548/** Pointer to an audio stream src/dst union. */
549typedef PDMAUDIODSTSRCUNION *PPDMAUDIODSTSRCUNION;
550
551/**
552 * Audio stream (data) layout.
553 */
554typedef enum PDMAUDIOSTREAMLAYOUT
555{
556 /** Invalid zero value as per usual (guards against using unintialized values). */
557 PDMAUDIOSTREAMLAYOUT_INVALID = 0,
558 /** Unknown access type; do not use (hdaR3StreamMapReset uses it). */
559 PDMAUDIOSTREAMLAYOUT_UNKNOWN,
560 /** Non-interleaved access, that is, consecutive access to the data.
561 * @todo r=bird: For plain stereo this is actually interleaves left/right. What
562 * I guess non-interleaved means, is that there are no additional
563 * information interleaved next to the interleaved stereo.
564 * https://stackoverflow.com/questions/17879933/whats-the-interleaved-audio */
565 PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED,
566 /** Interleaved access, where the data can be mixed together with data of other audio streams. */
567 PDMAUDIOSTREAMLAYOUT_INTERLEAVED,
568 /** Complex layout, which does not fit into the interleaved / non-interleaved layouts. */
569 PDMAUDIOSTREAMLAYOUT_COMPLEX,
570 /** Raw (pass through) data, with no data layout processing done.
571 *
572 * This means that this stream will operate on PDMAUDIOFRAME data
573 * directly. Don't use this if you don't have to.
574 *
575 * @deprecated Replaced by S64 (signed, 64-bit sample size). */
576 PDMAUDIOSTREAMLAYOUT_RAW,
577 /** End of valid values. */
578 PDMAUDIOSTREAMLAYOUT_END,
579 /** Hack to blow the type up to 32-bit. */
580 PDMAUDIOSTREAMLAYOUT_32BIT_HACK = 0x7fffffff
581} PDMAUDIOSTREAMLAYOUT;
582
583/**
584 * Stream channel data block.
585 */
586typedef struct PDMAUDIOSTREAMCHANNELDATA
587{
588 /** Circular buffer for the channel data. */
589 PRTCIRCBUF pCircBuf;
590 /** Amount of audio data (in bytes) acquired for reading. */
591 size_t cbAcq;
592 /** Channel data flags, PDMAUDIOSTREAMCHANNELDATA_FLAGS_XXX. */
593 uint32_t fFlags;
594} PDMAUDIOSTREAMCHANNELDATA;
595/** Pointer to audio stream channel data buffer. */
596typedef PDMAUDIOSTREAMCHANNELDATA *PPDMAUDIOSTREAMCHANNELDATA;
597
598/** @name PDMAUDIOSTREAMCHANNELDATA_FLAGS_XXX
599 * @{ */
600/** No stream channel data flags defined. */
601#define PDMAUDIOSTREAMCHANNELDATA_FLAGS_NONE UINT32_C(0)
602/** @} */
603
604/**
605 * Standard speaker channel IDs.
606 *
607 * This can cover up to 11.0 surround sound.
608 *
609 * @note Any of those channels can be marked / used as the LFE channel (played
610 * through the subwoofer).
611 */
612typedef enum PDMAUDIOSTREAMCHANNELID
613{
614 /** Invalid zero value as per usual (guards against using unintialized values). */
615 PDMAUDIOSTREAMCHANNELID_INVALID = 0,
616 /** Unknown / not set channel ID. */
617 PDMAUDIOSTREAMCHANNELID_UNKNOWN,
618 /** Front left channel. */
619 PDMAUDIOSTREAMCHANNELID_FRONT_LEFT,
620 /** Front right channel. */
621 PDMAUDIOSTREAMCHANNELID_FRONT_RIGHT,
622 /** Front center channel. */
623 PDMAUDIOSTREAMCHANNELID_FRONT_CENTER,
624 /** Low frequency effects (subwoofer) channel. */
625 PDMAUDIOSTREAMCHANNELID_LFE,
626 /** Rear left channel. */
627 PDMAUDIOSTREAMCHANNELID_REAR_LEFT,
628 /** Rear right channel. */
629 PDMAUDIOSTREAMCHANNELID_REAR_RIGHT,
630 /** Front left of center channel. */
631 PDMAUDIOSTREAMCHANNELID_FRONT_LEFT_OF_CENTER,
632 /** Front right of center channel. */
633 PDMAUDIOSTREAMCHANNELID_FRONT_RIGHT_OF_CENTER,
634 /** Rear center channel. */
635 PDMAUDIOSTREAMCHANNELID_REAR_CENTER,
636 /** Side left channel. */
637 PDMAUDIOSTREAMCHANNELID_SIDE_LEFT,
638 /** Side right channel. */
639 PDMAUDIOSTREAMCHANNELID_SIDE_RIGHT,
640 /** Left height channel. */
641 PDMAUDIOSTREAMCHANNELID_LEFT_HEIGHT,
642 /** Right height channel. */
643 PDMAUDIOSTREAMCHANNELID_RIGHT_HEIGHT,
644 /** End of valid values. */
645 PDMAUDIOSTREAMCHANNELID_END,
646 /** Hack to blow the type up to 32-bit. */
647 PDMAUDIOSTREAMCHANNELID_32BIT_HACK = 0x7fffffff
648} PDMAUDIOSTREAMCHANNELID;
649
650/**
651 * Mappings channels onto an audio stream.
652 *
653 * The mappings are either for a single (mono) or dual (stereo) channels onto an
654 * audio stream (aka stream profile). An audio stream consists of one or
655 * multiple channels (e.g. 1 for mono, 2 for stereo), depending on the
656 * configuration.
657 */
658typedef struct PDMAUDIOSTREAMMAP
659{
660 /** Array of channel IDs being handled.
661 * @note The first (zero-based) index specifies the leftmost channel. */
662 PDMAUDIOSTREAMCHANNELID aenmIDs[2];
663 /** Step size (in bytes) to the channel's next frame. */
664 uint32_t cbStep;
665 /** Frame size (in bytes) of this channel. */
666 uint32_t cbFrame;
667 /** Byte offset to the first frame in the data block. */
668 uint32_t offFirst;
669 /** Byte offset to the next frame in the data block. */
670 uint32_t offNext;
671 /** Associated data buffer. */
672 PDMAUDIOSTREAMCHANNELDATA Data;
673
674 /** @todo r=bird: I'd structure this very differently.
675 * I would've had an array of channel descriptors like this:
676 *
677 * struct PDMAUDIOCHANNELDESC
678 * {
679 * uint8_t off; //< Stream offset in bytes.
680 * uint8_t id; //< PDMAUDIOSTREAMCHANNELID
681 * };
682 *
683 * And I'd baked it into PDMAUDIOPCMPROPS as a fixed sized array with 16 entries
684 * (max HDA channel count IIRC). */
685} PDMAUDIOSTREAMMAP;
686/** Pointer to an audio stream channel mapping. */
687typedef PDMAUDIOSTREAMMAP *PPDMAUDIOSTREAMMAP;
688
689/**
690 * Properties of audio streams for host/guest for in or out directions.
691 */
692typedef struct PDMAUDIOPCMPROPS
693{
694 /** The frame size. */
695 uint8_t cbFrame;
696 /** Shift count used with PDMAUDIOPCMPROPS_F2B and PDMAUDIOPCMPROPS_B2F.
697 * Depends on number of stream channels and the stream format being used, calc
698 * value using PDMAUDIOPCMPROPS_MAKE_SHIFT.
699 * @sa PDMAUDIOSTREAMCFG_B2F, PDMAUDIOSTREAMCFG_F2B */
700 uint8_t cShiftX;
701 /** Sample width (in bytes). */
702 RT_GCC_EXTENSION
703 uint8_t cbSampleX : 4;
704 /** Number of audio channels. */
705 RT_GCC_EXTENSION
706 uint8_t cChannelsX : 4;
707 /** Signed or unsigned sample. */
708 bool fSigned : 1;
709 /** Whether the endianness is swapped or not. */
710 bool fSwapEndian : 1;
711 /** Raw mixer frames, only applicable for signed 64-bit samples. */
712 bool fRaw : 1;
713 /** Sample frequency in Hertz (Hz). */
714 uint32_t uHz;
715} PDMAUDIOPCMPROPS;
716AssertCompileSize(PDMAUDIOPCMPROPS, 8);
717AssertCompileSizeAlignment(PDMAUDIOPCMPROPS, 8);
718/** Pointer to audio stream properties. */
719typedef PDMAUDIOPCMPROPS *PPDMAUDIOPCMPROPS;
720/** Pointer to const audio stream properties. */
721typedef PDMAUDIOPCMPROPS const *PCPDMAUDIOPCMPROPS;
722
723/** @name Macros for use with PDMAUDIOPCMPROPS
724 * @{ */
725/** Initializer for PDMAUDIOPCMPROPS. */
726#define PDMAUDIOPCMPROPS_INITIALIZER(a_cbSample, a_fSigned, a_cChannels, a_uHz, a_fSwapEndian) \
727 { (a_cbSample) * (a_cChannels), PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(a_cbSample, a_cChannels), a_cbSample, a_cChannels, \
728 a_fSigned, a_fSwapEndian, false /*fRaw*/, a_uHz }
729/** Calculates the cShift value of given sample bits and audio channels.
730 * @note Does only support mono/stereo channels for now, for non-stereo/mono we
731 * returns a special value which the two conversion functions detect
732 * and make them fall back on cbSample * cChannels. */
733#define PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(cbSample, cChannels) \
734 ( RT_IS_POWER_OF_TWO((unsigned)((cChannels) * (cbSample))) \
735 ? (uint8_t)(ASMBitFirstSetU32((unsigned)((cChannels) * (cbSample))) - 1) : (uint8_t)UINT8_MAX )
736/** Calculates the cShift value of a PDMAUDIOPCMPROPS structure. */
737#define PDMAUDIOPCMPROPS_MAKE_SHIFT(pProps) \
738 PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS((pProps)->cbSampleX, (pProps)->cChannelsX)
739/** Converts (audio) frames to bytes.
740 * @note Requires properly initialized properties, i.e. cbFrames correctly calculated
741 * and cShift set using PDMAUDIOPCMPROPS_MAKE_SHIFT. */
742#define PDMAUDIOPCMPROPS_F2B(pProps, cFrames) \
743 ( (pProps)->cShiftX != UINT8_MAX ? (cFrames) << (pProps)->cShiftX : (cFrames) * (pProps)->cbFrame )
744/** Converts bytes to (audio) frames.
745 * @note Requires properly initialized properties, i.e. cbFrames correctly calculated
746 * and cShift set using PDMAUDIOPCMPROPS_MAKE_SHIFT. */
747#define PDMAUDIOPCMPROPS_B2F(pProps, cb) \
748 ( (pProps)->cShiftX != UINT8_MAX ? (cb) >> (pProps)->cShiftX : (cb) / (pProps)->cbFrame )
749/** @} */
750
751/**
752 * An audio stream configuration.
753 */
754typedef struct PDMAUDIOSTREAMCFG
755{
756 /** Direction of the stream. */
757 PDMAUDIODIR enmDir;
758 /** Destination / source indicator, depending on enmDir. */
759 PDMAUDIODSTSRCUNION u;
760 /** The stream's PCM properties. */
761 PDMAUDIOPCMPROPS Props;
762 /** The stream's audio data layout.
763 * This indicates how the audio data buffers to/from the backend is being layouted.
764 *
765 * Currently, the following layouts are supported by the audio connector:
766 *
767 * PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED:
768 * One stream at once. The consecutive audio data is exactly in the format and frame width
769 * like defined in the PCM properties. This is the default.
770 *
771 * PDMAUDIOSTREAMLAYOUT_RAW:
772 * Can be one or many streams at once, depending on the stream's mixing buffer setup.
773 * The audio data will get handled as PDMAUDIOFRAME frames without any modification done.
774 *
775 * @todo r=bird: See PDMAUDIOSTREAMLAYOUT comments. */
776 PDMAUDIOSTREAMLAYOUT enmLayout;
777 /** Device emulation-specific data needed for the audio connector. */
778 struct
779 {
780 /** Scheduling hint set by the device emulation about when this stream is being served on average (in ms).
781 * Can be 0 if not hint given or some other mechanism (e.g. callbacks) is being used. */
782 uint32_t cMsSchedulingHint;
783 } Device;
784 /**
785 * Backend-specific data for the stream.
786 * On input (requested configuration) those values are set by the audio connector to let the backend know what we expect.
787 * On output (acquired configuration) those values reflect the values set and used by the backend.
788 * Set by the backend on return. Not all backends support all values / features.
789 */
790 struct
791 {
792 /** Period size of the stream (in audio frames).
793 * This value reflects the number of audio frames in between each hardware interrupt on the
794 * backend (host) side. 0 if not set / available by the backend. */
795 uint32_t cFramesPeriod;
796 /** (Ring) buffer size (in audio frames). Often is a multiple of cFramesPeriod.
797 * 0 if not set / available by the backend. */
798 uint32_t cFramesBufferSize;
799 /** Pre-buffering size (in audio frames). Frames needed in buffer before the stream becomes active (pre buffering).
800 * The bigger this value is, the more latency for the stream will occur.
801 * 0 if not set / available by the backend. UINT32_MAX if not defined (yet). */
802 uint32_t cFramesPreBuffering;
803 } Backend;
804 uint32_t u32Padding;
805 /** Friendly name of the stream. */
806 char szName[64];
807} PDMAUDIOSTREAMCFG;
808AssertCompileSizeAlignment(PDMAUDIOSTREAMCFG, 8);
809/** Pointer to audio stream configuration keeper. */
810typedef PDMAUDIOSTREAMCFG *PPDMAUDIOSTREAMCFG;
811/** Pointer to a const audio stream configuration keeper. */
812typedef PDMAUDIOSTREAMCFG const *PCPDMAUDIOSTREAMCFG;
813
814/** Converts (audio) frames to bytes. */
815#define PDMAUDIOSTREAMCFG_F2B(pCfg, frames) PDMAUDIOPCMPROPS_F2B(&(pCfg)->Props, (frames))
816/** Converts bytes to (audio) frames. */
817#define PDMAUDIOSTREAMCFG_B2F(pCfg, cb) PDMAUDIOPCMPROPS_B2F(&(pCfg)->Props, (cb))
818
819/**
820 * Audio mixer controls.
821 */
822typedef enum PDMAUDIOMIXERCTL
823{
824 /** Invalid zero value as per usual (guards against using unintialized values). */
825 PDMAUDIOMIXERCTL_INVALID = 0,
826 /** Unknown mixer control. */
827 PDMAUDIOMIXERCTL_UNKNOWN,
828 /** Master volume. */
829 PDMAUDIOMIXERCTL_VOLUME_MASTER,
830 /** Front. */
831 PDMAUDIOMIXERCTL_FRONT,
832 /** Center / LFE (Subwoofer). */
833 PDMAUDIOMIXERCTL_CENTER_LFE,
834 /** Rear. */
835 PDMAUDIOMIXERCTL_REAR,
836 /** Line-In. */
837 PDMAUDIOMIXERCTL_LINE_IN,
838 /** Microphone-In. */
839 PDMAUDIOMIXERCTL_MIC_IN,
840 /** End of valid values. */
841 PDMAUDIOMIXERCTL_END,
842 /** Hack to blow the type up to 32-bit. */
843 PDMAUDIOMIXERCTL_32BIT_HACK = 0x7fffffff
844} PDMAUDIOMIXERCTL;
845
846/**
847 * Audio stream commands.
848 *
849 * Used in the audio connector as well as in the actual host backends.
850 */
851typedef enum PDMAUDIOSTREAMCMD
852{
853 /** Invalid zero value as per usual (guards against using unintialized values). */
854 PDMAUDIOSTREAMCMD_INVALID = 0,
855 /** Enables the stream. */
856 PDMAUDIOSTREAMCMD_ENABLE,
857 /** Disables the stream.
858 * For output streams this stops the stream after playing the remaining (buffered) audio data.
859 * For input streams this will deliver the remaining (captured) audio data and not accepting
860 * any new audio input data afterwards. */
861 PDMAUDIOSTREAMCMD_DISABLE,
862 /** Pauses the stream.
863 * This is currently only issued when the VM is suspended (paused). */
864 PDMAUDIOSTREAMCMD_PAUSE,
865 /** Resumes the stream.
866 *This is currently only issued when the VM is resumed. */
867 PDMAUDIOSTREAMCMD_RESUME,
868 /** Drain the stream, that is, play what's in the buffer and then stop.
869 *
870 * A separate DISABLE command will be issued to disable the stream.
871 *
872 * @note This should not wait for the stream to finish draining, just change the
873 * state. (EMT cannot wait hundreds of milliseconds of
874 * buffer to finish draining.)
875 * @note Does not apply to input streams. Backends should refuse such requests.
876 * @note No supported by all backends. */
877 PDMAUDIOSTREAMCMD_DRAIN,
878 /** End of valid values. */
879 PDMAUDIOSTREAMCMD_END,
880 /** Hack to blow the type up to 32-bit. */
881 PDMAUDIOSTREAMCMD_32BIT_HACK = 0x7fffffff
882} PDMAUDIOSTREAMCMD;
883
884/**
885 * Audio volume parameters.
886 */
887typedef struct PDMAUDIOVOLUME
888{
889 /** Set to @c true if this stream is muted, @c false if not. */
890 bool fMuted;
891 /** Left channel volume.
892 * Range is from [0 ... 255], whereas 0 specifies
893 * the most silent and 255 the loudest value. */
894 uint8_t uLeft;
895 /** Right channel volume.
896 * Range is from [0 ... 255], whereas 0 specifies
897 * the most silent and 255 the loudest value. */
898 uint8_t uRight;
899} PDMAUDIOVOLUME;
900/** Pointer to audio volume settings. */
901typedef PDMAUDIOVOLUME *PPDMAUDIOVOLUME;
902
903/** Defines the minimum volume allowed. */
904#define PDMAUDIO_VOLUME_MIN (0)
905/** Defines the maximum volume allowed. */
906#define PDMAUDIO_VOLUME_MAX (255)
907
908
909/**
910 * Backend status.
911 */
912typedef enum PDMAUDIOBACKENDSTS
913{
914 /** Unknown/invalid status. */
915 PDMAUDIOBACKENDSTS_UNKNOWN = 0,
916 /** No backend attached. */
917 PDMAUDIOBACKENDSTS_NOT_ATTACHED,
918 /** The backend is in its initialization phase.
919 * Not all backends support this status. */
920 PDMAUDIOBACKENDSTS_INITIALIZING,
921 /** The backend has stopped its operation. */
922 PDMAUDIOBACKENDSTS_STOPPED,
923 /** The backend is up and running. */
924 PDMAUDIOBACKENDSTS_RUNNING,
925 /** The backend ran into an error and is unable to recover.
926 * A manual re-initialization might help. */
927 PDMAUDIOBACKENDSTS_ERROR,
928 /** Hack to blow the type up to 32-bit. */
929 PDMAUDIOBACKENDSTS_32BIT_HACK = 0x7fffffff
930} PDMAUDIOBACKENDSTS;
931
932/**
933 * PDM audio stream state.
934 *
935 * This is all the mixer/device needs. The PDMAUDIOSTREAM_STS_XXX stuff will
936 * become DrvAudio internal state once the backend stuff is destilled out of it.
937 *
938 * @note The value order is significant, don't change it willy-nilly.
939 */
940typedef enum PDMAUDIOSTREAMSTATE
941{
942 /** Invalid state value. */
943 PDMAUDIOSTREAMSTATE_INVALID = 0,
944 /** The stream is not operative and cannot be enabled. */
945 PDMAUDIOSTREAMSTATE_NOT_WORKING,
946 /** The stream needs to be re-initialized by the device/mixer
947 * (i.e. call PDMIAUDIOCONNECTOR::pfnStreamReInit). */
948 PDMAUDIOSTREAMSTATE_NEED_REINIT,
949 /** The stream is inactive (not enabled). */
950 PDMAUDIOSTREAMSTATE_INACTIVE,
951 /** The stream is enabled but nothing to read/write.
952 * @todo not sure if we need this variant... */
953 PDMAUDIOSTREAMSTATE_ENABLED,
954 /** The stream is enabled and captured samples can be read. */
955 PDMAUDIOSTREAMSTATE_ENABLED_READABLE,
956 /** The stream is enabled and samples can be written for playback. */
957 PDMAUDIOSTREAMSTATE_ENABLED_WRITABLE,
958 /** End of valid states. */
959 PDMAUDIOSTREAMSTATE_END,
960 /** Make sure the type is 32-bit wide. */
961 PDMAUDIOSTREAMSTATE_32BIT_HACK = 0x7fffffff
962} PDMAUDIOSTREAMSTATE;
963
964/** @name PDMAUDIOSTREAM_CREATE_F_XXX
965 * @{ */
966/** Does not need any mixing buffers, the device takes care of all conversion. */
967#define PDMAUDIOSTREAM_CREATE_F_NO_MIXBUF RT_BIT_32(0)
968/** @} */
969
970/** @name PDMAUDIOSTREAM_WARN_FLAGS_XXX
971 * @{ */
972/** No stream warning flags set. */
973#define PDMAUDIOSTREAM_WARN_FLAGS_NONE 0
974/** Warned about a disabled stream. */
975#define PDMAUDIOSTREAM_WARN_FLAGS_DISABLED RT_BIT(0)
976/** @} */
977
978/**
979 * An input or output audio stream.
980 */
981typedef struct PDMAUDIOSTREAM
982{
983 /** Magic value (PDMAUDIOSTREAM_MAGIC). */
984 uint32_t uMagic;
985 /** Audio direction of this stream. */
986 PDMAUDIODIR enmDir;
987 /** Size (in bytes) of the backend-specific stream data. */
988 uint32_t cbBackend;
989 /** Warnings shown already in the release log.
990 * See PDMAUDIOSTREAM_WARN_FLAGS_XXX. */
991 uint32_t fWarningsShown;
992 /** The stream properties (both sides when PDMAUDIOSTREAM_CREATE_F_NO_MIXBUF
993 * is used, otherwise the guest side). */
994 PDMAUDIOPCMPROPS Props;
995
996 /** Name of this stream. */
997 char szName[64];
998} PDMAUDIOSTREAM;
999/** Pointer to an audio stream. */
1000typedef struct PDMAUDIOSTREAM *PPDMAUDIOSTREAM;
1001/** Pointer to a const audio stream. */
1002typedef struct PDMAUDIOSTREAM const *PCPDMAUDIOSTREAM;
1003
1004/** Magic value for PDMAUDIOSTREAM. */
1005#define PDMAUDIOSTREAM_MAGIC PDM_VERSION_MAKE(0xa0d3, 4, 0)
1006
1007
1008
1009/** Pointer to a audio connector interface. */
1010typedef struct PDMIAUDIOCONNECTOR *PPDMIAUDIOCONNECTOR;
1011
1012/**
1013 * Audio connector interface (up).
1014 */
1015typedef struct PDMIAUDIOCONNECTOR
1016{
1017 /**
1018 * Enables or disables the given audio direction for this driver.
1019 *
1020 * When disabled, assiociated output streams consume written audio without passing them further down to the backends.
1021 * Associated input streams then return silence when read from those.
1022 *
1023 * @returns VBox status code.
1024 * @param pInterface Pointer to the interface structure containing the called function pointer.
1025 * @param enmDir Audio direction to enable or disable driver for.
1026 * @param fEnable Whether to enable or disable the specified audio direction.
1027 *
1028 * @note Be very careful when using this function, as this could
1029 * violate / run against the (global) VM settings. See @bugref{9882}.
1030 */
1031 DECLR3CALLBACKMEMBER(int, pfnEnable, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir, bool fEnable));
1032
1033 /**
1034 * Returns whether the given audio direction for this driver is enabled or not.
1035 *
1036 * @returns True if audio is enabled for the given direction, false if not.
1037 * @param pInterface Pointer to the interface structure containing the called function pointer.
1038 * @param enmDir Audio direction to retrieve enabled status for.
1039 */
1040 DECLR3CALLBACKMEMBER(bool, pfnIsEnabled, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir));
1041
1042 /**
1043 * Retrieves the current configuration of the host audio backend.
1044 *
1045 * @returns VBox status code.
1046 * @param pInterface Pointer to the interface structure containing the called function pointer.
1047 * @param pCfg Where to store the host audio backend configuration data.
1048 */
1049 DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOBACKENDCFG pCfg));
1050
1051 /**
1052 * Retrieves the current status of the host audio backend.
1053 *
1054 * @returns Status of the host audio backend.
1055 * @param pInterface Pointer to the interface structure containing the called function pointer.
1056 * @param enmDir Audio direction to check host audio backend for. Specify PDMAUDIODIR_DUPLEX for the overall
1057 * backend status.
1058 */
1059 DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir));
1060
1061 /**
1062 * Gives the audio drivers a hint about a typical configuration.
1063 *
1064 * This is a little hack for windows (and maybe other hosts) where stream
1065 * creation can take a relatively long time, making it very unsuitable for EMT.
1066 * The audio backend can use this hint to cache pre-configured stream setups,
1067 * so that when the guest actually wants to play something EMT won't be blocked
1068 * configuring host audio.
1069 *
1070 * @param pInterface Pointer to this interface.
1071 * @param pCfg The typical configuration. Can be modified by the
1072 * drivers in unspecified ways.
1073 */
1074 DECLR3CALLBACKMEMBER(void, pfnStreamConfigHint, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfg));
1075
1076 /**
1077 * Creates an audio stream.
1078 *
1079 * @returns VBox status code.
1080 * @param pInterface Pointer to the interface structure containing the called function pointer.
1081 * @param fFlags PDMAUDIOSTREAM_CREATE_F_XXX.
1082 * @param pCfgHost Stream configuration for host side.
1083 * @param pCfgGuest Stream configuration for guest side.
1084 * @param ppStream Pointer where to return the created audio stream on success.
1085 * @todo r=bird: It is not documented how pCfgHost and pCfgGuest can be
1086 * modified the DrvAudio...
1087 */
1088 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, uint32_t fFlags, PPDMAUDIOSTREAMCFG pCfgHost,
1089 PPDMAUDIOSTREAMCFG pCfgGuest, PPDMAUDIOSTREAM *ppStream));
1090
1091
1092 /**
1093 * Destroys an audio stream.
1094 *
1095 * @param pInterface Pointer to the interface structure containing the called function pointer.
1096 * @param pStream Pointer to audio stream.
1097 */
1098 DECLR3CALLBACKMEMBER(int, pfnStreamDestroy, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1099
1100 /**
1101 * Re-initializes the stream in response to PDMAUDIOSTREAM_STS_NEED_REINIT.
1102 *
1103 * @returns VBox status code.
1104 * @param pInterface Pointer to this interface.
1105 * @param pStream The audio stream needing re-initialization.
1106 */
1107 DECLR3CALLBACKMEMBER(int, pfnStreamReInit, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1108
1109 /**
1110 * Adds a reference to the specified audio stream.
1111 *
1112 * @returns New reference count. UINT32_MAX on error.
1113 * @param pInterface Pointer to the interface structure containing the called function pointer.
1114 * @param pStream Pointer to audio stream adding the reference to.
1115 */
1116 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamRetain, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1117
1118 /**
1119 * Releases a reference from the specified stream.
1120 *
1121 * @returns New reference count. UINT32_MAX on error.
1122 * @param pInterface Pointer to the interface structure containing the called function pointer.
1123 * @param pStream Pointer to audio stream releasing a reference from.
1124 */
1125 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamRelease, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1126
1127 /**
1128 * Controls a specific 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 * @param enmStreamCmd The stream command to issue.
1134 */
1135 DECLR3CALLBACKMEMBER(int, pfnStreamControl, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream,
1136 PDMAUDIOSTREAMCMD enmStreamCmd));
1137
1138 /**
1139 * Processes stream data.
1140 *
1141 * @param pInterface Pointer to the interface structure containing the called function pointer.
1142 * @param pStream Pointer to audio stream.
1143 */
1144 DECLR3CALLBACKMEMBER(int, pfnStreamIterate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1145
1146 /**
1147 * Returns the number of readable data (in bytes) of a specific audio input stream.
1148 *
1149 * @returns Number of bytes of readable data.
1150 * @param pInterface Pointer to the interface structure containing the called function pointer.
1151 * @param pStream Pointer to audio stream.
1152 */
1153 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetReadable, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1154
1155 /**
1156 * Returns the number of writable data (in bytes) of a specific audio output stream.
1157 *
1158 * @returns Number of bytes writable data.
1159 * @param pInterface Pointer to the interface structure containing the called function pointer.
1160 * @param pStream Pointer to audio stream.
1161 */
1162 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetWritable, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1163
1164 /**
1165 * Returns the state of a specific audio stream (destilled status).
1166 *
1167 * @returns PDMAUDIOSTREAMSTATE value.
1168 * @retval PDMAUDIOSTREAMSTATE_INVALID if the input isn't valid (w/ assertion).
1169 * @param pInterface Pointer to the interface structure containing the called function pointer.
1170 * @param pStream Pointer to audio stream.
1171 */
1172 DECLR3CALLBACKMEMBER(PDMAUDIOSTREAMSTATE, pfnStreamGetState, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1173
1174 /**
1175 * Sets the audio volume of a specific audio stream.
1176 *
1177 * @returns VBox status code.
1178 * @param pInterface Pointer to the interface structure containing the called function pointer.
1179 * @param pStream Pointer to audio stream.
1180 * @param pVol Pointer to audio volume structure to set the stream's audio volume to.
1181 */
1182 DECLR3CALLBACKMEMBER(int, pfnStreamSetVolume, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOVOLUME pVol));
1183
1184 /**
1185 * Plays (writes to) an audio (output) stream.
1186 *
1187 * @returns VBox status code.
1188 * @param pInterface Pointer to the interface structure containing the called function pointer.
1189 * @param pStream Pointer to audio stream to read from.
1190 * @param pvBuf Audio data to be written.
1191 * @param cbBuf Number of bytes to be written.
1192 * @param pcbWritten Bytes of audio data written. Optional.
1193 */
1194 DECLR3CALLBACKMEMBER(int, pfnStreamPlay, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream,
1195 const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten));
1196
1197 /**
1198 * Reads PCM audio data from the host (input).
1199 *
1200 * @returns VBox status code.
1201 * @param pInterface Pointer to the interface structure containing the called function pointer.
1202 * @param pStream Pointer to audio stream to write to.
1203 * @param pvBuf Where to store the read data.
1204 * @param cbBuf Number of bytes to read.
1205 * @param pcbRead Bytes of audio data read. Optional.
1206 */
1207 DECLR3CALLBACKMEMBER(int, pfnStreamRead, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream,
1208 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead));
1209
1210 /**
1211 * Captures (transfers) available audio frames from the host backend.
1212 *
1213 * Only works with input streams.
1214 *
1215 * @returns VBox status code.
1216 * @param pInterface Pointer to the interface structure containing the called function pointer.
1217 * @param pStream Pointer to audio stream.
1218 * @param pcFramesCaptured Number of frames captured. Optional.
1219 */
1220 DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream,
1221 uint32_t *pcFramesCaptured));
1222
1223} PDMIAUDIOCONNECTOR;
1224
1225/** PDMIAUDIOCONNECTOR interface ID. */
1226#define PDMIAUDIOCONNECTOR_IID "5bd85091-e99c-4092-acea-f0c5e9872408"
1227
1228
1229/**
1230 * Host audio backend specific stream data.
1231 *
1232 * The backend will put this as the first member of it's own data structure.
1233 */
1234typedef struct PDMAUDIOBACKENDSTREAM
1235{
1236 /** Magic value (PDMAUDIOBACKENDSTREAM_MAGIC). */
1237 uint32_t uMagic;
1238 /** Explicit zero padding - do not touch! */
1239 uint32_t uReserved;
1240 /** Pointer to the stream this backend data is associated with. */
1241 PPDMAUDIOSTREAM pStream;
1242 /** Reserved for future use (zeroed) - do not touch. */
1243 void *apvReserved[2];
1244} PDMAUDIOBACKENDSTREAM;
1245/** Pointer to host audio specific stream data! */
1246typedef PDMAUDIOBACKENDSTREAM *PPDMAUDIOBACKENDSTREAM;
1247
1248/** Magic value for PDMAUDIOBACKENDSTREAM. */
1249#define PDMAUDIOBACKENDSTREAM_MAGIC PDM_VERSION_MAKE(0xa0d4, 1, 0)
1250
1251/**
1252 * Host audio (backend) stream state returned by PDMIHOSTAUDIO::pfnStreamGetState.
1253 */
1254typedef enum PDMHOSTAUDIOSTREAMSTATE
1255{
1256 /** Invalid zero value, as per usual. */
1257 PDMHOSTAUDIOSTREAMSTATE_INVALID = 0,
1258 /** The stream is being initialized.
1259 * This should also be used when switching to a new device and the stream
1260 * stops to work with the old device while the new one being configured. */
1261 PDMHOSTAUDIOSTREAMSTATE_INITIALIZING,
1262 /** The stream does not work (async init failed, audio subsystem gone
1263 * fishing, or similar). */
1264 PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING,
1265 /** Backend is working okay. */
1266 PDMHOSTAUDIOSTREAMSTATE_OKAY,
1267 /** Backend is working but doesn't want any commands or data reads/writes. */
1268 PDMHOSTAUDIOSTREAMSTATE_INACTIVE,
1269 /** End of valid values. */
1270 PDMHOSTAUDIOSTREAMSTATE_END,
1271 /** Blow the type up to 32 bits. */
1272 PDMHOSTAUDIOSTREAMSTATE_32BIT_HACK = 0x7fffffff
1273} PDMHOSTAUDIOSTREAMSTATE;
1274
1275
1276/** Pointer to a host audio interface. */
1277typedef struct PDMIHOSTAUDIO *PPDMIHOSTAUDIO;
1278
1279/**
1280 * PDM host audio interface.
1281 */
1282typedef struct PDMIHOSTAUDIO
1283{
1284 /**
1285 * Returns the host backend's configuration (backend).
1286 *
1287 * @returns VBox status code.
1288 * @param pInterface Pointer to the interface structure containing the called function pointer.
1289 * @param pBackendCfg Where to store the backend audio configuration to.
1290 */
1291 DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg));
1292
1293 /**
1294 * Returns (enumerates) host audio device information (optional).
1295 *
1296 * @returns VBox status code.
1297 * @param pInterface Pointer to the interface structure containing the called function pointer.
1298 * @param pDeviceEnum Where to return the enumerated audio devices.
1299 */
1300 DECLR3CALLBACKMEMBER(int, pfnGetDevices, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHOSTENUM pDeviceEnum));
1301
1302 /**
1303 * Returns the current status from the audio backend (optional).
1304 *
1305 * @returns PDMAUDIOBACKENDSTS enum.
1306 * @param pInterface Pointer to the interface structure containing the called function pointer.
1307 * @param enmDir Audio direction to get status for. Pass PDMAUDIODIR_DUPLEX for overall status.
1308 */
1309 DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir));
1310
1311 /**
1312 * Callback for genric on-worker-thread requests initiated by the backend itself.
1313 *
1314 * This is the counterpart to PDMIHOSTAUDIOPORT::pfnDoOnWorkerThread that will
1315 * be invoked on a worker thread when the backend requests it - optional.
1316 *
1317 * This does not return a value, so the backend must keep track of
1318 * failure/success on its own.
1319 *
1320 * This method is optional. A non-NULL will, together with pfnStreamInitAsync
1321 * and PDMAUDIOBACKEND_F_ASYNC_HINT, force DrvAudio to create the thread pool.
1322 *
1323 * @param pInterface Pointer to this interface.
1324 * @param pStream Optionally a backend stream if specified in the
1325 * PDMIHOSTAUDIOPORT::pfnDoOnWorkerThread() call.
1326 * @param uUser User specific value as specified in the
1327 * PDMIHOSTAUDIOPORT::pfnDoOnWorkerThread() call.
1328 * @param pvUser User specific pointer as specified in the
1329 * PDMIHOSTAUDIOPORT::pfnDoOnWorkerThread() call.
1330 */
1331 DECLR3CALLBACKMEMBER(void, pfnDoOnWorkerThread,(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1332 uintptr_t uUser, void *pvUser));
1333
1334 /**
1335 * Gives the audio backend a hint about a typical configuration (optional).
1336 *
1337 * This is a little hack for windows (and maybe other hosts) where stream
1338 * creation can take a relatively long time, making it very unsuitable for EMT.
1339 * The audio backend can use this hint to cache pre-configured stream setups,
1340 * so that when the guest actually wants to play something EMT won't be blocked
1341 * configuring host audio.
1342 *
1343 * The backend can return PDMAUDIOBACKEND_F_ASYNC_HINT in
1344 * PDMIHOSTAUDIO::pfnGetConfig to avoid having EMT making this call and thereby
1345 * speeding up VM construction.
1346 *
1347 * @param pInterface Pointer to this interface.
1348 * @param pCfg The typical configuration. (Feel free to change it
1349 * to the actual stream config that would be used,
1350 * however caller will probably ignore this.)
1351 */
1352 DECLR3CALLBACKMEMBER(void, pfnStreamConfigHint, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAMCFG pCfg));
1353
1354 /**
1355 * Creates an audio stream using the requested stream configuration.
1356 *
1357 * If a backend is not able to create this configuration, it will return its
1358 * best match in the acquired configuration structure on success.
1359 *
1360 * @returns VBox status code.
1361 * @retval VINF_AUDIO_STREAM_ASYNC_INIT_NEEDED if
1362 * PDMIHOSTAUDIO::pfnStreamInitAsync should be called.
1363 * @param pInterface Pointer to the interface structure containing the called function pointer.
1364 * @param pStream Pointer to audio stream.
1365 * @param pCfgReq Pointer to requested stream configuration.
1366 * @param pCfgAcq Pointer to acquired stream configuration.
1367 * @todo r=bird: Implementation (at least Alsa) seems to make undocumented
1368 * assumptions about the content of @a pCfgAcq.
1369 */
1370 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1371 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq));
1372
1373 /**
1374 * Asynchronous stream initialization step, optional.
1375 *
1376 * This is called on a worker thread iff the PDMIHOSTAUDIO::pfnStreamCreate
1377 * method returns VINF_AUDIO_STREAM_ASYNC_INIT_NEEDED.
1378 *
1379 * @returns VBox status code.
1380 * @param pInterface Pointer to this interface.
1381 * @param pStream Pointer to audio stream to continue
1382 * initialization of.
1383 * @param fDestroyed Set to @c true if the stream has been destroyed
1384 * before the worker thread got to making this
1385 * call. The backend should just ready the stream
1386 * for destruction in that case.
1387 */
1388 DECLR3CALLBACKMEMBER(int, pfnStreamInitAsync, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, bool fDestroyed));
1389
1390 /**
1391 * Destroys an audio stream.
1392 *
1393 * @returns VBox status code.
1394 * @param pInterface Pointer to the interface structure containing the called function pointer.
1395 * @param pStream Pointer to audio stream.
1396 */
1397 DECLR3CALLBACKMEMBER(int, pfnStreamDestroy, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
1398
1399 /**
1400 * Called from PDMIHOSTAUDIOPORT::pfnNotifyDeviceChanged so the backend can start
1401 * the device change for a stream.
1402 *
1403 * This is mainly to avoid the need for a list of streams in the backend.
1404 *
1405 * @param pInterface Pointer to this interface.
1406 * @param pStream Pointer to audio stream.
1407 * @param pvUser Backend specific parameter from the call to
1408 * PDMIHOSTAUDIOPORT::pfnNotifyDeviceChanged.
1409 */
1410 DECLR3CALLBACKMEMBER(void, pfnStreamNotifyDeviceChanged,(PPDMIHOSTAUDIO pInterface,
1411 PPDMAUDIOBACKENDSTREAM pStream, void *pvUser));
1412
1413 /**
1414 * Controls an audio stream.
1415 *
1416 * @returns VBox status code.
1417 * @retval VERR_AUDIO_STREAM_NOT_READY if stream is not ready for required operation (yet).
1418 * @param pInterface Pointer to the interface structure containing the called function pointer.
1419 * @param pStream Pointer to audio stream.
1420 * @param enmStreamCmd The stream command to issue.
1421 */
1422 DECLR3CALLBACKMEMBER(int, pfnStreamControl, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1423 PDMAUDIOSTREAMCMD enmStreamCmd));
1424
1425 /**
1426 * Returns the amount which is readable from the audio (input) stream.
1427 *
1428 * @returns For non-raw layout streams: Number of readable bytes.
1429 * for raw layout streams : Number of readable audio frames.
1430 * @param pInterface Pointer to the interface structure containing the called function pointer.
1431 * @param pStream Pointer to audio stream.
1432 */
1433 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetReadable, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
1434
1435 /**
1436 * Returns the amount which is writable to the audio (output) stream.
1437 *
1438 * @returns Number of writable bytes.
1439 * @param pInterface Pointer to the interface structure containing the called function pointer.
1440 * @param pStream Pointer to audio stream.
1441 */
1442 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetWritable, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
1443
1444 /**
1445 * Returns the number of buffered bytes that hasn't been played yet (optional).
1446 *
1447 * This function is used by DrvAudio to detect when it is appropriate to fully
1448 * disable an output stream w/o cutting off the playback too early. The backend
1449 * should have already received the PDMAUDIOSTREAMCMD_DRAIN command prior to
1450 * this. It doesn't really matter whether the returned value is 100% correct,
1451 * as long as it isn't reported as zero too early (and that zero is reported).
1452 *
1453 * Is not valid on an input stream, implementions shall assert and return zero.
1454 *
1455 * @returns Number of pending bytes.
1456 * @param pInterface Pointer to this interface.
1457 * @param pStream Pointer to audio stream.
1458 *
1459 * @remarks This interface can be omitted if the backend properly implements the
1460 * drain operation, i.e. automatically disables the stream when done
1461 * draining and ignores any requests to disable the stream while doing
1462 * so (there will probably be one right after initiating draining).
1463 */
1464 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetPending, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
1465
1466 /**
1467 * Returns the current state of the given backend stream.
1468 *
1469 * @returns PDMHOSTAUDIOSTREAMSTATE value.
1470 * @retval PDMHOSTAUDIOSTREAMSTATE_INVALID if invalid stream.
1471 * @param pInterface Pointer to the interface structure containing the called function pointer.
1472 * @param pStream Pointer to audio stream.
1473 */
1474 DECLR3CALLBACKMEMBER(PDMHOSTAUDIOSTREAMSTATE, pfnStreamGetState, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
1475
1476 /**
1477 * Plays (writes to) an audio (output) stream.
1478 *
1479 * @returns VBox status code.
1480 * @param pInterface Pointer to the interface structure containing the called function pointer.
1481 * @param pStream Pointer to audio stream.
1482 * @param pvBuf Pointer to audio data buffer to play.
1483 * @param cbBuf The number of bytes of audio data to play.
1484 * @param pcbWritten Where to return the actual number of bytes played.
1485 */
1486 DECLR3CALLBACKMEMBER(int, pfnStreamPlay, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1487 const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten));
1488
1489 /**
1490 * Captures (reads from) an audio (input) stream.
1491 *
1492 * @returns VBox status code.
1493 * @param pInterface Pointer to the interface structure containing the called function pointer.
1494 * @param pStream Pointer to audio stream.
1495 * @param pvBuf Buffer where to store read audio data.
1496 * @param cbBuf Size of the audio data buffer in bytes.
1497 * @param pcbRead Where to return the number of bytes actually captured.
1498 */
1499 DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1500 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead));
1501} PDMIHOSTAUDIO;
1502
1503/** PDMIHOSTAUDIO interface ID. */
1504#define PDMIHOSTAUDIO_IID "53949a0a-ca2d-4d25-869f-2a8357991293"
1505
1506
1507/** Pointer to a audio notify from host interface. */
1508typedef struct PDMIHOSTAUDIOPORT *PPDMIHOSTAUDIOPORT;
1509
1510/**
1511 * PDM host audio port interface, upwards sibling of PDMIHOSTAUDIO.
1512 */
1513typedef struct PDMIHOSTAUDIOPORT
1514{
1515 /**
1516 * Ask DrvAudio to call PDMIHOSTAUDIO::pfnDoOnWorkerThread on a worker thread.
1517 *
1518 * Generic method for doing asynchronous work using the DrvAudio thread pool.
1519 *
1520 * This function will not wait for PDMIHOSTAUDIO::pfnDoOnWorkerThread to
1521 * complete, but returns immediately after submitting the request to the thread
1522 * pool.
1523 *
1524 * @returns VBox status code.
1525 * @param pInterface Pointer to this interface.
1526 * @param pStream Optional backend stream structure to pass along. The
1527 * reference count will be increased till the call
1528 * completes to make sure the stream stays valid.
1529 * @param uUser User specific value.
1530 * @param pvUser User specific pointer.
1531 */
1532 DECLR3CALLBACKMEMBER(int, pfnDoOnWorkerThread,(PPDMIHOSTAUDIOPORT pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1533 uintptr_t uUser, void *pvUser));
1534
1535 /**
1536 * The device for the given direction changed.
1537 *
1538 * The driver above backend (DrvAudio) will call the backend back
1539 * (PDMIHOSTAUDIO::pfnStreamNotifyDeviceChanged) for all open streams in the
1540 * given direction. (This ASSUMES the backend uses one output device and one
1541 * input devices for all streams.)
1542 *
1543 * @param pInterface Pointer to this interface.
1544 * @param enmDir The audio direction.
1545 * @param pvUser Backend specific parameter for
1546 * PDMIHOSTAUDIO::pfnStreamNotifyDeviceChanged.
1547 */
1548 DECLR3CALLBACKMEMBER(void, pfnNotifyDeviceChanged,(PPDMIHOSTAUDIOPORT pInterface, PDMAUDIODIR enmDir, void *pvUser));
1549
1550 /**
1551 * Notification that the stream is about to change device in a bit.
1552 *
1553 * This will assume PDMAUDIOSTREAM_STS_PREPARING_SWITCH will be set when
1554 * PDMIHOSTAUDIO::pfnStreamGetStatus is next called and change the stream state
1555 * accordingly.
1556 *
1557 * @param pInterface Pointer to this interface.
1558 * @param pStream The stream that changed device (backend variant).
1559 */
1560 DECLR3CALLBACKMEMBER(void, pfnStreamNotifyPreparingDeviceSwitch,(PPDMIHOSTAUDIOPORT pInterface,
1561 PPDMAUDIOBACKENDSTREAM pStream));
1562
1563 /**
1564 * The stream has changed its device and left the
1565 * PDMAUDIOSTREAM_STS_PREPARING_SWITCH state (if it entered it at all).
1566 *
1567 * @param pInterface Pointer to this interface.
1568 * @param pStream The stream that changed device (backend variant).
1569 * @param fReInit Set if a re-init is required, clear if not.
1570 */
1571 DECLR3CALLBACKMEMBER(void, pfnStreamNotifyDeviceChanged,(PPDMIHOSTAUDIOPORT pInterface,
1572 PPDMAUDIOBACKENDSTREAM pStream, bool fReInit));
1573
1574 /**
1575 * One or more audio devices have changed in some way.
1576 *
1577 * The upstream driver/device should re-evaluate the devices they're using.
1578 *
1579 * @todo r=bird: The upstream driver/device does not know which host audio
1580 * devices they are using. This is mainly for triggering enumeration and
1581 * logging of the audio devices.
1582 *
1583 * @param pInterface Pointer to this interface.
1584 */
1585 DECLR3CALLBACKMEMBER(void, pfnNotifyDevicesChanged,(PPDMIHOSTAUDIOPORT pInterface));
1586} PDMIHOSTAUDIOPORT;
1587
1588/** PDMIHOSTAUDIOPORT interface ID. */
1589#define PDMIHOSTAUDIOPORT_IID "1aa566e2-b3df-4b8a-9f80-99bdcb5e9964"
1590
1591/** @} */
1592
1593#endif /* !VBOX_INCLUDED_vmm_pdmaudioifs_h */
1594
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