VirtualBox

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

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

Audio: Changed PDMAUDIO_MAX_CHANNELS to 12 since PDMAUDIOPCMPROPS can only store up to 15. bugref:9890

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 66.0 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/critsect.h>
234#include <iprt/circbuf.h>
235#include <iprt/list.h>
236#include <iprt/path.h>
237
238#include <VBox/types.h>
239#include <VBox/vmm/pdmcommon.h>
240#include <VBox/vmm/stam.h>
241
242RT_C_DECLS_BEGIN
243
244
245/** @defgroup grp_pdm_ifs_audio PDM Audio Interfaces
246 * @ingroup grp_pdm_interfaces
247 * @{
248 */
249
250/** The maximum number of channels PDM supports. */
251#define PDMAUDIO_MAX_CHANNELS 12
252
253/**
254 * Audio direction.
255 */
256typedef enum PDMAUDIODIR
257{
258 /** Invalid zero value as per usual (guards against using unintialized values). */
259 PDMAUDIODIR_INVALID = 0,
260 /** Unknown direction. */
261 PDMAUDIODIR_UNKNOWN,
262 /** Input. */
263 PDMAUDIODIR_IN,
264 /** Output. */
265 PDMAUDIODIR_OUT,
266 /** Duplex handling. */
267 PDMAUDIODIR_DUPLEX,
268 /** End of valid values. */
269 PDMAUDIODIR_END,
270 /** Hack to blow the type up to 32-bit. */
271 PDMAUDIODIR_32BIT_HACK = 0x7fffffff
272} PDMAUDIODIR;
273
274
275/** @name PDMAUDIOHOSTDEV_F_XXX
276 * @{ */
277/** No flags set. */
278#define PDMAUDIOHOSTDEV_F_NONE UINT32_C(0)
279/** The default input (capture/recording) device (for the user). */
280#define PDMAUDIOHOSTDEV_F_DEFAULT_IN RT_BIT_32(0)
281/** The default output (playback) device (for the user). */
282#define PDMAUDIOHOSTDEV_F_DEFAULT_OUT RT_BIT_32(1)
283/** The device can be removed at any time and we have to deal with it. */
284#define PDMAUDIOHOSTDEV_F_HOTPLUG RT_BIT_32(2)
285/** The device is known to be buggy and needs special treatment. */
286#define PDMAUDIOHOSTDEV_F_BUGGY RT_BIT_32(3)
287/** Ignore the device, no matter what. */
288#define PDMAUDIOHOSTDEV_F_IGNORE RT_BIT_32(4)
289/** The device is present but marked as locked by some other application. */
290#define PDMAUDIOHOSTDEV_F_LOCKED RT_BIT_32(5)
291/** The device is present but not in an alive state (dead). */
292#define PDMAUDIOHOSTDEV_F_DEAD RT_BIT_32(6)
293/** Set if the PDMAUDIOHOSTDEV::pszId is allocated. */
294#define PDMAUDIOHOSTDEV_F_ID_ALLOC RT_BIT_32(30)
295/** Set if the extra backend specific data cannot be duplicated. */
296#define PDMAUDIOHOSTDEV_F_NO_DUP RT_BIT_32(31)
297/** @} */
298
299/**
300 * Audio device type.
301 */
302typedef enum PDMAUDIODEVICETYPE
303{
304 /** Invalid zero value as per usual (guards against using unintialized values). */
305 PDMAUDIODEVICETYPE_INVALID = 0,
306 /** Unknown device type. This is the default. */
307 PDMAUDIODEVICETYPE_UNKNOWN,
308 /** Dummy device; for backends which are not able to report
309 * actual device information (yet). */
310 PDMAUDIODEVICETYPE_DUMMY,
311 /** The device is built into the host (non-removable). */
312 PDMAUDIODEVICETYPE_BUILTIN,
313 /** The device is an (external) USB device. */
314 PDMAUDIODEVICETYPE_USB,
315 /** End of valid values. */
316 PDMAUDIODEVICETYPE_END,
317 /** Hack to blow the type up to 32-bit. */
318 PDMAUDIODEVICETYPE_32BIT_HACK = 0x7fffffff
319} PDMAUDIODEVICETYPE;
320
321/**
322 * Host audio device info, part of enumeration result.
323 *
324 * @sa PDMAUDIOHOSTENUM, PDMIHOSTAUDIO::pfnGetDevices
325 */
326typedef struct PDMAUDIOHOSTDEV
327{
328 /** List entry (like PDMAUDIOHOSTENUM::LstDevices). */
329 RTLISTNODE ListEntry;
330 /** Magic value (PDMAUDIOHOSTDEV_MAGIC). */
331 uint32_t uMagic;
332 /** Size of this structure and whatever backend specific data that follows it. */
333 uint32_t cbSelf;
334 /** The device type. */
335 PDMAUDIODEVICETYPE enmType;
336 /** Usage of the device. */
337 PDMAUDIODIR enmUsage;
338 /** Device flags, PDMAUDIOHOSTDEV_F_XXX. */
339 uint32_t fFlags;
340 /** Maximum number of input audio channels the device supports. */
341 uint8_t cMaxInputChannels;
342 /** Maximum number of output audio channels the device supports. */
343 uint8_t cMaxOutputChannels;
344 uint8_t abAlignment[ARCH_BITS == 32 ? 2 + 12 : 2];
345 /** Backend specific device identifier, can be NULL, used to select device.
346 * This can either point into some non-public part of this structure or to a
347 * RTStrAlloc allocation. PDMAUDIOHOSTDEV_F_ID_ALLOC is set in the latter
348 * case.
349 * @sa PDMIHOSTAUDIO::pfnSetDevice */
350 char *pszId;
351 /** Friendly name of the device, if any. Could be truncated. */
352 char szName[64];
353} PDMAUDIOHOSTDEV;
354AssertCompileSizeAlignment(PDMAUDIOHOSTDEV, 16);
355/** Pointer to audio device info (enumeration result). */
356typedef PDMAUDIOHOSTDEV *PPDMAUDIOHOSTDEV;
357/** Pointer to a const audio device info (enumeration result). */
358typedef PDMAUDIOHOSTDEV const *PCPDMAUDIOHOSTDEV;
359
360/** Magic value for PDMAUDIOHOSTDEV. */
361#define PDMAUDIOHOSTDEV_MAGIC PDM_VERSION_MAKE(0xa0d0, 2, 0)
362
363
364/**
365 * A host audio device enumeration result.
366 *
367 * @sa PDMIHOSTAUDIO::pfnGetDevices
368 */
369typedef struct PDMAUDIOHOSTENUM
370{
371 /** Magic value (PDMAUDIOHOSTENUM_MAGIC). */
372 uint32_t uMagic;
373 /** Number of audio devices in the list. */
374 uint32_t cDevices;
375 /** List of audio devices (PDMAUDIOHOSTDEV). */
376 RTLISTANCHOR LstDevices;
377} PDMAUDIOHOSTENUM;
378/** Pointer to an audio device enumeration result. */
379typedef PDMAUDIOHOSTENUM *PPDMAUDIOHOSTENUM;
380/** Pointer to a const audio device enumeration result. */
381typedef PDMAUDIOHOSTENUM const *PCPDMAUDIOHOSTENUM;
382
383/** Magic for the host audio device enumeration. */
384#define PDMAUDIOHOSTENUM_MAGIC PDM_VERSION_MAKE(0xa0d1, 1, 0)
385
386
387/**
388 * Audio configuration (static) of an audio host backend.
389 */
390typedef struct PDMAUDIOBACKENDCFG
391{
392 /** The backend's friendly name. */
393 char szName[32];
394 /** The size of the backend specific stream data (in bytes). */
395 uint32_t cbStream;
396 /** PDMAUDIOBACKEND_F_XXX. */
397 uint32_t fFlags;
398 /** Number of concurrent output (playback) streams supported on the host.
399 * UINT32_MAX for unlimited concurrent streams, 0 if no concurrent input streams are supported. */
400 uint32_t cMaxStreamsOut;
401 /** Number of concurrent input (recording) streams supported on the host.
402 * UINT32_MAX for unlimited concurrent streams, 0 if no concurrent input streams are supported. */
403 uint32_t cMaxStreamsIn;
404} PDMAUDIOBACKENDCFG;
405/** Pointer to a static host audio audio configuration. */
406typedef PDMAUDIOBACKENDCFG *PPDMAUDIOBACKENDCFG;
407
408/** @name PDMAUDIOBACKEND_F_XXX - PDMAUDIOBACKENDCFG::fFlags
409 * @{ */
410/** PDMIHOSTAUDIO::pfnStreamConfigHint should preferably be called on a
411 * worker thread rather than EMT as it may take a good while. */
412#define PDMAUDIOBACKEND_F_ASYNC_HINT RT_BIT_32(0)
413/** PDMIHOSTAUDIO::pfnStreamDestroy and any preceeding
414 * PDMIHOSTAUDIO::pfnStreamControl/DISABLE should be preferably be called on a
415 * worker thread rather than EMT as it may take a good while. */
416#define PDMAUDIOBACKEND_F_ASYNC_STREAM_DESTROY RT_BIT_32(1)
417/** @} */
418
419
420/**
421 * A single audio frame.
422 *
423 * Currently only two (2) channels, left and right, are supported.
424 *
425 * @note When changing this structure, make sure to also handle
426 * VRDP's input / output processing in DrvAudioVRDE, as VRDP
427 * expects audio data in st_sample_t format (historical reasons)
428 * which happens to be the same as PDMAUDIOFRAME for now.
429 *
430 * @todo r=bird: This is an internal AudioMixBuffer structure which should not
431 * be exposed here, I think. Only used to some sizeof statements in VRDE.
432 * (The problem with exposing it, is that we would like to move away from
433 * stereo and instead to anything from 1 to 16 channels. That means
434 * removing this structure entirely.)
435 */
436typedef struct PDMAUDIOFRAME
437{
438 /** Left channel. */
439 int64_t i64LSample;
440 /** Right channel. */
441 int64_t i64RSample;
442} PDMAUDIOFRAME;
443/** Pointer to a single (stereo) audio frame. */
444typedef PDMAUDIOFRAME *PPDMAUDIOFRAME;
445/** Pointer to a const single (stereo) audio frame. */
446typedef PDMAUDIOFRAME const *PCPDMAUDIOFRAME;
447
448
449/**
450 * Audio path: input sources and playback destinations.
451 *
452 * Think of this as the name of the socket you plug the virtual audio stream
453 * jack into.
454 *
455 * @note Not quite sure what the purpose of this type is. It used to be two
456 * separate enums (PDMAUDIOPLAYBACKDST & PDMAUDIORECSRC) without overlapping
457 * values and most commonly used in a union (PDMAUDIODSTSRCUNION). The output
458 * values were designated "channel" (e.g. "Front channel"), whereas this was not
459 * done to the input ones. So, I'm (bird) a little confused what the actual
460 * meaning was.
461 */
462typedef enum PDMAUDIOPATH
463{
464 /** Customary invalid zero value. */
465 PDMAUDIOPATH_INVALID = 0,
466
467 /** Unknown path / Doesn't care. */
468 PDMAUDIOPATH_UNKNOWN,
469
470 /** First output value. */
471 PDMAUDIOPATH_OUT_FIRST,
472 /** Output: Front. */
473 PDMAUDIOPATH_OUT_FRONT = PDMAUDIOPATH_OUT_FIRST,
474 /** Output: Center / LFE (Subwoofer). */
475 PDMAUDIOPATH_OUT_CENTER_LFE,
476 /** Output: Rear. */
477 PDMAUDIOPATH_OUT_REAR,
478 /** Last output value (inclusive) */
479 PDMAUDIOPATH_OUT_END = PDMAUDIOPATH_OUT_REAR,
480
481 /** First input value. */
482 PDMAUDIOPATH_IN_FIRST,
483 /** Input: Microphone. */
484 PDMAUDIOPATH_IN_MIC = PDMAUDIOPATH_IN_FIRST,
485 /** Input: CD. */
486 PDMAUDIOPATH_IN_CD,
487 /** Input: Video-In. */
488 PDMAUDIOPATH_IN_VIDEO,
489 /** Input: AUX. */
490 PDMAUDIOPATH_IN_AUX,
491 /** Input: Line-In. */
492 PDMAUDIOPATH_IN_LINE,
493 /** Input: Phone-In. */
494 PDMAUDIOPATH_IN_PHONE,
495 /** Last intput value (inclusive). */
496 PDMAUDIOPATH_IN_LAST = PDMAUDIOPATH_IN_PHONE,
497
498 /** End of valid values. */
499 PDMAUDIOPATH_END,
500 /** Hack to blow the typ up to 32 bits. */
501 PDMAUDIOPATH_32BIT_HACK = 0x7fffffff
502} PDMAUDIOPATH;
503
504/**
505 * Audio stream (data) layout.
506 */
507typedef enum PDMAUDIOSTREAMLAYOUT
508{
509 /** Invalid zero value as per usual (guards against using unintialized values). */
510 PDMAUDIOSTREAMLAYOUT_INVALID = 0,
511 /** Unknown access type; do not use (hdaR3StreamMapReset uses it). */
512 PDMAUDIOSTREAMLAYOUT_UNKNOWN,
513 /** Non-interleaved access, that is, consecutive access to the data.
514 * @todo r=bird: For plain stereo this is actually interleaves left/right. What
515 * I guess non-interleaved means, is that there are no additional
516 * information interleaved next to the interleaved stereo.
517 * https://stackoverflow.com/questions/17879933/whats-the-interleaved-audio */
518 PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED,
519 /** Interleaved access, where the data can be mixed together with data of other audio streams. */
520 PDMAUDIOSTREAMLAYOUT_INTERLEAVED,
521 /** Complex layout, which does not fit into the interleaved / non-interleaved layouts. */
522 PDMAUDIOSTREAMLAYOUT_COMPLEX,
523 /** Raw (pass through) data, with no data layout processing done.
524 *
525 * This means that this stream will operate on PDMAUDIOFRAME data
526 * directly. Don't use this if you don't have to.
527 *
528 * @deprecated Replaced by S64 (signed, 64-bit sample size). */
529 PDMAUDIOSTREAMLAYOUT_RAW,
530 /** End of valid values. */
531 PDMAUDIOSTREAMLAYOUT_END,
532 /** Hack to blow the type up to 32-bit. */
533 PDMAUDIOSTREAMLAYOUT_32BIT_HACK = 0x7fffffff
534} PDMAUDIOSTREAMLAYOUT;
535
536/**
537 * Stream channel data block.
538 */
539typedef struct PDMAUDIOSTREAMCHANNELDATA
540{
541 /** Circular buffer for the channel data. */
542 PRTCIRCBUF pCircBuf;
543 /** Amount of audio data (in bytes) acquired for reading. */
544 size_t cbAcq;
545 /** Channel data flags, PDMAUDIOSTREAMCHANNELDATA_FLAGS_XXX. */
546 uint32_t fFlags;
547} PDMAUDIOSTREAMCHANNELDATA;
548/** Pointer to audio stream channel data buffer. */
549typedef PDMAUDIOSTREAMCHANNELDATA *PPDMAUDIOSTREAMCHANNELDATA;
550
551/** @name PDMAUDIOSTREAMCHANNELDATA_FLAGS_XXX
552 * @{ */
553/** No stream channel data flags defined. */
554#define PDMAUDIOSTREAMCHANNELDATA_FLAGS_NONE UINT32_C(0)
555/** @} */
556
557/**
558 * Standard speaker channel IDs.
559 *
560 * This can cover up to 11.0 surround sound.
561 *
562 * @note Any of those channels can be marked / used as the LFE channel (played
563 * through the subwoofer).
564 */
565typedef enum PDMAUDIOSTREAMCHANNELID
566{
567 /** Invalid zero value as per usual (guards against using unintialized values). */
568 PDMAUDIOSTREAMCHANNELID_INVALID = 0,
569 /** Unknown / not set channel ID. */
570 PDMAUDIOSTREAMCHANNELID_UNKNOWN,
571 /** Front left channel. */
572 PDMAUDIOSTREAMCHANNELID_FRONT_LEFT,
573 /** Front right channel. */
574 PDMAUDIOSTREAMCHANNELID_FRONT_RIGHT,
575 /** Front center channel. */
576 PDMAUDIOSTREAMCHANNELID_FRONT_CENTER,
577 /** Low frequency effects (subwoofer) channel. */
578 PDMAUDIOSTREAMCHANNELID_LFE,
579 /** Rear left channel. */
580 PDMAUDIOSTREAMCHANNELID_REAR_LEFT,
581 /** Rear right channel. */
582 PDMAUDIOSTREAMCHANNELID_REAR_RIGHT,
583 /** Front left of center channel. */
584 PDMAUDIOSTREAMCHANNELID_FRONT_LEFT_OF_CENTER,
585 /** Front right of center channel. */
586 PDMAUDIOSTREAMCHANNELID_FRONT_RIGHT_OF_CENTER,
587 /** Rear center channel. */
588 PDMAUDIOSTREAMCHANNELID_REAR_CENTER,
589 /** Side left channel. */
590 PDMAUDIOSTREAMCHANNELID_SIDE_LEFT,
591 /** Side right channel. */
592 PDMAUDIOSTREAMCHANNELID_SIDE_RIGHT,
593 /** Left height channel. */
594 PDMAUDIOSTREAMCHANNELID_LEFT_HEIGHT,
595 /** Right height channel. */
596 PDMAUDIOSTREAMCHANNELID_RIGHT_HEIGHT,
597 /** End of valid values. */
598 PDMAUDIOSTREAMCHANNELID_END,
599 /** Hack to blow the type up to 32-bit. */
600 PDMAUDIOSTREAMCHANNELID_32BIT_HACK = 0x7fffffff
601} PDMAUDIOSTREAMCHANNELID;
602
603/**
604 * Mappings channels onto an audio stream.
605 *
606 * The mappings are either for a single (mono) or dual (stereo) channels onto an
607 * audio stream (aka stream profile). An audio stream consists of one or
608 * multiple channels (e.g. 1 for mono, 2 for stereo), depending on the
609 * configuration.
610 */
611typedef struct PDMAUDIOSTREAMMAP
612{
613 /** Array of channel IDs being handled.
614 * @note The first (zero-based) index specifies the leftmost channel. */
615 PDMAUDIOSTREAMCHANNELID aenmIDs[2];
616 /** Step size (in bytes) to the channel's next frame. */
617 uint32_t cbStep;
618 /** Frame size (in bytes) of this channel. */
619 uint32_t cbFrame;
620 /** Byte offset to the first frame in the data block. */
621 uint32_t offFirst;
622 /** Byte offset to the next frame in the data block. */
623 uint32_t offNext;
624 /** Associated data buffer. */
625 PDMAUDIOSTREAMCHANNELDATA Data;
626
627 /** @todo r=bird: I'd structure this very differently.
628 * I would've had an array of channel descriptors like this:
629 *
630 * struct PDMAUDIOCHANNELDESC
631 * {
632 * uint8_t off; //< Stream offset in bytes.
633 * uint8_t id; //< PDMAUDIOSTREAMCHANNELID
634 * };
635 *
636 * And I'd baked it into PDMAUDIOPCMPROPS as a fixed sized array with 16 entries
637 * (max HDA channel count IIRC). */
638} PDMAUDIOSTREAMMAP;
639/** Pointer to an audio stream channel mapping. */
640typedef PDMAUDIOSTREAMMAP *PPDMAUDIOSTREAMMAP;
641
642/**
643 * Properties of audio streams for host/guest for in or out directions.
644 */
645typedef struct PDMAUDIOPCMPROPS
646{
647 /** The frame size. */
648 uint8_t cbFrame;
649 /** Shift count used with PDMAUDIOPCMPROPS_F2B and PDMAUDIOPCMPROPS_B2F.
650 * Depends on number of stream channels and the stream format being used, calc
651 * value using PDMAUDIOPCMPROPS_MAKE_SHIFT.
652 * @sa PDMAUDIOSTREAMCFG_B2F, PDMAUDIOSTREAMCFG_F2B */
653 uint8_t cShiftX;
654 /** Sample width (in bytes). */
655 RT_GCC_EXTENSION
656 uint8_t cbSampleX : 4;
657 /** Number of audio channels. */
658 RT_GCC_EXTENSION
659 uint8_t cChannelsX : 4;
660 /** Signed or unsigned sample. */
661 bool fSigned : 1;
662 /** Whether the endianness is swapped or not. */
663 bool fSwapEndian : 1;
664 /** Raw mixer frames, only applicable for signed 64-bit samples.
665 * The raw mixer samples are really just signed 32-bit samples stored as 64-bit
666 * integers without any change in the value.
667 *
668 * @todo Get rid of this, only VRDE needs it an it should use the common
669 * mixer code rather than cooking its own stuff. */
670 bool fRaw : 1;
671 /** Sample frequency in Hertz (Hz). */
672 uint32_t uHz;
673} PDMAUDIOPCMPROPS;
674AssertCompileSize(PDMAUDIOPCMPROPS, 8);
675AssertCompileSizeAlignment(PDMAUDIOPCMPROPS, 8);
676/** Pointer to audio stream properties. */
677typedef PDMAUDIOPCMPROPS *PPDMAUDIOPCMPROPS;
678/** Pointer to const audio stream properties. */
679typedef PDMAUDIOPCMPROPS const *PCPDMAUDIOPCMPROPS;
680
681/** @name Macros for use with PDMAUDIOPCMPROPS
682 * @{ */
683/** Initializer for PDMAUDIOPCMPROPS. */
684#define PDMAUDIOPCMPROPS_INITIALIZER(a_cbSample, a_fSigned, a_cChannels, a_uHz, a_fSwapEndian) \
685 { (a_cbSample) * (a_cChannels), PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(a_cbSample, a_cChannels), a_cbSample, a_cChannels, \
686 a_fSigned, a_fSwapEndian, false /*fRaw*/, a_uHz }
687/** Calculates the cShift value of given sample bits and audio channels.
688 * @note Does only support mono/stereo channels for now, for non-stereo/mono we
689 * returns a special value which the two conversion functions detect
690 * and make them fall back on cbSample * cChannels. */
691#define PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(cbSample, cChannels) \
692 ( RT_IS_POWER_OF_TWO((unsigned)((cChannels) * (cbSample))) \
693 ? (uint8_t)(ASMBitFirstSetU32((unsigned)((cChannels) * (cbSample))) - 1) : (uint8_t)UINT8_MAX )
694/** Calculates the cShift value of a PDMAUDIOPCMPROPS structure. */
695#define PDMAUDIOPCMPROPS_MAKE_SHIFT(pProps) \
696 PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS((pProps)->cbSampleX, (pProps)->cChannelsX)
697/** Converts (audio) frames to bytes.
698 * @note Requires properly initialized properties, i.e. cbFrames correctly calculated
699 * and cShift set using PDMAUDIOPCMPROPS_MAKE_SHIFT. */
700#define PDMAUDIOPCMPROPS_F2B(pProps, cFrames) \
701 ( (pProps)->cShiftX != UINT8_MAX ? (cFrames) << (pProps)->cShiftX : (cFrames) * (pProps)->cbFrame )
702/** Converts bytes to (audio) frames.
703 * @note Requires properly initialized properties, i.e. cbFrames correctly calculated
704 * and cShift set using PDMAUDIOPCMPROPS_MAKE_SHIFT. */
705#define PDMAUDIOPCMPROPS_B2F(pProps, cb) \
706 ( (pProps)->cShiftX != UINT8_MAX ? (cb) >> (pProps)->cShiftX : (cb) / (pProps)->cbFrame )
707/** @} */
708
709/**
710 * An audio stream configuration.
711 */
712typedef struct PDMAUDIOSTREAMCFG
713{
714 /** Direction of the stream. */
715 PDMAUDIODIR enmDir;
716 /** Destination / source path. */
717 PDMAUDIOPATH enmPath;
718 /** The stream's PCM properties. */
719 PDMAUDIOPCMPROPS Props;
720 /** The stream's audio data layout.
721 * This indicates how the audio data buffers to/from the backend is being layouted.
722 *
723 * Currently, the following layouts are supported by the audio connector:
724 *
725 * PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED:
726 * One stream at once. The consecutive audio data is exactly in the format and frame width
727 * like defined in the PCM properties. This is the default.
728 *
729 * PDMAUDIOSTREAMLAYOUT_RAW:
730 * Can be one or many streams at once, depending on the stream's mixing buffer setup.
731 * The audio data will get handled as PDMAUDIOFRAME frames without any modification done.
732 *
733 * @todo r=bird: See PDMAUDIOSTREAMLAYOUT comments. */
734 PDMAUDIOSTREAMLAYOUT enmLayout;
735 /** Device emulation-specific data needed for the audio connector. */
736 struct
737 {
738 /** Scheduling hint set by the device emulation about when this stream is being served on average (in ms).
739 * Can be 0 if not hint given or some other mechanism (e.g. callbacks) is being used. */
740 uint32_t cMsSchedulingHint;
741 } Device;
742 /**
743 * Backend-specific data for the stream.
744 * On input (requested configuration) those values are set by the audio connector to let the backend know what we expect.
745 * On output (acquired configuration) those values reflect the values set and used by the backend.
746 * Set by the backend on return. Not all backends support all values / features.
747 */
748 struct
749 {
750 /** Period size of the stream (in audio frames).
751 * This value reflects the number of audio frames in between each hardware interrupt on the
752 * backend (host) side. 0 if not set / available by the backend. */
753 uint32_t cFramesPeriod;
754 /** (Ring) buffer size (in audio frames). Often is a multiple of cFramesPeriod.
755 * 0 if not set / available by the backend. */
756 uint32_t cFramesBufferSize;
757 /** Pre-buffering size (in audio frames). Frames needed in buffer before the stream becomes active (pre buffering).
758 * The bigger this value is, the more latency for the stream will occur.
759 * 0 if not set / available by the backend. UINT32_MAX if not defined (yet). */
760 uint32_t cFramesPreBuffering;
761 } Backend;
762 uint32_t u32Padding;
763 /** Friendly name of the stream. */
764 char szName[64];
765} PDMAUDIOSTREAMCFG;
766AssertCompileSizeAlignment(PDMAUDIOSTREAMCFG, 8);
767/** Pointer to audio stream configuration keeper. */
768typedef PDMAUDIOSTREAMCFG *PPDMAUDIOSTREAMCFG;
769/** Pointer to a const audio stream configuration keeper. */
770typedef PDMAUDIOSTREAMCFG const *PCPDMAUDIOSTREAMCFG;
771
772/** Converts (audio) frames to bytes. */
773#define PDMAUDIOSTREAMCFG_F2B(pCfg, frames) PDMAUDIOPCMPROPS_F2B(&(pCfg)->Props, (frames))
774/** Converts bytes to (audio) frames. */
775#define PDMAUDIOSTREAMCFG_B2F(pCfg, cb) PDMAUDIOPCMPROPS_B2F(&(pCfg)->Props, (cb))
776
777/**
778 * Audio mixer controls.
779 */
780typedef enum PDMAUDIOMIXERCTL
781{
782 /** Invalid zero value as per usual (guards against using unintialized values). */
783 PDMAUDIOMIXERCTL_INVALID = 0,
784 /** Unknown mixer control. */
785 PDMAUDIOMIXERCTL_UNKNOWN,
786 /** Master volume. */
787 PDMAUDIOMIXERCTL_VOLUME_MASTER,
788 /** Front. */
789 PDMAUDIOMIXERCTL_FRONT,
790 /** Center / LFE (Subwoofer). */
791 PDMAUDIOMIXERCTL_CENTER_LFE,
792 /** Rear. */
793 PDMAUDIOMIXERCTL_REAR,
794 /** Line-In. */
795 PDMAUDIOMIXERCTL_LINE_IN,
796 /** Microphone-In. */
797 PDMAUDIOMIXERCTL_MIC_IN,
798 /** End of valid values. */
799 PDMAUDIOMIXERCTL_END,
800 /** Hack to blow the type up to 32-bit. */
801 PDMAUDIOMIXERCTL_32BIT_HACK = 0x7fffffff
802} PDMAUDIOMIXERCTL;
803
804/**
805 * Audio stream commands.
806 *
807 * Used in the audio connector as well as in the actual host backends.
808 */
809typedef enum PDMAUDIOSTREAMCMD
810{
811 /** Invalid zero value as per usual (guards against using unintialized values). */
812 PDMAUDIOSTREAMCMD_INVALID = 0,
813 /** Enables the stream. */
814 PDMAUDIOSTREAMCMD_ENABLE,
815 /** Pauses the stream.
816 * This is currently only issued when the VM is suspended (paused).
817 * @remarks This is issued by DrvAudio, never by the mixer or devices. */
818 PDMAUDIOSTREAMCMD_PAUSE,
819 /** Resumes the stream.
820 * This is currently only issued when the VM is resumed.
821 * @remarks This is issued by DrvAudio, never by the mixer or devices. */
822 PDMAUDIOSTREAMCMD_RESUME,
823 /** Drain the stream, that is, play what's in the buffers and then stop.
824 *
825 * There will be no more samples written after this command is issued.
826 * PDMIAUDIOCONNECTOR::pfnStreamIterate will drive progress for DrvAudio and
827 * calls to PDMIHOSTAUDIO::pfnStreamPlay with a zero sized buffer will provide
828 * the backend with a way to drive it forwards. These calls will come at a
829 * frequency set by the device and be on an asynchronous I/O thread.
830 *
831 * A DISABLE command maybe submitted if the device/mixer wants to re-enable the
832 * stream while it's still draining or if it gets impatient and thinks the
833 * draining has been going on too long, in which case the stream should stop
834 * immediately.
835 *
836 * @note This should not wait for the stream to finish draining, just change
837 * the state. (The caller could be an EMT and it must not block for
838 * hundreds of milliseconds of buffer to finish draining.)
839 *
840 * @note Does not apply to input streams. Backends should refuse such requests. */
841 PDMAUDIOSTREAMCMD_DRAIN,
842 /** Stops the stream immediately w/o any draining. */
843 PDMAUDIOSTREAMCMD_DISABLE,
844 /** End of valid values. */
845 PDMAUDIOSTREAMCMD_END,
846 /** Hack to blow the type up to 32-bit. */
847 PDMAUDIOSTREAMCMD_32BIT_HACK = 0x7fffffff
848} PDMAUDIOSTREAMCMD;
849
850/**
851 * Audio volume parameters.
852 */
853typedef struct PDMAUDIOVOLUME
854{
855 /** Set to @c true if this stream is muted, @c false if not. */
856 bool fMuted;
857 /** Left channel volume.
858 * Range is from [0 ... 255], whereas 0 specifies
859 * the most silent and 255 the loudest value. */
860 uint8_t uLeft;
861 /** Right channel volume.
862 * Range is from [0 ... 255], whereas 0 specifies
863 * the most silent and 255 the loudest value. */
864 uint8_t uRight;
865} PDMAUDIOVOLUME;
866/** Pointer to audio volume settings. */
867typedef PDMAUDIOVOLUME *PPDMAUDIOVOLUME;
868/** Pointer to const audio volume settings. */
869typedef PDMAUDIOVOLUME const *PCPDMAUDIOVOLUME;
870
871/** Defines the minimum volume allowed. */
872#define PDMAUDIO_VOLUME_MIN (0)
873/** Defines the maximum volume allowed. */
874#define PDMAUDIO_VOLUME_MAX (255)
875
876
877/**
878 * Backend status.
879 */
880typedef enum PDMAUDIOBACKENDSTS
881{
882 /** Unknown/invalid status. */
883 PDMAUDIOBACKENDSTS_UNKNOWN = 0,
884 /** No backend attached. */
885 PDMAUDIOBACKENDSTS_NOT_ATTACHED,
886 /** The backend is in its initialization phase.
887 * Not all backends support this status. */
888 PDMAUDIOBACKENDSTS_INITIALIZING,
889 /** The backend has stopped its operation. */
890 PDMAUDIOBACKENDSTS_STOPPED,
891 /** The backend is up and running. */
892 PDMAUDIOBACKENDSTS_RUNNING,
893 /** The backend ran into an error and is unable to recover.
894 * A manual re-initialization might help. */
895 PDMAUDIOBACKENDSTS_ERROR,
896 /** Hack to blow the type up to 32-bit. */
897 PDMAUDIOBACKENDSTS_32BIT_HACK = 0x7fffffff
898} PDMAUDIOBACKENDSTS;
899
900/**
901 * PDM audio stream state.
902 *
903 * This is all the mixer/device needs. The PDMAUDIOSTREAM_STS_XXX stuff will
904 * become DrvAudio internal state once the backend stuff is destilled out of it.
905 *
906 * @note The value order is significant, don't change it willy-nilly.
907 */
908typedef enum PDMAUDIOSTREAMSTATE
909{
910 /** Invalid state value. */
911 PDMAUDIOSTREAMSTATE_INVALID = 0,
912 /** The stream is not operative and cannot be enabled. */
913 PDMAUDIOSTREAMSTATE_NOT_WORKING,
914 /** The stream needs to be re-initialized by the device/mixer
915 * (i.e. call PDMIAUDIOCONNECTOR::pfnStreamReInit). */
916 PDMAUDIOSTREAMSTATE_NEED_REINIT,
917 /** The stream is inactive (not enabled). */
918 PDMAUDIOSTREAMSTATE_INACTIVE,
919 /** The stream is enabled but nothing to read/write.
920 * @todo not sure if we need this variant... */
921 PDMAUDIOSTREAMSTATE_ENABLED,
922 /** The stream is enabled and captured samples can be read. */
923 PDMAUDIOSTREAMSTATE_ENABLED_READABLE,
924 /** The stream is enabled and samples can be written for playback. */
925 PDMAUDIOSTREAMSTATE_ENABLED_WRITABLE,
926 /** End of valid states. */
927 PDMAUDIOSTREAMSTATE_END,
928 /** Make sure the type is 32-bit wide. */
929 PDMAUDIOSTREAMSTATE_32BIT_HACK = 0x7fffffff
930} PDMAUDIOSTREAMSTATE;
931
932/** @name PDMAUDIOSTREAM_CREATE_F_XXX
933 * @{ */
934/** Does not need any mixing buffers, the device takes care of all conversion.
935 * @note this is now default and assumed always set. */
936#define PDMAUDIOSTREAM_CREATE_F_NO_MIXBUF RT_BIT_32(0)
937/** @} */
938
939/** @name PDMAUDIOSTREAM_WARN_FLAGS_XXX
940 * @{ */
941/** No stream warning flags set. */
942#define PDMAUDIOSTREAM_WARN_FLAGS_NONE 0
943/** Warned about a disabled stream. */
944#define PDMAUDIOSTREAM_WARN_FLAGS_DISABLED RT_BIT(0)
945/** @} */
946
947/**
948 * An input or output audio stream.
949 */
950typedef struct PDMAUDIOSTREAM
951{
952 /** Critical section protecting the stream.
953 *
954 * When not otherwise stated, DrvAudio will enter this before calling the
955 * backend. The backend and device/mixer can normally safely enter it prior to
956 * a DrvAudio call, however not to pfnStreamDestroy, pfnStreamRelease or
957 * anything that may access the stream list.
958 *
959 * @note Lock ordering:
960 * - After DRVAUDIO::CritSectGlobals.
961 * - Before DRVAUDIO::CritSectHotPlug. */
962 RTCRITSECT CritSect;
963 /** Magic value (PDMAUDIOSTREAM_MAGIC). */
964 uint32_t uMagic;
965 /** Audio direction of this stream. */
966 PDMAUDIODIR enmDir;
967 /** Size (in bytes) of the backend-specific stream data. */
968 uint32_t cbBackend;
969 /** Warnings shown already in the release log.
970 * See PDMAUDIOSTREAM_WARN_FLAGS_XXX. */
971 uint32_t fWarningsShown;
972 /** The stream properties (both sides when PDMAUDIOSTREAM_CREATE_F_NO_MIXBUF
973 * is used, otherwise the guest side). */
974 PDMAUDIOPCMPROPS Props;
975
976 /** Name of this stream. */
977 char szName[64];
978} PDMAUDIOSTREAM;
979/** Pointer to an audio stream. */
980typedef struct PDMAUDIOSTREAM *PPDMAUDIOSTREAM;
981/** Pointer to a const audio stream. */
982typedef struct PDMAUDIOSTREAM const *PCPDMAUDIOSTREAM;
983
984/** Magic value for PDMAUDIOSTREAM. */
985#define PDMAUDIOSTREAM_MAGIC PDM_VERSION_MAKE(0xa0d3, 5, 0)
986
987
988
989/** Pointer to a audio connector interface. */
990typedef struct PDMIAUDIOCONNECTOR *PPDMIAUDIOCONNECTOR;
991
992/**
993 * Audio connector interface (up).
994 */
995typedef struct PDMIAUDIOCONNECTOR
996{
997 /**
998 * Enables or disables the given audio direction for this driver.
999 *
1000 * When disabled, assiociated output streams consume written audio without passing them further down to the backends.
1001 * Associated input streams then return silence when read from those.
1002 *
1003 * @returns VBox status code.
1004 * @param pInterface Pointer to the interface structure containing the called function pointer.
1005 * @param enmDir Audio direction to enable or disable driver for.
1006 * @param fEnable Whether to enable or disable the specified audio direction.
1007 *
1008 * @note Be very careful when using this function, as this could
1009 * violate / run against the (global) VM settings. See @bugref{9882}.
1010 */
1011 DECLR3CALLBACKMEMBER(int, pfnEnable, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir, bool fEnable));
1012
1013 /**
1014 * Returns whether the given audio direction for this driver is enabled or not.
1015 *
1016 * @returns True if audio is enabled for the given direction, false if not.
1017 * @param pInterface Pointer to the interface structure containing the called function pointer.
1018 * @param enmDir Audio direction to retrieve enabled status for.
1019 */
1020 DECLR3CALLBACKMEMBER(bool, pfnIsEnabled, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir));
1021
1022 /**
1023 * Retrieves the current configuration of the host audio backend.
1024 *
1025 * @returns VBox status code.
1026 * @param pInterface Pointer to the interface structure containing the called function pointer.
1027 * @param pCfg Where to store the host audio backend configuration data.
1028 */
1029 DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOBACKENDCFG pCfg));
1030
1031 /**
1032 * Retrieves the current status of the host audio backend.
1033 *
1034 * @returns Status of the host audio backend.
1035 * @param pInterface Pointer to the interface structure containing the called function pointer.
1036 * @param enmDir Audio direction to check host audio backend for. Specify PDMAUDIODIR_DUPLEX for the overall
1037 * backend status.
1038 */
1039 DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir));
1040
1041 /**
1042 * Gives the audio drivers a hint about a typical configuration.
1043 *
1044 * This is a little hack for windows (and maybe other hosts) where stream
1045 * creation can take a relatively long time, making it very unsuitable for EMT.
1046 * The audio backend can use this hint to cache pre-configured stream setups,
1047 * so that when the guest actually wants to play something EMT won't be blocked
1048 * configuring host audio.
1049 *
1050 * @param pInterface Pointer to this interface.
1051 * @param pCfg The typical configuration. Can be modified by the
1052 * drivers in unspecified ways.
1053 */
1054 DECLR3CALLBACKMEMBER(void, pfnStreamConfigHint, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfg));
1055
1056 /**
1057 * Creates an audio stream.
1058 *
1059 * @returns VBox status code.
1060 * @param pInterface Pointer to the interface structure containing the called function pointer.
1061 * @param fFlags PDMAUDIOSTREAM_CREATE_F_XXX.
1062 * @param pCfgHost Stream configuration for host side.
1063 * @param pCfgGuest Stream configuration for guest side.
1064 * @param ppStream Pointer where to return the created audio stream on success.
1065 * @todo r=bird: It is not documented how pCfgHost and pCfgGuest can be
1066 * modified the DrvAudio...
1067 */
1068 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, uint32_t fFlags, PPDMAUDIOSTREAMCFG pCfgHost,
1069 PPDMAUDIOSTREAMCFG pCfgGuest, PPDMAUDIOSTREAM *ppStream));
1070
1071
1072 /**
1073 * Destroys an audio stream.
1074 *
1075 * @param pInterface Pointer to the interface structure containing the called function pointer.
1076 * @param pStream Pointer to audio stream.
1077 * @param fImmediate Whether to immdiately stop and destroy a draining
1078 * stream (@c true), or to allow it to complete
1079 * draining first (@c false) if that's feasable.
1080 * The latter depends on the draining stage and what
1081 * the backend is capable of.
1082 */
1083 DECLR3CALLBACKMEMBER(int, pfnStreamDestroy, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, bool fImmediate));
1084
1085 /**
1086 * Re-initializes the stream in response to PDMAUDIOSTREAM_STS_NEED_REINIT.
1087 *
1088 * @returns VBox status code.
1089 * @param pInterface Pointer to this interface.
1090 * @param pStream The audio stream needing re-initialization.
1091 */
1092 DECLR3CALLBACKMEMBER(int, pfnStreamReInit, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1093
1094 /**
1095 * Adds a reference to the specified audio stream.
1096 *
1097 * @returns New reference count. UINT32_MAX on error.
1098 * @param pInterface Pointer to the interface structure containing the called function pointer.
1099 * @param pStream Pointer to audio stream adding the reference to.
1100 */
1101 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamRetain, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1102
1103 /**
1104 * Releases a reference from the specified stream.
1105 *
1106 * @returns New reference count. UINT32_MAX on error.
1107 * @param pInterface Pointer to the interface structure containing the called function pointer.
1108 * @param pStream Pointer to audio stream releasing a reference from.
1109 */
1110 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamRelease, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1111
1112 /**
1113 * Controls a specific audio stream.
1114 *
1115 * @returns VBox status code.
1116 * @param pInterface Pointer to the interface structure containing the called function pointer.
1117 * @param pStream Pointer to audio stream.
1118 * @param enmStreamCmd The stream command to issue.
1119 */
1120 DECLR3CALLBACKMEMBER(int, pfnStreamControl, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream,
1121 PDMAUDIOSTREAMCMD enmStreamCmd));
1122
1123 /**
1124 * Processes stream data.
1125 *
1126 * @param pInterface Pointer to the interface structure containing the called function pointer.
1127 * @param pStream Pointer to audio stream.
1128 */
1129 DECLR3CALLBACKMEMBER(int, pfnStreamIterate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1130
1131 /**
1132 * Returns the state of a specific audio stream (destilled status).
1133 *
1134 * @returns PDMAUDIOSTREAMSTATE value.
1135 * @retval PDMAUDIOSTREAMSTATE_INVALID if the input isn't valid (w/ assertion).
1136 * @param pInterface Pointer to the interface structure containing the called function pointer.
1137 * @param pStream Pointer to audio stream.
1138 */
1139 DECLR3CALLBACKMEMBER(PDMAUDIOSTREAMSTATE, pfnStreamGetState, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1140
1141 /**
1142 * Returns the number of bytes that can be written to an audio output stream.
1143 *
1144 * @returns Number of bytes writable data.
1145 * @param pInterface Pointer to the interface structure containing the called function pointer.
1146 * @param pStream Pointer to audio stream.
1147 */
1148 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetWritable, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1149
1150 /**
1151 * Plays (writes to) an audio output stream.
1152 *
1153 * @returns VBox status code.
1154 * @param pInterface Pointer to the interface structure containing the called function pointer.
1155 * @param pStream Pointer to audio stream to read from.
1156 * @param pvBuf Audio data to be written.
1157 * @param cbBuf Number of bytes to be written.
1158 * @param pcbWritten Bytes of audio data written. Optional.
1159 */
1160 DECLR3CALLBACKMEMBER(int, pfnStreamPlay, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream,
1161 const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten));
1162
1163 /**
1164 * Returns the number of bytes that can be read from an input stream.
1165 *
1166 * @returns Number of bytes of readable data.
1167 * @param pInterface Pointer to the interface structure containing the called function pointer.
1168 * @param pStream Pointer to audio stream.
1169 */
1170 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetReadable, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
1171
1172 /**
1173 * Captures (reads) samples from an audio input stream.
1174 *
1175 * @returns VBox status code.
1176 * @param pInterface Pointer to the interface structure containing the called function pointer.
1177 * @param pStream Pointer to audio stream to write to.
1178 * @param pvBuf Where to store the read data.
1179 * @param cbBuf Number of bytes to read.
1180 * @param pcbRead Bytes of audio data read. Optional.
1181 */
1182 DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream,
1183 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead));
1184} PDMIAUDIOCONNECTOR;
1185
1186/** PDMIAUDIOCONNECTOR interface ID. */
1187#define PDMIAUDIOCONNECTOR_IID "36fee65e-cbb3-4bb7-a028-e88e6acc1c46"
1188
1189
1190/**
1191 * Host audio backend specific stream data.
1192 *
1193 * The backend will put this as the first member of it's own data structure.
1194 */
1195typedef struct PDMAUDIOBACKENDSTREAM
1196{
1197 /** Magic value (PDMAUDIOBACKENDSTREAM_MAGIC). */
1198 uint32_t uMagic;
1199 /** Explicit zero padding - do not touch! */
1200 uint32_t uReserved;
1201 /** Pointer to the stream this backend data is associated with. */
1202 PPDMAUDIOSTREAM pStream;
1203 /** Reserved for future use (zeroed) - do not touch. */
1204 void *apvReserved[2];
1205} PDMAUDIOBACKENDSTREAM;
1206/** Pointer to host audio specific stream data! */
1207typedef PDMAUDIOBACKENDSTREAM *PPDMAUDIOBACKENDSTREAM;
1208
1209/** Magic value for PDMAUDIOBACKENDSTREAM. */
1210#define PDMAUDIOBACKENDSTREAM_MAGIC PDM_VERSION_MAKE(0xa0d4, 1, 0)
1211
1212/**
1213 * Host audio (backend) stream state returned by PDMIHOSTAUDIO::pfnStreamGetState.
1214 */
1215typedef enum PDMHOSTAUDIOSTREAMSTATE
1216{
1217 /** Invalid zero value, as per usual. */
1218 PDMHOSTAUDIOSTREAMSTATE_INVALID = 0,
1219 /** The stream is being initialized.
1220 * This should also be used when switching to a new device and the stream
1221 * stops to work with the old device while the new one being configured. */
1222 PDMHOSTAUDIOSTREAMSTATE_INITIALIZING,
1223 /** The stream does not work (async init failed, audio subsystem gone
1224 * fishing, or similar). */
1225 PDMHOSTAUDIOSTREAMSTATE_NOT_WORKING,
1226 /** Backend is working okay. */
1227 PDMHOSTAUDIOSTREAMSTATE_OKAY,
1228 /** Backend is working okay, but currently draining the stream. */
1229 PDMHOSTAUDIOSTREAMSTATE_DRAINING,
1230 /** Backend is working but doesn't want any commands or data reads/writes. */
1231 PDMHOSTAUDIOSTREAMSTATE_INACTIVE,
1232 /** End of valid values. */
1233 PDMHOSTAUDIOSTREAMSTATE_END,
1234 /** Blow the type up to 32 bits. */
1235 PDMHOSTAUDIOSTREAMSTATE_32BIT_HACK = 0x7fffffff
1236} PDMHOSTAUDIOSTREAMSTATE;
1237
1238
1239/** Pointer to a host audio interface. */
1240typedef struct PDMIHOSTAUDIO *PPDMIHOSTAUDIO;
1241
1242/**
1243 * PDM host audio interface.
1244 */
1245typedef struct PDMIHOSTAUDIO
1246{
1247 /**
1248 * Returns the host backend's configuration (backend).
1249 *
1250 * @returns VBox status code.
1251 * @param pInterface Pointer to the interface structure containing the called function pointer.
1252 * @param pBackendCfg Where to store the backend audio configuration to.
1253 */
1254 DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg));
1255
1256 /**
1257 * Returns (enumerates) host audio device information (optional).
1258 *
1259 * @returns VBox status code.
1260 * @param pInterface Pointer to the interface structure containing the called function pointer.
1261 * @param pDeviceEnum Where to return the enumerated audio devices.
1262 */
1263 DECLR3CALLBACKMEMBER(int, pfnGetDevices, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOHOSTENUM pDeviceEnum));
1264
1265 /**
1266 * Changes the output or input device.
1267 *
1268 * @returns VBox status code.
1269 * @param pInterface Pointer to this interface.
1270 * @param enmDir The direction to set the device for: PDMAUDIODIR_IN,
1271 * PDMAUDIODIR_OUT or PDMAUDIODIR_DUPLEX (both the
1272 * previous).
1273 * @param pszId The PDMAUDIOHOSTDEV::pszId value of the device to
1274 * use, or NULL / empty string for the default device.
1275 */
1276 DECLR3CALLBACKMEMBER(int, pfnSetDevice, (PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir, const char *pszId));
1277
1278 /**
1279 * Returns the current status from the audio backend (optional).
1280 *
1281 * @returns PDMAUDIOBACKENDSTS enum.
1282 * @param pInterface Pointer to the interface structure containing the called function pointer.
1283 * @param enmDir Audio direction to get status for. Pass PDMAUDIODIR_DUPLEX for overall status.
1284 */
1285 DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir));
1286
1287 /**
1288 * Callback for genric on-worker-thread requests initiated by the backend itself.
1289 *
1290 * This is the counterpart to PDMIHOSTAUDIOPORT::pfnDoOnWorkerThread that will
1291 * be invoked on a worker thread when the backend requests it - optional.
1292 *
1293 * This does not return a value, so the backend must keep track of
1294 * failure/success on its own.
1295 *
1296 * This method is optional. A non-NULL will, together with pfnStreamInitAsync
1297 * and PDMAUDIOBACKEND_F_ASYNC_HINT, force DrvAudio to create the thread pool.
1298 *
1299 * @param pInterface Pointer to this interface.
1300 * @param pStream Optionally a backend stream if specified in the
1301 * PDMIHOSTAUDIOPORT::pfnDoOnWorkerThread() call.
1302 * @param uUser User specific value as specified in the
1303 * PDMIHOSTAUDIOPORT::pfnDoOnWorkerThread() call.
1304 * @param pvUser User specific pointer as specified in the
1305 * PDMIHOSTAUDIOPORT::pfnDoOnWorkerThread() call.
1306 */
1307 DECLR3CALLBACKMEMBER(void, pfnDoOnWorkerThread,(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1308 uintptr_t uUser, void *pvUser));
1309
1310 /**
1311 * Gives the audio backend a hint about a typical configuration (optional).
1312 *
1313 * This is a little hack for windows (and maybe other hosts) where stream
1314 * creation can take a relatively long time, making it very unsuitable for EMT.
1315 * The audio backend can use this hint to cache pre-configured stream setups,
1316 * so that when the guest actually wants to play something EMT won't be blocked
1317 * configuring host audio.
1318 *
1319 * The backend can return PDMAUDIOBACKEND_F_ASYNC_HINT in
1320 * PDMIHOSTAUDIO::pfnGetConfig to avoid having EMT making this call and thereby
1321 * speeding up VM construction.
1322 *
1323 * @param pInterface Pointer to this interface.
1324 * @param pCfg The typical configuration. (Feel free to change it
1325 * to the actual stream config that would be used,
1326 * however caller will probably ignore this.)
1327 */
1328 DECLR3CALLBACKMEMBER(void, pfnStreamConfigHint, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAMCFG pCfg));
1329
1330 /**
1331 * Creates an audio stream using the requested stream configuration.
1332 *
1333 * If a backend is not able to create this configuration, it will return its
1334 * best match in the acquired configuration structure on success.
1335 *
1336 * @returns VBox status code.
1337 * @retval VINF_AUDIO_STREAM_ASYNC_INIT_NEEDED if
1338 * PDMIHOSTAUDIO::pfnStreamInitAsync should be called.
1339 * @param pInterface Pointer to the interface structure containing the called function pointer.
1340 * @param pStream Pointer to audio stream.
1341 * @param pCfgReq Pointer to requested stream configuration.
1342 * @param pCfgAcq Pointer to acquired stream configuration.
1343 * @todo r=bird: Implementation (at least Alsa) seems to make undocumented
1344 * assumptions about the content of @a pCfgAcq.
1345 */
1346 DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1347 PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq));
1348
1349 /**
1350 * Asynchronous stream initialization step, optional.
1351 *
1352 * This is called on a worker thread iff the PDMIHOSTAUDIO::pfnStreamCreate
1353 * method returns VINF_AUDIO_STREAM_ASYNC_INIT_NEEDED.
1354 *
1355 * @returns VBox status code.
1356 * @param pInterface Pointer to this interface.
1357 * @param pStream Pointer to audio stream to continue
1358 * initialization of.
1359 * @param fDestroyed Set to @c true if the stream has been destroyed
1360 * before the worker thread got to making this
1361 * call. The backend should just ready the stream
1362 * for destruction in that case.
1363 */
1364 DECLR3CALLBACKMEMBER(int, pfnStreamInitAsync, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, bool fDestroyed));
1365
1366 /**
1367 * Destroys an audio stream.
1368 *
1369 * @returns VBox status code.
1370 * @param pInterface Pointer to the interface containing the called function.
1371 * @param pStream Pointer to audio stream.
1372 * @param fImmediate Whether to immdiately stop and destroy a draining
1373 * stream (@c true), or to allow it to complete
1374 * draining first (@c false) if that's feasable.
1375 */
1376 DECLR3CALLBACKMEMBER(int, pfnStreamDestroy, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, bool fImmediate));
1377
1378 /**
1379 * Called from PDMIHOSTAUDIOPORT::pfnNotifyDeviceChanged so the backend can start
1380 * the device change for a stream.
1381 *
1382 * This is mainly to avoid the need for a list of streams in the backend.
1383 *
1384 * @param pInterface Pointer to this interface.
1385 * @param pStream Pointer to audio stream (locked).
1386 * @param pvUser Backend specific parameter from the call to
1387 * PDMIHOSTAUDIOPORT::pfnNotifyDeviceChanged.
1388 */
1389 DECLR3CALLBACKMEMBER(void, pfnStreamNotifyDeviceChanged,(PPDMIHOSTAUDIO pInterface,
1390 PPDMAUDIOBACKENDSTREAM pStream, void *pvUser));
1391
1392 /**
1393 * Controls an audio stream.
1394 *
1395 * @returns VBox status code.
1396 * @retval VERR_AUDIO_STREAM_NOT_READY if stream is not ready for required operation (yet).
1397 * @param pInterface Pointer to the interface structure containing the called function pointer.
1398 * @param pStream Pointer to audio stream.
1399 * @param enmStreamCmd The stream command to issue.
1400 */
1401 DECLR3CALLBACKMEMBER(int, pfnStreamControl, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1402 PDMAUDIOSTREAMCMD enmStreamCmd));
1403
1404 /**
1405 * Returns the amount which is readable from the audio (input) stream.
1406 *
1407 * @returns For non-raw layout streams: Number of readable bytes.
1408 * for raw layout streams : Number of readable audio frames.
1409 * @param pInterface Pointer to the interface structure containing the called function pointer.
1410 * @param pStream Pointer to audio stream.
1411 */
1412 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetReadable, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
1413
1414 /**
1415 * Returns the amount which is writable to the audio (output) stream.
1416 *
1417 * @returns Number of writable bytes.
1418 * @param pInterface Pointer to the interface structure containing the called function pointer.
1419 * @param pStream Pointer to audio stream.
1420 */
1421 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetWritable, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
1422
1423 /**
1424 * Returns the number of buffered bytes that hasn't been played yet (optional).
1425 *
1426 * Is not valid on an input stream, implementions shall assert and return zero.
1427 *
1428 * @returns Number of pending bytes.
1429 * @param pInterface Pointer to this interface.
1430 * @param pStream Pointer to audio stream.
1431 *
1432 * @todo This is no longer not used by DrvAudio and can probably be removed.
1433 */
1434 DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetPending, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
1435
1436 /**
1437 * Returns the current state of the given backend stream.
1438 *
1439 * @returns PDMHOSTAUDIOSTREAMSTATE value.
1440 * @retval PDMHOSTAUDIOSTREAMSTATE_INVALID if invalid stream.
1441 * @param pInterface Pointer to the interface structure containing the called function pointer.
1442 * @param pStream Pointer to audio stream.
1443 */
1444 DECLR3CALLBACKMEMBER(PDMHOSTAUDIOSTREAMSTATE, pfnStreamGetState, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
1445
1446 /**
1447 * Plays (writes to) an audio (output) stream.
1448 *
1449 * This is always called with data in the buffer, except after
1450 * PDMAUDIOSTREAMCMD_DRAIN is issued when it's called every so often to assist
1451 * the backend with moving the draining operation forward (kind of like
1452 * PDMIAUDIOCONNECTOR::pfnStreamIterate).
1453 *
1454 * @returns VBox status code.
1455 * @param pInterface Pointer to the interface structure containing the called function pointer.
1456 * @param pStream Pointer to audio stream.
1457 * @param pvBuf Pointer to audio data buffer to play. This will be NULL
1458 * when called to assist draining the stream.
1459 * @param cbBuf The number of bytes of audio data to play. This will be
1460 * zero when called to assist draining the stream.
1461 * @param pcbWritten Where to return the actual number of bytes played.
1462 */
1463 DECLR3CALLBACKMEMBER(int, pfnStreamPlay, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1464 const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten));
1465
1466 /**
1467 * Captures (reads from) an audio (input) stream.
1468 *
1469 * @returns VBox status code.
1470 * @param pInterface Pointer to the interface structure containing the called function pointer.
1471 * @param pStream Pointer to audio stream.
1472 * @param pvBuf Buffer where to store read audio data.
1473 * @param cbBuf Size of the audio data buffer in bytes.
1474 * @param pcbRead Where to return the number of bytes actually captured.
1475 */
1476 DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1477 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead));
1478} PDMIHOSTAUDIO;
1479
1480/** PDMIHOSTAUDIO interface ID. */
1481#define PDMIHOSTAUDIO_IID "da3c9d33-e532-415b-9156-db31521f59ef"
1482
1483
1484/** Pointer to a audio notify from host interface. */
1485typedef struct PDMIHOSTAUDIOPORT *PPDMIHOSTAUDIOPORT;
1486
1487/**
1488 * PDM host audio port interface, upwards sibling of PDMIHOSTAUDIO.
1489 */
1490typedef struct PDMIHOSTAUDIOPORT
1491{
1492 /**
1493 * Ask DrvAudio to call PDMIHOSTAUDIO::pfnDoOnWorkerThread on a worker thread.
1494 *
1495 * Generic method for doing asynchronous work using the DrvAudio thread pool.
1496 *
1497 * This function will not wait for PDMIHOSTAUDIO::pfnDoOnWorkerThread to
1498 * complete, but returns immediately after submitting the request to the thread
1499 * pool.
1500 *
1501 * @returns VBox status code.
1502 * @param pInterface Pointer to this interface.
1503 * @param pStream Optional backend stream structure to pass along. The
1504 * reference count will be increased till the call
1505 * completes to make sure the stream stays valid.
1506 * @param uUser User specific value.
1507 * @param pvUser User specific pointer.
1508 */
1509 DECLR3CALLBACKMEMBER(int, pfnDoOnWorkerThread,(PPDMIHOSTAUDIOPORT pInterface, PPDMAUDIOBACKENDSTREAM pStream,
1510 uintptr_t uUser, void *pvUser));
1511
1512 /**
1513 * The device for the given direction changed.
1514 *
1515 * The driver above backend (DrvAudio) will call the backend back
1516 * (PDMIHOSTAUDIO::pfnStreamNotifyDeviceChanged) for all open streams in the
1517 * given direction. (This ASSUMES the backend uses one output device and one
1518 * input devices for all streams.)
1519 *
1520 * @param pInterface Pointer to this interface.
1521 * @param enmDir The audio direction.
1522 * @param pvUser Backend specific parameter for
1523 * PDMIHOSTAUDIO::pfnStreamNotifyDeviceChanged.
1524 */
1525 DECLR3CALLBACKMEMBER(void, pfnNotifyDeviceChanged,(PPDMIHOSTAUDIOPORT pInterface, PDMAUDIODIR enmDir, void *pvUser));
1526
1527 /**
1528 * Notification that the stream is about to change device in a bit.
1529 *
1530 * This will assume PDMAUDIOSTREAM_STS_PREPARING_SWITCH will be set when
1531 * PDMIHOSTAUDIO::pfnStreamGetStatus is next called and change the stream state
1532 * accordingly.
1533 *
1534 * @param pInterface Pointer to this interface.
1535 * @param pStream The stream that changed device (backend variant).
1536 */
1537 DECLR3CALLBACKMEMBER(void, pfnStreamNotifyPreparingDeviceSwitch,(PPDMIHOSTAUDIOPORT pInterface,
1538 PPDMAUDIOBACKENDSTREAM pStream));
1539
1540 /**
1541 * The stream has changed its device and left the
1542 * PDMAUDIOSTREAM_STS_PREPARING_SWITCH state (if it entered it at all).
1543 *
1544 * @param pInterface Pointer to this interface.
1545 * @param pStream The stream that changed device (backend variant).
1546 * @param fReInit Set if a re-init is required, clear if not.
1547 */
1548 DECLR3CALLBACKMEMBER(void, pfnStreamNotifyDeviceChanged,(PPDMIHOSTAUDIOPORT pInterface,
1549 PPDMAUDIOBACKENDSTREAM pStream, bool fReInit));
1550
1551 /**
1552 * One or more audio devices have changed in some way.
1553 *
1554 * The upstream driver/device should re-evaluate the devices they're using.
1555 *
1556 * @todo r=bird: The upstream driver/device does not know which host audio
1557 * devices they are using. This is mainly for triggering enumeration and
1558 * logging of the audio devices.
1559 *
1560 * @param pInterface Pointer to this interface.
1561 */
1562 DECLR3CALLBACKMEMBER(void, pfnNotifyDevicesChanged,(PPDMIHOSTAUDIOPORT pInterface));
1563} PDMIHOSTAUDIOPORT;
1564
1565/** PDMIHOSTAUDIOPORT interface ID. */
1566#define PDMIHOSTAUDIOPORT_IID "9f91ec59-95ba-4925-92dc-e75be1c63352"
1567
1568/** @} */
1569
1570RT_C_DECLS_END
1571
1572#endif /* !VBOX_INCLUDED_vmm_pdmaudioifs_h */
1573
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