1 | /** @file
|
---|
2 | * PDM - Pluggable Device Manager, audio interfaces.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2018 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 | /**
|
---|
27 | * == Audio architecture overview
|
---|
28 | *
|
---|
29 | * The audio architecture mainly consists of two PDM interfaces, PDMAUDIOCONNECTOR
|
---|
30 | * and PDMIHOSTAUDIO.
|
---|
31 | *
|
---|
32 | * The PDMAUDIOCONNECTOR interface is responsible of connecting a device emulation, such
|
---|
33 | * as SB16, AC'97 and HDA to one or multiple audio backend(s). Its API abstracts audio
|
---|
34 | * stream handling and I/O functions, device enumeration and so on.
|
---|
35 | *
|
---|
36 | * The PDMIHOSTAUDIO interface must be implemented by all audio backends to provide an
|
---|
37 | * abstract and common way of accessing needed functions, such as transferring output audio
|
---|
38 | * data for playing audio or recording input from the host.
|
---|
39 | *
|
---|
40 | * A device emulation can have one or more LUNs attached to it, whereas these LUNs in turn
|
---|
41 | * then all have their own PDMIAUDIOCONNECTOR, making it possible to connect multiple backends
|
---|
42 | * to a certain device emulation stream (multiplexing).
|
---|
43 | *
|
---|
44 | * An audio backend's job is to record and/or play audio data (depending on its capabilities).
|
---|
45 | * It highly depends on the host it's running on and needs very specific (host-OS-dependent) code.
|
---|
46 | * The backend itself only has very limited ways of accessing and/or communicating with the
|
---|
47 | * PDMIAUDIOCONNECTOR interface via callbacks, but never directly with the device emulation or
|
---|
48 | * other parts of the audio sub system.
|
---|
49 | *
|
---|
50 | *
|
---|
51 | * == Mixing
|
---|
52 | *
|
---|
53 | * The AUDIOMIXER API is optionally available to create and manage virtual audio mixers.
|
---|
54 | * Such an audio mixer in turn then can be used by the device emulation code to manage all
|
---|
55 | * the multiplexing to/from the connected LUN audio streams.
|
---|
56 | *
|
---|
57 | * Currently only input and output stream are supported. Duplex stream are not supported yet.
|
---|
58 | *
|
---|
59 | * This also is handy if certain LUN audio streams should be added or removed during runtime.
|
---|
60 | *
|
---|
61 | * To create a group of either input or output streams the AUDMIXSINK API can be used.
|
---|
62 | *
|
---|
63 | * For example: The device emulation has one hardware output stream (HW0), and that output
|
---|
64 | * stream shall be available to all connected LUN backends. For that to happen,
|
---|
65 | * an AUDMIXSINK sink has to be created and attached to the device's AUDIOMIXER object.
|
---|
66 | *
|
---|
67 | * As every LUN has its own AUDMIXSTREAM object, adding all those objects to the
|
---|
68 | * just created audio mixer sink will do the job.
|
---|
69 | *
|
---|
70 | * Note: The AUDIOMIXER API is purely optional and is not used by all currently implemented
|
---|
71 | * device emulations (e.g. SB16).
|
---|
72 | *
|
---|
73 | *
|
---|
74 | * == Data processing
|
---|
75 | *
|
---|
76 | * Audio input / output data gets handed-off to/from the device emulation in an unmodified
|
---|
77 | * - that is, raw - way. The actual audio frame / sample conversion is done via the PDMAUDIOMIXBUF API.
|
---|
78 | *
|
---|
79 | * This concentrates the audio data processing in one place and makes it easier to test / benchmark
|
---|
80 | * such code.
|
---|
81 | *
|
---|
82 | * A PDMAUDIOFRAME is the internal representation of a single audio frame, which consists of a single left
|
---|
83 | * and right audio sample in time. Only mono (1) and stereo (2) channel(s) currently are supported.
|
---|
84 | *
|
---|
85 | *
|
---|
86 | * == Timing
|
---|
87 | *
|
---|
88 | * Handling audio data in a virtual environment is hard, as the human perception is very sensitive
|
---|
89 | * to the slightest cracks and stutters in the audible data. This can happen if the VM's timing is
|
---|
90 | * lagging behind or not within the expected time frame.
|
---|
91 | *
|
---|
92 | * The two main components which unfortunately contradict each other is a) the audio device emulation
|
---|
93 | * and b) the audio backend(s) on the host. Those need to be served in a timely manner to function correctly.
|
---|
94 | * To make e.g. the device emulation rely on the pace the host backend(s) set - or vice versa - will not work,
|
---|
95 | * as the guest's audio system / drivers then will not be able to compensate this accordingly.
|
---|
96 | *
|
---|
97 | * So each component, the device emulation, the audio connector(s) and the backend(s) must do its thing
|
---|
98 | * *when* it needs to do it, independently of the others. For that we use various (small) ring buffers to
|
---|
99 | * (hopefully) serve all components with the amount of data *when* they need it.
|
---|
100 | *
|
---|
101 | * Additionally, the device emulation can run with a different audio frame size, while the backends(s) may
|
---|
102 | * require a different frame size (16 bit stereo -> 8 bit mono, for example).
|
---|
103 | *
|
---|
104 | * The device emulation can give the audio connector(s) a scheduling hint (optional), e.g. in which interval
|
---|
105 | * it expects any data processing.
|
---|
106 | *
|
---|
107 | * A data transfer for playing audio data from the guest on the host looks like this:
|
---|
108 | * (RB = Ring Buffer, MB = Mixing Buffer)
|
---|
109 | *
|
---|
110 | * (A) Device DMA -> (B) Device RB -> (C) Audio Connector Guest MB -> (D) Audio Connector Host MB -> \
|
---|
111 | * (E) Backend RB (optional, up to the backend) > (F) Backend audio framework
|
---|
112 | *
|
---|
113 | * For capturing audio data the above chain is similar, just in a different direction, of course.
|
---|
114 | *
|
---|
115 | * The audio connector hereby plays a key role when it comes to (pre-) buffering data to minimize any audio stutters
|
---|
116 | * and/or cracks. The following values, which also can be tweaked via CFGM / extra-data are available:
|
---|
117 | *
|
---|
118 | * - The pre-buffering time (in ms): Audio data which needs to be buffered before any playback (or capturing) can happen.
|
---|
119 | * - The actual buffer size (in ms): How big the mixing buffer (for C and D) will be.
|
---|
120 | * - The period size (in ms): How big a chunk of audio (often called period or fragment) for F must be to get handled correctly.
|
---|
121 | *
|
---|
122 | * The above values can be set on a per-driver level, whereas input and output streams for a driver also can be handled
|
---|
123 | * set independently. The verbose audio (release) log will tell about the (final) state of each audio stream.
|
---|
124 | *
|
---|
125 | *
|
---|
126 | * == Diagram
|
---|
127 | *
|
---|
128 | * +-------------------------+
|
---|
129 | * +-------------------------+ +-------------------------+ +-------------------+
|
---|
130 | * |PDMAUDIOSTREAM | |PDMAUDIOCONNECTOR | + ++|LUN |
|
---|
131 | * |-------------------------| |-------------------------| | |||-------------------|
|
---|
132 | * |PDMAUDIOMIXBUF |+------>|PDMAUDIOSTREAM Host |+---|-|||PDMIAUDIOCONNECTOR |
|
---|
133 | * |PDMAUDIOSTREAMCFG |+------>|PDMAUDIOSTREAM Guest | | |||AUDMIXSTREAM |
|
---|
134 | * | | |Device capabilities | | ||| |
|
---|
135 | * | | |Device configuration | | ||| |
|
---|
136 | * | | | | | ||| |
|
---|
137 | * | | +|PDMIHOSTAUDIO | | ||| |
|
---|
138 | * | | ||+-----------------------+| | ||+-------------------+
|
---|
139 | * +-------------------------+ |||Backend storage space || | ||
|
---|
140 | * ||+-----------------------+| | ||
|
---|
141 | * |+-------------------------+ | ||
|
---|
142 | * | | ||
|
---|
143 | * +---------------------+ | | ||
|
---|
144 | * |PDMIHOSTAUDIO | | | ||
|
---|
145 | * |+--------------+ | | +-------------------+ | || +-------------+
|
---|
146 | * ||DirectSound | | | |AUDMIXSINK | | || |AUDIOMIXER |
|
---|
147 | * |+--------------+ | | |-------------------| | || |-------------|
|
---|
148 | * | | | |AUDMIXSTREAM0 |+---|-||----->|AUDMIXSINK0 |
|
---|
149 | * |+--------------+ | | |AUDMIXSTREAM1 |+---|-||----->|AUDMIXSINK1 |
|
---|
150 | * ||PulseAudio | | | |AUDMIXSTREAMn |+---|-||----->|AUDMIXSINKn |
|
---|
151 | * |+--------------+ |+----------+ +-------------------+ | || +-------------+
|
---|
152 | * | | | ||
|
---|
153 | * |+--------------+ | | ||
|
---|
154 | * ||Core Audio | | | ||
|
---|
155 | * |+--------------+ | | ||
|
---|
156 | * | | | ||
|
---|
157 | * | | | ||+----------------------------------+
|
---|
158 | * | | | |||Device (SB16 / AC'97 / HDA) |
|
---|
159 | * | | | |||----------------------------------|
|
---|
160 | * +---------------------+ | |||AUDIOMIXER (Optional) |
|
---|
161 | * | |||AUDMIXSINK0 (Optional) |
|
---|
162 | * | |||AUDMIXSINK1 (Optional) |
|
---|
163 | * | |||AUDMIXSINKn (Optional) |
|
---|
164 | * | ||| |
|
---|
165 | * | |+|LUN0 |
|
---|
166 | * | ++|LUN1 |
|
---|
167 | * +--+|LUNn |
|
---|
168 | * | |
|
---|
169 | * | |
|
---|
170 | * | |
|
---|
171 | * +----------------------------------+
|
---|
172 | */
|
---|
173 |
|
---|
174 | #ifndef ___VBox_vmm_pdmaudioifs_h
|
---|
175 | #define ___VBox_vmm_pdmaudioifs_h
|
---|
176 |
|
---|
177 | #include <iprt/assertcompile.h>
|
---|
178 | #include <iprt/circbuf.h>
|
---|
179 | #include <iprt/list.h>
|
---|
180 | #include <iprt/path.h>
|
---|
181 |
|
---|
182 | #include <VBox/types.h>
|
---|
183 | #ifdef VBOX_WITH_STATISTICS
|
---|
184 | # include <VBox/vmm/stam.h>
|
---|
185 | #endif
|
---|
186 |
|
---|
187 | /** @defgroup grp_pdm_ifs_audio PDM Audio Interfaces
|
---|
188 | * @ingroup grp_pdm_interfaces
|
---|
189 | * @{
|
---|
190 | */
|
---|
191 |
|
---|
192 | #ifndef VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH
|
---|
193 | # ifdef RT_OS_WINDOWS
|
---|
194 | # define VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "c:\\temp\\"
|
---|
195 | # else
|
---|
196 | # define VBOX_AUDIO_DEBUG_DUMP_PCM_DATA_PATH "/tmp/"
|
---|
197 | # endif
|
---|
198 | #endif
|
---|
199 |
|
---|
200 | /** PDM audio driver instance flags. */
|
---|
201 | typedef uint32_t PDMAUDIODRVFLAGS;
|
---|
202 |
|
---|
203 | /** No flags set. */
|
---|
204 | #define PDMAUDIODRVFLAGS_NONE 0
|
---|
205 | /** Marks a primary audio driver which is critical
|
---|
206 | * when running the VM. */
|
---|
207 | #define PDMAUDIODRVFLAGS_PRIMARY RT_BIT(0)
|
---|
208 |
|
---|
209 | /**
|
---|
210 | * Audio format in signed or unsigned variants.
|
---|
211 | */
|
---|
212 | typedef enum PDMAUDIOFMT
|
---|
213 | {
|
---|
214 | /** Invalid format, do not use. */
|
---|
215 | PDMAUDIOFMT_INVALID,
|
---|
216 | /** 8-bit, unsigned. */
|
---|
217 | PDMAUDIOFMT_U8,
|
---|
218 | /** 8-bit, signed. */
|
---|
219 | PDMAUDIOFMT_S8,
|
---|
220 | /** 16-bit, unsigned. */
|
---|
221 | PDMAUDIOFMT_U16,
|
---|
222 | /** 16-bit, signed. */
|
---|
223 | PDMAUDIOFMT_S16,
|
---|
224 | /** 32-bit, unsigned. */
|
---|
225 | PDMAUDIOFMT_U32,
|
---|
226 | /** 32-bit, signed. */
|
---|
227 | PDMAUDIOFMT_S32,
|
---|
228 | /** Hack to blow the type up to 32-bit. */
|
---|
229 | PDMAUDIOFMT_32BIT_HACK = 0x7fffffff
|
---|
230 | } PDMAUDIOFMT;
|
---|
231 |
|
---|
232 | /**
|
---|
233 | * Audio direction.
|
---|
234 | */
|
---|
235 | typedef enum PDMAUDIODIR
|
---|
236 | {
|
---|
237 | /** Unknown direction. */
|
---|
238 | PDMAUDIODIR_UNKNOWN = 0,
|
---|
239 | /** Input. */
|
---|
240 | PDMAUDIODIR_IN = 1,
|
---|
241 | /** Output. */
|
---|
242 | PDMAUDIODIR_OUT = 2,
|
---|
243 | /** Duplex handling. */
|
---|
244 | PDMAUDIODIR_ANY = 3,
|
---|
245 | /** Hack to blow the type up to 32-bit. */
|
---|
246 | PDMAUDIODIR_32BIT_HACK = 0x7fffffff
|
---|
247 | } PDMAUDIODIR;
|
---|
248 |
|
---|
249 | /** Device latency spec in milliseconds (ms). */
|
---|
250 | typedef uint32_t PDMAUDIODEVLATSPECMS;
|
---|
251 |
|
---|
252 | /** Device latency spec in seconds (s). */
|
---|
253 | typedef uint32_t PDMAUDIODEVLATSPECSEC;
|
---|
254 |
|
---|
255 | /** Audio device flags. Use with PDMAUDIODEV_FLAG_ flags. */
|
---|
256 | typedef uint32_t PDMAUDIODEVFLAG;
|
---|
257 |
|
---|
258 | /** No flags set. */
|
---|
259 | #define PDMAUDIODEV_FLAGS_NONE 0
|
---|
260 | /** The device marks the default device within the host OS. */
|
---|
261 | #define PDMAUDIODEV_FLAGS_DEFAULT RT_BIT(0)
|
---|
262 | /** The device can be removed at any time and we have to deal with it. */
|
---|
263 | #define PDMAUDIODEV_FLAGS_HOTPLUG RT_BIT(1)
|
---|
264 | /** The device is known to be buggy and needs special treatment. */
|
---|
265 | #define PDMAUDIODEV_FLAGS_BUGGY RT_BIT(2)
|
---|
266 | /** Ignore the device, no matter what. */
|
---|
267 | #define PDMAUDIODEV_FLAGS_IGNORE RT_BIT(3)
|
---|
268 | /** The device is present but marked as locked by some other application. */
|
---|
269 | #define PDMAUDIODEV_FLAGS_LOCKED RT_BIT(4)
|
---|
270 | /** The device is present but not in an alive state (dead). */
|
---|
271 | #define PDMAUDIODEV_FLAGS_DEAD RT_BIT(5)
|
---|
272 |
|
---|
273 | /**
|
---|
274 | * Audio device type.
|
---|
275 | */
|
---|
276 | typedef enum PDMAUDIODEVICETYPE
|
---|
277 | {
|
---|
278 | /** Unknown device type. This is the default. */
|
---|
279 | PDMAUDIODEVICETYPE_UNKNOWN = 0,
|
---|
280 | /** Dummy device; for backends which are not able to report
|
---|
281 | * actual device information (yet). */
|
---|
282 | PDMAUDIODEVICETYPE_DUMMY,
|
---|
283 | /** The device is built into the host (non-removable). */
|
---|
284 | PDMAUDIODEVICETYPE_BUILTIN,
|
---|
285 | /** The device is an (external) USB device. */
|
---|
286 | PDMAUDIODEVICETYPE_USB,
|
---|
287 | /** Hack to blow the type up to 32-bit. */
|
---|
288 | PDMAUDIODEVICETYPE_32BIT_HACK = 0x7fffffff
|
---|
289 | } PDMAUDIODEVICETYPE;
|
---|
290 |
|
---|
291 | /**
|
---|
292 | * Audio device instance data.
|
---|
293 | */
|
---|
294 | typedef struct PDMAUDIODEVICE
|
---|
295 | {
|
---|
296 | /** List node. */
|
---|
297 | RTLISTNODE Node;
|
---|
298 | /** Friendly name of the device, if any. */
|
---|
299 | char szName[64];
|
---|
300 | /** The device type. */
|
---|
301 | PDMAUDIODEVICETYPE enmType;
|
---|
302 | /** Reference count indicating how many audio streams currently are relying on this device. */
|
---|
303 | uint8_t cRefCount;
|
---|
304 | /** Usage of the device. */
|
---|
305 | PDMAUDIODIR enmUsage;
|
---|
306 | /** Device flags. */
|
---|
307 | PDMAUDIODEVFLAG fFlags;
|
---|
308 | /** Maximum number of input audio channels the device supports. */
|
---|
309 | uint8_t cMaxInputChannels;
|
---|
310 | /** Maximum number of output audio channels the device supports. */
|
---|
311 | uint8_t cMaxOutputChannels;
|
---|
312 | /** Additional data which might be relevant for the current context. */
|
---|
313 | void *pvData;
|
---|
314 | /** Size of the additional data. */
|
---|
315 | size_t cbData;
|
---|
316 | /** Device type union, based on enmType. */
|
---|
317 | union
|
---|
318 | {
|
---|
319 | /** USB type specifics. */
|
---|
320 | struct
|
---|
321 | {
|
---|
322 | /** Vendor ID. */
|
---|
323 | int16_t VID;
|
---|
324 | /** Product ID. */
|
---|
325 | int16_t PID;
|
---|
326 | } USB;
|
---|
327 | } Type;
|
---|
328 | } PDMAUDIODEVICE, *PPDMAUDIODEVICE;
|
---|
329 |
|
---|
330 | /**
|
---|
331 | * Structure for keeping an audio device enumeration.
|
---|
332 | */
|
---|
333 | typedef struct PDMAUDIODEVICEENUM
|
---|
334 | {
|
---|
335 | /** Number of audio devices in the list. */
|
---|
336 | uint16_t cDevices;
|
---|
337 | /** List of audio devices. */
|
---|
338 | RTLISTANCHOR lstDevices;
|
---|
339 | } PDMAUDIODEVICEENUM, *PPDMAUDIODEVICEENUM;
|
---|
340 |
|
---|
341 | /**
|
---|
342 | * Audio (static) configuration of an audio host backend.
|
---|
343 | */
|
---|
344 | typedef struct PDMAUDIOBACKENDCFG
|
---|
345 | {
|
---|
346 | /** The backend's friendly name. */
|
---|
347 | char szName[32];
|
---|
348 | /** Size (in bytes) of the host backend's audio output stream structure. */
|
---|
349 | size_t cbStreamOut;
|
---|
350 | /** Size (in bytes) of the host backend's audio input stream structure. */
|
---|
351 | size_t cbStreamIn;
|
---|
352 | /** Number of concurrent output (playback) streams supported on the host.
|
---|
353 | * UINT32_MAX for unlimited concurrent streams, 0 if no concurrent input streams are supported. */
|
---|
354 | uint32_t cMaxStreamsOut;
|
---|
355 | /** Number of concurrent input (recording) streams supported on the host.
|
---|
356 | * UINT32_MAX for unlimited concurrent streams, 0 if no concurrent input streams are supported. */
|
---|
357 | uint32_t cMaxStreamsIn;
|
---|
358 | } PDMAUDIOBACKENDCFG, *PPDMAUDIOBACKENDCFG;
|
---|
359 |
|
---|
360 | /**
|
---|
361 | * A single audio frame.
|
---|
362 | *
|
---|
363 | * Currently only two (2) channels, left and right, are supported.
|
---|
364 | *
|
---|
365 | * Note: When changing this structure, make sure to also handle
|
---|
366 | * VRDP's input / output processing in DrvAudioVRDE, as VRDP
|
---|
367 | * expects audio data in st_sample_t format (historical reasons)
|
---|
368 | * which happens to be the same as PDMAUDIOFRAME for now.
|
---|
369 | */
|
---|
370 | typedef struct PDMAUDIOFRAME
|
---|
371 | {
|
---|
372 | /** Left channel. */
|
---|
373 | int64_t i64LSample;
|
---|
374 | /** Right channel. */
|
---|
375 | int64_t i64RSample;
|
---|
376 | } PDMAUDIOFRAME;
|
---|
377 | /** Pointer to a single (stereo) audio frame. */
|
---|
378 | typedef PDMAUDIOFRAME *PPDMAUDIOFRAME;
|
---|
379 | /** Pointer to a const single (stereo) audio frame. */
|
---|
380 | typedef PDMAUDIOFRAME const *PCPDMAUDIOFRAME;
|
---|
381 |
|
---|
382 | typedef enum PDMAUDIOENDIANNESS
|
---|
383 | {
|
---|
384 | /** The usual invalid endian. */
|
---|
385 | PDMAUDIOENDIANNESS_INVALID,
|
---|
386 | /** Little endian. */
|
---|
387 | PDMAUDIOENDIANNESS_LITTLE,
|
---|
388 | /** Bit endian. */
|
---|
389 | PDMAUDIOENDIANNESS_BIG,
|
---|
390 | /** Endianness doesn't have a meaning in the context. */
|
---|
391 | PDMAUDIOENDIANNESS_NA,
|
---|
392 | /** The end of the valid endian values (exclusive). */
|
---|
393 | PDMAUDIOENDIANNESS_END,
|
---|
394 | /** Hack to blow the type up to 32-bit. */
|
---|
395 | PDMAUDIOENDIANNESS_32BIT_HACK = 0x7fffffff
|
---|
396 | } PDMAUDIOENDIANNESS;
|
---|
397 |
|
---|
398 | /**
|
---|
399 | * Audio playback destinations.
|
---|
400 | */
|
---|
401 | typedef enum PDMAUDIOPLAYBACKDEST
|
---|
402 | {
|
---|
403 | /** Unknown destination. */
|
---|
404 | PDMAUDIOPLAYBACKDEST_UNKNOWN = 0,
|
---|
405 | /** Front channel. */
|
---|
406 | PDMAUDIOPLAYBACKDEST_FRONT,
|
---|
407 | /** Center / LFE (Subwoofer) channel. */
|
---|
408 | PDMAUDIOPLAYBACKDEST_CENTER_LFE,
|
---|
409 | /** Rear channel. */
|
---|
410 | PDMAUDIOPLAYBACKDEST_REAR,
|
---|
411 | /** Hack to blow the type up to 32-bit. */
|
---|
412 | PDMAUDIOPLAYBACKDEST_32BIT_HACK = 0x7fffffff
|
---|
413 | } PDMAUDIOPLAYBACKDEST;
|
---|
414 |
|
---|
415 | /**
|
---|
416 | * Audio recording sources.
|
---|
417 | */
|
---|
418 | typedef enum PDMAUDIORECSOURCE
|
---|
419 | {
|
---|
420 | /** Unknown recording source. */
|
---|
421 | PDMAUDIORECSOURCE_UNKNOWN = 0,
|
---|
422 | /** Microphone-In. */
|
---|
423 | PDMAUDIORECSOURCE_MIC,
|
---|
424 | /** CD. */
|
---|
425 | PDMAUDIORECSOURCE_CD,
|
---|
426 | /** Video-In. */
|
---|
427 | PDMAUDIORECSOURCE_VIDEO,
|
---|
428 | /** AUX. */
|
---|
429 | PDMAUDIORECSOURCE_AUX,
|
---|
430 | /** Line-In. */
|
---|
431 | PDMAUDIORECSOURCE_LINE,
|
---|
432 | /** Phone-In. */
|
---|
433 | PDMAUDIORECSOURCE_PHONE,
|
---|
434 | /** Hack to blow the type up to 32-bit. */
|
---|
435 | PDMAUDIORECSOURCE_32BIT_HACK = 0x7fffffff
|
---|
436 | } PDMAUDIORECSOURCE;
|
---|
437 |
|
---|
438 | /**
|
---|
439 | * Audio stream (data) layout.
|
---|
440 | */
|
---|
441 | typedef enum PDMAUDIOSTREAMLAYOUT
|
---|
442 | {
|
---|
443 | /** Unknown access type; do not use. */
|
---|
444 | PDMAUDIOSTREAMLAYOUT_UNKNOWN = 0,
|
---|
445 | /** Non-interleaved access, that is, consecutive
|
---|
446 | * access to the data. */
|
---|
447 | PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED,
|
---|
448 | /** Interleaved access, where the data can be
|
---|
449 | * mixed together with data of other audio streams. */
|
---|
450 | PDMAUDIOSTREAMLAYOUT_INTERLEAVED,
|
---|
451 | /** Complex layout, which does not fit into the
|
---|
452 | * interleaved / non-interleaved layouts. */
|
---|
453 | PDMAUDIOSTREAMLAYOUT_COMPLEX,
|
---|
454 | /** Raw (pass through) data, with no data layout processing done.
|
---|
455 | *
|
---|
456 | * This means that this stream will operate on PDMAUDIOFRAME data
|
---|
457 | * directly. Don't use this if you don't have to. */
|
---|
458 | PDMAUDIOSTREAMLAYOUT_RAW,
|
---|
459 | /** Hack to blow the type up to 32-bit. */
|
---|
460 | PDMAUDIOSTREAMLAYOUT_32BIT_HACK = 0x7fffffff
|
---|
461 | } PDMAUDIOSTREAMLAYOUT, *PPDMAUDIOSTREAMLAYOUT;
|
---|
462 |
|
---|
463 | /** No stream channel data flags defined. */
|
---|
464 | #define PDMAUDIOSTREAMCHANNELDATA_FLAG_NONE 0
|
---|
465 |
|
---|
466 | /**
|
---|
467 | * Structure for keeping a stream channel data block around.
|
---|
468 | */
|
---|
469 | typedef struct PDMAUDIOSTREAMCHANNELDATA
|
---|
470 | {
|
---|
471 | /** Circular buffer for the channel data. */
|
---|
472 | PRTCIRCBUF pCircBuf;
|
---|
473 | size_t cbAcq;
|
---|
474 | /** Channel data flags. */
|
---|
475 | uint32_t fFlags;
|
---|
476 | } PDMAUDIOSTREAMCHANNELDATA, *PPDMAUDIOSTREAMCHANNELDATA;
|
---|
477 |
|
---|
478 | /**
|
---|
479 | * Structure for a single channel of an audio stream.
|
---|
480 | * An audio stream consists of one or multiple channels,
|
---|
481 | * depending on the configuration.
|
---|
482 | */
|
---|
483 | typedef struct PDMAUDIOSTREAMCHANNEL
|
---|
484 | {
|
---|
485 | /** Channel ID. */
|
---|
486 | uint8_t uChannel;
|
---|
487 | /** Step size (in bytes) to the channel's next frame. */
|
---|
488 | size_t cbStep;
|
---|
489 | /** Frame size (in bytes) of this channel. */
|
---|
490 | size_t cbFrame;
|
---|
491 | /** Offset (in bytes) to first frame in the data block. */
|
---|
492 | size_t cbFirst;
|
---|
493 | /** Currente offset (in bytes) in the data stream. */
|
---|
494 | size_t cbOff;
|
---|
495 | /** Associated data buffer. */
|
---|
496 | PDMAUDIOSTREAMCHANNELDATA Data;
|
---|
497 | } PDMAUDIOSTREAMCHANNEL, *PPDMAUDIOSTREAMCHANNEL;
|
---|
498 |
|
---|
499 | /**
|
---|
500 | * Union for keeping an audio stream destination or source.
|
---|
501 | */
|
---|
502 | typedef union PDMAUDIODESTSOURCE
|
---|
503 | {
|
---|
504 | /** Desired playback destination (for an output stream). */
|
---|
505 | PDMAUDIOPLAYBACKDEST Dest;
|
---|
506 | /** Desired recording source (for an input stream). */
|
---|
507 | PDMAUDIORECSOURCE Source;
|
---|
508 | } PDMAUDIODESTSOURCE, *PPDMAUDIODESTSOURCE;
|
---|
509 |
|
---|
510 | /**
|
---|
511 | * Properties of audio streams for host/guest for in or out directions.
|
---|
512 | */
|
---|
513 | typedef struct PDMAUDIOPCMPROPS
|
---|
514 | {
|
---|
515 | /** Sample width (in bytes). */
|
---|
516 | uint8_t cBytes;
|
---|
517 | /** Number of audio channels. */
|
---|
518 | uint8_t cChannels;
|
---|
519 | /** Shift count used for faster calculation of various
|
---|
520 | * values, such as the alignment, bytes to frames and so on.
|
---|
521 | * Depends on number of stream channels and the stream format
|
---|
522 | * being used.
|
---|
523 | *
|
---|
524 | ** @todo Use some RTAsmXXX functions instead?
|
---|
525 | */
|
---|
526 | uint8_t cShift;
|
---|
527 | /** Signed or unsigned sample. */
|
---|
528 | bool fSigned : 1;
|
---|
529 | /** Whether the endianness is swapped or not. */
|
---|
530 | bool fSwapEndian : 1;
|
---|
531 | /** Sample frequency in Hertz (Hz). */
|
---|
532 | uint32_t uHz;
|
---|
533 | } PDMAUDIOPCMPROPS;
|
---|
534 | AssertCompileSizeAlignment(PDMAUDIOPCMPROPS, 8);
|
---|
535 | /** Pointer to audio stream properties. */
|
---|
536 | typedef PDMAUDIOPCMPROPS *PPDMAUDIOPCMPROPS;
|
---|
537 |
|
---|
538 | /** Initializor for PDMAUDIOPCMPROPS. */
|
---|
539 | #define PDMAUDIOPCMPROPS_INITIALIZOR(a_cBytes, a_fSigned, a_cCannels, a_uHz, a_cShift, a_fSwapEndian) \
|
---|
540 | { a_cBytes, a_cCannels, a_cShift, a_fSigned, a_fSwapEndian, a_uHz }
|
---|
541 | /** Calculates the cShift value of given sample bits and audio channels.
|
---|
542 | * Note: Does only support mono/stereo channels for now. */
|
---|
543 | #define PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS(cBytes, cChannels) ((cChannels == 2) + (cBytes / 2))
|
---|
544 | /** Calculates the cShift value of a PDMAUDIOPCMPROPS structure. */
|
---|
545 | #define PDMAUDIOPCMPROPS_MAKE_SHIFT(pProps) PDMAUDIOPCMPROPS_MAKE_SHIFT_PARMS((pProps)->cBytes, (pProps)->cChannels)
|
---|
546 | /** Converts (audio) frames to bytes.
|
---|
547 | * Needs the cShift value set correctly, using PDMAUDIOPCMPROPS_MAKE_SHIFT. */
|
---|
548 | #define PDMAUDIOPCMPROPS_F2B(pProps, frames) ((frames) << (pProps)->cShift)
|
---|
549 | /** Converts bytes to (audio) frames.
|
---|
550 | * Needs the cShift value set correctly, using PDMAUDIOPCMPROPS_MAKE_SHIFT. */
|
---|
551 | #define PDMAUDIOPCMPROPS_B2F(pProps, cb) (cb >> (pProps)->cShift)
|
---|
552 |
|
---|
553 | /**
|
---|
554 | * Structure for keeping an audio stream configuration.
|
---|
555 | */
|
---|
556 | typedef struct PDMAUDIOSTREAMCFG
|
---|
557 | {
|
---|
558 | /** Friendly name of the stream. */
|
---|
559 | char szName[64];
|
---|
560 | /** Direction of the stream. */
|
---|
561 | PDMAUDIODIR enmDir;
|
---|
562 | /** Destination / source indicator, depending on enmDir. */
|
---|
563 | PDMAUDIODESTSOURCE DestSource;
|
---|
564 | /** The stream's PCM properties. */
|
---|
565 | PDMAUDIOPCMPROPS Props;
|
---|
566 | /** The stream's audio data layout.
|
---|
567 | * This indicates how the audio data buffers to/from the backend is being layouted.
|
---|
568 | *
|
---|
569 | * Currently, the following layouts are supported by the audio connector:
|
---|
570 | *
|
---|
571 | * PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED:
|
---|
572 | * One stream at once. The consecutive audio data is exactly in the format and frame width
|
---|
573 | * like defined in the PCM properties. This is the default.
|
---|
574 | *
|
---|
575 | * PDMAUDIOSTREAMLAYOUT_RAW:
|
---|
576 | * Can be one or many streams at once, depending on the stream's mixing buffer setup.
|
---|
577 | * The audio data will get handled as PDMAUDIOFRAME frames without any modification done. */
|
---|
578 | PDMAUDIOSTREAMLAYOUT enmLayout;
|
---|
579 | /** Device emulation-specific data needed for the audio connector. */
|
---|
580 | struct
|
---|
581 | {
|
---|
582 | /** Scheduling hint set by the device emulation about when this stream is being served on average (in ms).
|
---|
583 | * Can be 0 if not hint given or some other mechanism (e.g. callbacks) is being used. */
|
---|
584 | uint32_t uSchedulingHintMs;
|
---|
585 | } Device;
|
---|
586 | /**
|
---|
587 | * Backend-specific data for the stream.
|
---|
588 | * On input (requested configuration) those values are set by the audio connector to let the backend know what we expect.
|
---|
589 | * On output (acquired configuration) those values reflect the values set and used by the backend.
|
---|
590 | * Set by the backend on return. Not all backends support all values / features.
|
---|
591 | */
|
---|
592 | struct
|
---|
593 | {
|
---|
594 | /** Period size of the stream (in audio frames).
|
---|
595 | * This value reflects the number of audio frames in between each hardware interrupt on the
|
---|
596 | * backend (host) side. 0 if not set / available by the backend. */
|
---|
597 | uint32_t cfPeriod;
|
---|
598 | /** (Ring) buffer size (in audio frames). Often is a multiple of cfPeriod.
|
---|
599 | * 0 if not set / available by the backend. */
|
---|
600 | uint32_t cfBufferSize;
|
---|
601 | /** Pre-buffering size (in audio frames). Frames needed in buffer before the stream becomes active (pre buffering).
|
---|
602 | * The bigger this value is, the more latency for the stream will occur.
|
---|
603 | * 0 if not set / available by the backend. */
|
---|
604 | uint32_t cfPreBuf;
|
---|
605 | } Backend;
|
---|
606 | } PDMAUDIOSTREAMCFG;
|
---|
607 | AssertCompileSizeAlignment(PDMAUDIOPCMPROPS, 8);
|
---|
608 | /** Pointer to audio stream configuration keeper. */
|
---|
609 | typedef PDMAUDIOSTREAMCFG *PPDMAUDIOSTREAMCFG;
|
---|
610 |
|
---|
611 |
|
---|
612 | /** Converts (audio) frames to bytes. */
|
---|
613 | #define PDMAUDIOSTREAMCFG_F2B(pCfg, frames) ((frames) << (pCfg->Props).cShift)
|
---|
614 | /** Converts bytes to (audio) frames. */
|
---|
615 | #define PDMAUDIOSTREAMCFG_B2F(pCfg, cb) (cb >> (pCfg->Props).cShift)
|
---|
616 |
|
---|
617 | #if defined(RT_LITTLE_ENDIAN)
|
---|
618 | # define PDMAUDIOHOSTENDIANNESS PDMAUDIOENDIANNESS_LITTLE
|
---|
619 | #elif defined(RT_BIG_ENDIAN)
|
---|
620 | # define PDMAUDIOHOSTENDIANNESS PDMAUDIOENDIANNESS_BIG
|
---|
621 | #else
|
---|
622 | # error "Port me!"
|
---|
623 | #endif
|
---|
624 |
|
---|
625 | /**
|
---|
626 | * Audio mixer controls.
|
---|
627 | */
|
---|
628 | typedef enum PDMAUDIOMIXERCTL
|
---|
629 | {
|
---|
630 | /** Unknown mixer control. */
|
---|
631 | PDMAUDIOMIXERCTL_UNKNOWN = 0,
|
---|
632 | /** Master volume. */
|
---|
633 | PDMAUDIOMIXERCTL_VOLUME_MASTER,
|
---|
634 | /** Front. */
|
---|
635 | PDMAUDIOMIXERCTL_FRONT,
|
---|
636 | /** Center / LFE (Subwoofer). */
|
---|
637 | PDMAUDIOMIXERCTL_CENTER_LFE,
|
---|
638 | /** Rear. */
|
---|
639 | PDMAUDIOMIXERCTL_REAR,
|
---|
640 | /** Line-In. */
|
---|
641 | PDMAUDIOMIXERCTL_LINE_IN,
|
---|
642 | /** Microphone-In. */
|
---|
643 | PDMAUDIOMIXERCTL_MIC_IN,
|
---|
644 | /** Hack to blow the type up to 32-bit. */
|
---|
645 | PDMAUDIOMIXERCTL_32BIT_HACK = 0x7fffffff
|
---|
646 | } PDMAUDIOMIXERCTL;
|
---|
647 |
|
---|
648 | /**
|
---|
649 | * Audio stream commands. Used in the audio connector
|
---|
650 | * as well as in the actual host backends.
|
---|
651 | */
|
---|
652 | typedef enum PDMAUDIOSTREAMCMD
|
---|
653 | {
|
---|
654 | /** Unknown command, do not use. */
|
---|
655 | PDMAUDIOSTREAMCMD_UNKNOWN = 0,
|
---|
656 | /** Enables the stream. */
|
---|
657 | PDMAUDIOSTREAMCMD_ENABLE,
|
---|
658 | /** Disables the stream.
|
---|
659 | * For output streams this stops the stream after playing the remaining (buffered) audio data.
|
---|
660 | * For input streams this will deliver the remaining (captured) audio data and not accepting
|
---|
661 | * any new audio input data afterwards. */
|
---|
662 | PDMAUDIOSTREAMCMD_DISABLE,
|
---|
663 | /** Pauses the stream. */
|
---|
664 | PDMAUDIOSTREAMCMD_PAUSE,
|
---|
665 | /** Resumes the stream. */
|
---|
666 | PDMAUDIOSTREAMCMD_RESUME,
|
---|
667 | /** Tells the stream to drain itself.
|
---|
668 | * For output streams this plays all remaining (buffered) audio frames,
|
---|
669 | * for input streams this permits receiving any new audio frames.
|
---|
670 | * No supported by all backends. */
|
---|
671 | PDMAUDIOSTREAMCMD_DRAIN,
|
---|
672 | /** Tells the stream to drop all (buffered) audio data immediately.
|
---|
673 | * No supported by all backends. */
|
---|
674 | PDMAUDIOSTREAMCMD_DROP,
|
---|
675 | /** Hack to blow the type up to 32-bit. */
|
---|
676 | PDMAUDIOSTREAMCMD_32BIT_HACK = 0x7fffffff
|
---|
677 | } PDMAUDIOSTREAMCMD;
|
---|
678 |
|
---|
679 | /**
|
---|
680 | * Audio volume parameters.
|
---|
681 | */
|
---|
682 | typedef struct PDMAUDIOVOLUME
|
---|
683 | {
|
---|
684 | /** Set to @c true if this stream is muted, @c false if not. */
|
---|
685 | bool fMuted;
|
---|
686 | /** Left channel volume.
|
---|
687 | * Range is from [0 ... 255], whereas 0 specifies
|
---|
688 | * the most silent and 255 the loudest value. */
|
---|
689 | uint8_t uLeft;
|
---|
690 | /** Right channel volume.
|
---|
691 | * Range is from [0 ... 255], whereas 0 specifies
|
---|
692 | * the most silent and 255 the loudest value. */
|
---|
693 | uint8_t uRight;
|
---|
694 | } PDMAUDIOVOLUME, *PPDMAUDIOVOLUME;
|
---|
695 |
|
---|
696 | /** Defines the minimum volume allowed. */
|
---|
697 | #define PDMAUDIO_VOLUME_MIN (0)
|
---|
698 | /** Defines the maximum volume allowed. */
|
---|
699 | #define PDMAUDIO_VOLUME_MAX (255)
|
---|
700 |
|
---|
701 | /**
|
---|
702 | * Structure for holding rate processing information
|
---|
703 | * of a source + destination audio stream. This is needed
|
---|
704 | * because both streams can differ regarding their rates
|
---|
705 | * and therefore need to be treated accordingly.
|
---|
706 | */
|
---|
707 | typedef struct PDMAUDIOSTREAMRATE
|
---|
708 | {
|
---|
709 | /** Current (absolute) offset in the output
|
---|
710 | * (destination) stream. */
|
---|
711 | uint64_t dstOffset;
|
---|
712 | /** Increment for moving dstOffset for the
|
---|
713 | * destination stream. This is needed because the
|
---|
714 | * source <-> destination rate might be different. */
|
---|
715 | uint64_t dstInc;
|
---|
716 | /** Current (absolute) offset in the input
|
---|
717 | * stream. */
|
---|
718 | uint32_t srcOffset;
|
---|
719 | /** Last processed frame of the input stream.
|
---|
720 | * Needed for interpolation. */
|
---|
721 | PDMAUDIOFRAME srcFrameLast;
|
---|
722 | } PDMAUDIOSTREAMRATE, *PPDMAUDIOSTREAMRATE;
|
---|
723 |
|
---|
724 | /**
|
---|
725 | * Structure for holding mixing buffer volume parameters.
|
---|
726 | * The volume values are in fixed point style and must
|
---|
727 | * be converted to/from before using with e.g. PDMAUDIOVOLUME.
|
---|
728 | */
|
---|
729 | typedef struct PDMAUDMIXBUFVOL
|
---|
730 | {
|
---|
731 | /** Set to @c true if this stream is muted, @c false if not. */
|
---|
732 | bool fMuted;
|
---|
733 | /** Left volume to apply during conversion. Pass 0
|
---|
734 | * to convert the original values. May not apply to
|
---|
735 | * all conversion functions. */
|
---|
736 | uint32_t uLeft;
|
---|
737 | /** Right volume to apply during conversion. Pass 0
|
---|
738 | * to convert the original values. May not apply to
|
---|
739 | * all conversion functions. */
|
---|
740 | uint32_t uRight;
|
---|
741 | } PDMAUDMIXBUFVOL, *PPDMAUDMIXBUFVOL;
|
---|
742 |
|
---|
743 | /**
|
---|
744 | * Structure for holding frame conversion parameters for
|
---|
745 | * the audioMixBufConvFromXXX / audioMixBufConvToXXX macros.
|
---|
746 | */
|
---|
747 | typedef struct PDMAUDMIXBUFCONVOPTS
|
---|
748 | {
|
---|
749 | /** Number of audio frames to convert. */
|
---|
750 | uint32_t cFrames;
|
---|
751 | union
|
---|
752 | {
|
---|
753 | struct
|
---|
754 | {
|
---|
755 | /** Volume to use for conversion. */
|
---|
756 | PDMAUDMIXBUFVOL Volume;
|
---|
757 | } From;
|
---|
758 | } RT_UNION_NM(u);
|
---|
759 | } PDMAUDMIXBUFCONVOPTS;
|
---|
760 | /** Pointer to conversion parameters for the audio mixer. */
|
---|
761 | typedef PDMAUDMIXBUFCONVOPTS *PPDMAUDMIXBUFCONVOPTS;
|
---|
762 | /** Pointer to const conversion parameters for the audio mixer. */
|
---|
763 | typedef PDMAUDMIXBUFCONVOPTS const *PCPDMAUDMIXBUFCONVOPTS;
|
---|
764 |
|
---|
765 | /**
|
---|
766 | * Note: All internal handling is done in audio frames,
|
---|
767 | * not in bytes!
|
---|
768 | */
|
---|
769 | typedef uint32_t PDMAUDIOMIXBUFFMT;
|
---|
770 | typedef PDMAUDIOMIXBUFFMT *PPDMAUDIOMIXBUFFMT;
|
---|
771 |
|
---|
772 | /**
|
---|
773 | * Convertion-from function used by the PDM audio buffer mixer.
|
---|
774 | *
|
---|
775 | * @returns Number of audio frames returned.
|
---|
776 | * @param paDst Where to return the converted frames.
|
---|
777 | * @param pvSrc The source frame bytes.
|
---|
778 | * @param cbSrc Number of bytes to convert.
|
---|
779 | * @param pOpts Conversion options.
|
---|
780 | */
|
---|
781 | typedef DECLCALLBACK(uint32_t) FNPDMAUDIOMIXBUFCONVFROM(PPDMAUDIOFRAME paDst, const void *pvSrc, uint32_t cbSrc,
|
---|
782 | PCPDMAUDMIXBUFCONVOPTS pOpts);
|
---|
783 | /** Pointer to a convertion-from function used by the PDM audio buffer mixer. */
|
---|
784 | typedef FNPDMAUDIOMIXBUFCONVFROM *PFNPDMAUDIOMIXBUFCONVFROM;
|
---|
785 |
|
---|
786 | /**
|
---|
787 | * Convertion-to function used by the PDM audio buffer mixer.
|
---|
788 | *
|
---|
789 | * @param pvDst Output buffer.
|
---|
790 | * @param paSrc The input frames.
|
---|
791 | * @param pOpts Conversion options.
|
---|
792 | */
|
---|
793 | typedef DECLCALLBACK(void) FNPDMAUDIOMIXBUFCONVTO(void *pvDst, PCPDMAUDIOFRAME paSrc, PCPDMAUDMIXBUFCONVOPTS pOpts);
|
---|
794 | /** Pointer to a convertion-to function used by the PDM audio buffer mixer. */
|
---|
795 | typedef FNPDMAUDIOMIXBUFCONVTO *PFNPDMAUDIOMIXBUFCONVTO;
|
---|
796 |
|
---|
797 | typedef struct PDMAUDIOMIXBUF *PPDMAUDIOMIXBUF;
|
---|
798 | typedef struct PDMAUDIOMIXBUF
|
---|
799 | {
|
---|
800 | RTLISTNODE Node;
|
---|
801 | /** Name of the buffer. */
|
---|
802 | char *pszName;
|
---|
803 | /** Frame buffer. */
|
---|
804 | PPDMAUDIOFRAME pFrames;
|
---|
805 | /** Size of the frame buffer (in audio frames). */
|
---|
806 | uint32_t cFrames;
|
---|
807 | /** The current read position (in frames). */
|
---|
808 | uint32_t offRead;
|
---|
809 | /** The current write position (in frames). */
|
---|
810 | uint32_t offWrite;
|
---|
811 | /**
|
---|
812 | * Total frames already mixed down to the parent buffer (if any). Always starting at
|
---|
813 | * the parent's offRead position.
|
---|
814 | *
|
---|
815 | * Note: Count always is specified in parent frames, as the sample count can differ between parent
|
---|
816 | * and child.
|
---|
817 | */
|
---|
818 | uint32_t cMixed;
|
---|
819 | /** How much audio frames are currently being used
|
---|
820 | * in this buffer.
|
---|
821 | * Note: This also is known as the distance in ring buffer terms. */
|
---|
822 | uint32_t cUsed;
|
---|
823 | /** Pointer to parent buffer (if any). */
|
---|
824 | PPDMAUDIOMIXBUF pParent;
|
---|
825 | /** List of children mix buffers to keep in sync with (if being a parent buffer). */
|
---|
826 | RTLISTANCHOR lstChildren;
|
---|
827 | /** Number of children mix buffers kept in lstChildren. */
|
---|
828 | uint32_t cChildren;
|
---|
829 | /** Intermediate structure for buffer conversion tasks. */
|
---|
830 | PPDMAUDIOSTREAMRATE pRate;
|
---|
831 | /** Internal representation of current volume used for mixing. */
|
---|
832 | PDMAUDMIXBUFVOL Volume;
|
---|
833 | /** This buffer's audio format. */
|
---|
834 | PDMAUDIOMIXBUFFMT AudioFmt;
|
---|
835 | /** Standard conversion-to function for set AudioFmt. */
|
---|
836 | PFNPDMAUDIOMIXBUFCONVTO pfnConvTo;
|
---|
837 | /** Standard conversion-from function for set AudioFmt. */
|
---|
838 | PFNPDMAUDIOMIXBUFCONVFROM pfnConvFrom;
|
---|
839 | /**
|
---|
840 | * Ratio of the associated parent stream's frequency by this stream's
|
---|
841 | * frequency (1<<32), represented as a signed 64 bit integer.
|
---|
842 | *
|
---|
843 | * For example, if the parent stream has a frequency of 44 khZ, and this
|
---|
844 | * stream has a frequency of 11 kHz, the ration then would be
|
---|
845 | * (44/11 * (1 << 32)).
|
---|
846 | *
|
---|
847 | * Currently this does not get changed once assigned.
|
---|
848 | */
|
---|
849 | int64_t iFreqRatio;
|
---|
850 | /** For quickly converting frames <-> bytes and vice versa. */
|
---|
851 | uint8_t cShift;
|
---|
852 | } PDMAUDIOMIXBUF;
|
---|
853 |
|
---|
854 | typedef uint32_t PDMAUDIOFILEFLAGS;
|
---|
855 |
|
---|
856 | /** No flags defined. */
|
---|
857 | #define PDMAUDIOFILE_FLAG_NONE 0
|
---|
858 | /** Keep the audio file even if it contains no audio data. */
|
---|
859 | #define PDMAUDIOFILE_FLAG_KEEP_IF_EMPTY RT_BIT(0)
|
---|
860 | /** Audio file flag validation mask. */
|
---|
861 | #define PDMAUDIOFILE_FLAG_VALID_MASK 0x1
|
---|
862 |
|
---|
863 | /** Audio file default open flags. */
|
---|
864 | #define PDMAUDIOFILE_DEFAULT_OPEN_FLAGS (RTFILE_O_OPEN_CREATE | RTFILE_O_APPEND | RTFILE_O_WRITE | RTFILE_O_DENY_WRITE)
|
---|
865 |
|
---|
866 | /**
|
---|
867 | * Audio file types.
|
---|
868 | */
|
---|
869 | typedef enum PDMAUDIOFILETYPE
|
---|
870 | {
|
---|
871 | /** Unknown type, do not use. */
|
---|
872 | PDMAUDIOFILETYPE_UNKNOWN = 0,
|
---|
873 | /** Raw (PCM) file. */
|
---|
874 | PDMAUDIOFILETYPE_RAW,
|
---|
875 | /** Wave (.WAV) file. */
|
---|
876 | PDMAUDIOFILETYPE_WAV,
|
---|
877 | /** Hack to blow the type up to 32-bit. */
|
---|
878 | PDMAUDIOFILETYPE_32BIT_HACK = 0x7fffffff
|
---|
879 | } PDMAUDIOFILETYPE;
|
---|
880 |
|
---|
881 | typedef uint32_t PDMAUDIOFILENAMEFLAGS;
|
---|
882 |
|
---|
883 | /** No flags defined. */
|
---|
884 | #define PDMAUDIOFILENAME_FLAG_NONE 0
|
---|
885 | /** Adds an ISO timestamp to the file name. */
|
---|
886 | #define PDMAUDIOFILENAME_FLAG_TS RT_BIT(0)
|
---|
887 |
|
---|
888 | /**
|
---|
889 | * Structure for an audio file handle.
|
---|
890 | */
|
---|
891 | typedef struct PDMAUDIOFILE
|
---|
892 | {
|
---|
893 | /** Type of the audio file. */
|
---|
894 | PDMAUDIOFILETYPE enmType;
|
---|
895 | /** Audio file flags. */
|
---|
896 | PDMAUDIOFILEFLAGS fFlags;
|
---|
897 | /** File name and path. */
|
---|
898 | char szName[RTPATH_MAX + 1];
|
---|
899 | /** Actual file handle. */
|
---|
900 | RTFILE hFile;
|
---|
901 | /** Data needed for the specific audio file type implemented.
|
---|
902 | * Optional, can be NULL. */
|
---|
903 | void *pvData;
|
---|
904 | /** Data size (in bytes). */
|
---|
905 | size_t cbData;
|
---|
906 | } PDMAUDIOFILE, *PPDMAUDIOFILE;
|
---|
907 |
|
---|
908 | /** Stream status flag. To be used with PDMAUDIOSTRMSTS_FLAG_ flags. */
|
---|
909 | typedef uint32_t PDMAUDIOSTREAMSTS;
|
---|
910 |
|
---|
911 | /** No flags being set. */
|
---|
912 | #define PDMAUDIOSTREAMSTS_FLAG_NONE 0
|
---|
913 | /** Whether this stream has been initialized by the
|
---|
914 | * backend or not. */
|
---|
915 | #define PDMAUDIOSTREAMSTS_FLAG_INITIALIZED RT_BIT_32(0)
|
---|
916 | /** Whether this stream is enabled or disabled. */
|
---|
917 | #define PDMAUDIOSTREAMSTS_FLAG_ENABLED RT_BIT_32(1)
|
---|
918 | /** Whether this stream has been paused or not. This also implies
|
---|
919 | * that this is an enabled stream! */
|
---|
920 | #define PDMAUDIOSTREAMSTS_FLAG_PAUSED RT_BIT_32(2)
|
---|
921 | /** Whether this stream was marked as being disabled
|
---|
922 | * but there are still associated guest output streams
|
---|
923 | * which rely on its data. */
|
---|
924 | #define PDMAUDIOSTREAMSTS_FLAG_PENDING_DISABLE RT_BIT_32(3)
|
---|
925 | /** Whether this stream is in re-initialization phase.
|
---|
926 | * All other bits remain untouched to be able to restore
|
---|
927 | * the stream's state after the re-initialization bas been
|
---|
928 | * finished. */
|
---|
929 | #define PDMAUDIOSTREAMSTS_FLAG_PENDING_REINIT RT_BIT_32(4)
|
---|
930 | /** Validation mask. */
|
---|
931 | #define PDMAUDIOSTREAMSTS_VALID_MASK UINT32_C(0x0000001F)
|
---|
932 |
|
---|
933 | /**
|
---|
934 | * Enumeration presenting a backend's current status.
|
---|
935 | */
|
---|
936 | typedef enum PDMAUDIOBACKENDSTS
|
---|
937 | {
|
---|
938 | /** Unknown/invalid status. */
|
---|
939 | PDMAUDIOBACKENDSTS_UNKNOWN = 0,
|
---|
940 | /** No backend attached. */
|
---|
941 | PDMAUDIOBACKENDSTS_NOT_ATTACHED,
|
---|
942 | /** The backend is in its initialization phase.
|
---|
943 | * Not all backends support this status. */
|
---|
944 | PDMAUDIOBACKENDSTS_INITIALIZING,
|
---|
945 | /** The backend has stopped its operation. */
|
---|
946 | PDMAUDIOBACKENDSTS_STOPPED,
|
---|
947 | /** The backend is up and running. */
|
---|
948 | PDMAUDIOBACKENDSTS_RUNNING,
|
---|
949 | /** The backend ran into an error and is unable to recover.
|
---|
950 | * A manual re-initialization might help. */
|
---|
951 | PDMAUDIOBACKENDSTS_ERROR,
|
---|
952 | /** Hack to blow the type up to 32-bit. */
|
---|
953 | PDMAUDIOBACKENDSTS_32BIT_HACK = 0x7fffffff
|
---|
954 | } PDMAUDIOBACKENDSTS;
|
---|
955 |
|
---|
956 | /**
|
---|
957 | * Structure for keeping audio input stream specifics.
|
---|
958 | * Do not use directly. Instead, use PDMAUDIOSTREAM.
|
---|
959 | */
|
---|
960 | typedef struct PDMAUDIOSTREAMIN
|
---|
961 | {
|
---|
962 | #ifdef VBOX_WITH_STATISTICS
|
---|
963 | struct
|
---|
964 | {
|
---|
965 | STAMCOUNTER BytesElapsed;
|
---|
966 | STAMCOUNTER BytesTotalRead;
|
---|
967 | STAMCOUNTER FramesCaptured;
|
---|
968 | } Stats;
|
---|
969 | #endif
|
---|
970 | struct
|
---|
971 | {
|
---|
972 | /** File for writing stream reads. */
|
---|
973 | PPDMAUDIOFILE pFileStreamRead;
|
---|
974 | /** File for writing non-interleaved captures. */
|
---|
975 | PPDMAUDIOFILE pFileCaptureNonInterleaved;
|
---|
976 | } Dbg;
|
---|
977 | } PDMAUDIOSTREAMIN, *PPDMAUDIOSTREAMIN;
|
---|
978 |
|
---|
979 | /**
|
---|
980 | * Structure for keeping audio output stream specifics.
|
---|
981 | * Do not use directly. Instead, use PDMAUDIOSTREAM.
|
---|
982 | */
|
---|
983 | typedef struct PDMAUDIOSTREAMOUT
|
---|
984 | {
|
---|
985 | #ifdef VBOX_WITH_STATISTICS
|
---|
986 | struct
|
---|
987 | {
|
---|
988 | STAMCOUNTER BytesElapsed;
|
---|
989 | STAMCOUNTER BytesTotalWritten;
|
---|
990 | STAMCOUNTER FramesPlayed;
|
---|
991 | } Stats;
|
---|
992 | #endif
|
---|
993 | struct
|
---|
994 | {
|
---|
995 | #ifdef DEBUG
|
---|
996 | /** Number of audio frames written since the last playback (transfer)
|
---|
997 | * to the backend. */
|
---|
998 | uint64_t cfWrittenSinceLastPlay;
|
---|
999 | #endif
|
---|
1000 | /** File for writing stream writes. */
|
---|
1001 | PPDMAUDIOFILE pFileStreamWrite;
|
---|
1002 | /** File for writing stream playback. */
|
---|
1003 | PPDMAUDIOFILE pFilePlayNonInterleaved;
|
---|
1004 | } Dbg;
|
---|
1005 | } PDMAUDIOSTREAMOUT, *PPDMAUDIOSTREAMOUT;
|
---|
1006 |
|
---|
1007 | /** Pointer to an audio stream. */
|
---|
1008 | typedef struct PDMAUDIOSTREAM *PPDMAUDIOSTREAM;
|
---|
1009 |
|
---|
1010 | /**
|
---|
1011 | * Audio stream context.
|
---|
1012 | * Needed for separating data from the guest and host side (per stream).
|
---|
1013 | */
|
---|
1014 | typedef struct PDMAUDIOSTREAMCTX
|
---|
1015 | {
|
---|
1016 | /** The stream's audio configuration. */
|
---|
1017 | PDMAUDIOSTREAMCFG Cfg;
|
---|
1018 | /** This stream's mixing buffer. */
|
---|
1019 | PDMAUDIOMIXBUF MixBuf;
|
---|
1020 | } PDMAUDIOSTREAMCTX;
|
---|
1021 |
|
---|
1022 | /** Pointer to an audio stream context. */
|
---|
1023 | typedef struct PDMAUDIOSTREAM *PPDMAUDIOSTREAMCTX;
|
---|
1024 |
|
---|
1025 | /**
|
---|
1026 | * Structure for maintaining an input/output audio stream.
|
---|
1027 | */
|
---|
1028 | typedef struct PDMAUDIOSTREAM
|
---|
1029 | {
|
---|
1030 | /** List node. */
|
---|
1031 | RTLISTNODE Node;
|
---|
1032 | /** Name of this stream. */
|
---|
1033 | char szName[64];
|
---|
1034 | /** Number of references to this stream. Only can be
|
---|
1035 | * destroyed if the reference count is reaching 0. */
|
---|
1036 | uint32_t cRefs;
|
---|
1037 | /** Stream status flag. */
|
---|
1038 | PDMAUDIOSTREAMSTS fStatus;
|
---|
1039 | /** Audio direction of this stream. */
|
---|
1040 | PDMAUDIODIR enmDir;
|
---|
1041 | /** The guest side of the stream. */
|
---|
1042 | PDMAUDIOSTREAMCTX Guest;
|
---|
1043 | /** The host side of the stream. */
|
---|
1044 | PDMAUDIOSTREAMCTX Host;
|
---|
1045 | /** Union for input/output specifics (based on enmDir). */
|
---|
1046 | union
|
---|
1047 | {
|
---|
1048 | PDMAUDIOSTREAMIN In;
|
---|
1049 | PDMAUDIOSTREAMOUT Out;
|
---|
1050 | } RT_UNION_NM(u);
|
---|
1051 | /** Timestamp (in ns) since last iteration. */
|
---|
1052 | uint64_t tsLastIteratedNs;
|
---|
1053 | /** Timestamp (in ns) since last playback / capture. */
|
---|
1054 | uint64_t tsLastPlayedCapturedNs;
|
---|
1055 | /** Timestamp (in ns) since last read (input streams) or
|
---|
1056 | * write (output streams). */
|
---|
1057 | uint64_t tsLastReadWrittenNs;
|
---|
1058 | /** For output streams this indicates whether the stream has reached
|
---|
1059 | * its playback threshold, e.g. is playing audio.
|
---|
1060 | * For input streams this indicates whether the stream has enough input
|
---|
1061 | * data to actually start reading audio. */
|
---|
1062 | bool fThresholdReached;
|
---|
1063 | /** Data to backend-specific stream data.
|
---|
1064 | * This data block will be casted by the backend to access its backend-dependent data.
|
---|
1065 | *
|
---|
1066 | * That way the backends do not have access to the audio connector's data. */
|
---|
1067 | void *pvBackend;
|
---|
1068 | /** Size (in bytes) of the backend-specific stream data. */
|
---|
1069 | size_t cbBackend;
|
---|
1070 | } PDMAUDIOSTREAM;
|
---|
1071 |
|
---|
1072 | /** Pointer to a audio connector interface. */
|
---|
1073 | typedef struct PDMIAUDIOCONNECTOR *PPDMIAUDIOCONNECTOR;
|
---|
1074 |
|
---|
1075 | /**
|
---|
1076 | * Enumeration for an audio callback source.
|
---|
1077 | */
|
---|
1078 | typedef enum PDMAUDIOCBSOURCE
|
---|
1079 | {
|
---|
1080 | /** Invalid, do not use. */
|
---|
1081 | PDMAUDIOCBSOURCE_INVALID = 0,
|
---|
1082 | /** Device emulation. */
|
---|
1083 | PDMAUDIOCBSOURCE_DEVICE = 1,
|
---|
1084 | /** Audio connector interface. */
|
---|
1085 | PDMAUDIOCBSOURCE_CONNECTOR = 2,
|
---|
1086 | /** Backend (lower). */
|
---|
1087 | PDMAUDIOCBSOURCE_BACKEND = 3,
|
---|
1088 | /** Hack to blow the type up to 32-bit. */
|
---|
1089 | PDMAUDIOCBSOURCE_32BIT_HACK = 0x7fffffff
|
---|
1090 | } PDMAUDIOCBSOURCE;
|
---|
1091 |
|
---|
1092 | /**
|
---|
1093 | * Audio device callback types.
|
---|
1094 | * Those callbacks are being sent from the audio connector -> device emulation.
|
---|
1095 | */
|
---|
1096 | typedef enum PDMAUDIODEVICECBTYPE
|
---|
1097 | {
|
---|
1098 | /** Invalid, do not use. */
|
---|
1099 | PDMAUDIODEVICECBTYPE_INVALID = 0,
|
---|
1100 | /** Data is availabe as input for passing to the device emulation. */
|
---|
1101 | PDMAUDIODEVICECBTYPE_DATA_INPUT,
|
---|
1102 | /** Free data for the device emulation to write to the backend. */
|
---|
1103 | PDMAUDIODEVICECBTYPE_DATA_OUTPUT,
|
---|
1104 | /** Hack to blow the type up to 32-bit. */
|
---|
1105 | PDMAUDIODEVICECBTYPE_32BIT_HACK = 0x7fffffff
|
---|
1106 | } PDMAUDIODEVICECBTYPE;
|
---|
1107 |
|
---|
1108 | /**
|
---|
1109 | * Device callback data for audio input.
|
---|
1110 | */
|
---|
1111 | typedef struct PDMAUDIODEVICECBDATA_DATA_INPUT
|
---|
1112 | {
|
---|
1113 | /** Input: How many bytes are availabe as input for passing
|
---|
1114 | * to the device emulation. */
|
---|
1115 | uint32_t cbInAvail;
|
---|
1116 | /** Output: How many bytes have been read. */
|
---|
1117 | uint32_t cbOutRead;
|
---|
1118 | } PDMAUDIODEVICECBDATA_DATA_INPUT, *PPDMAUDIODEVICECBDATA_DATA_INPUT;
|
---|
1119 |
|
---|
1120 | /**
|
---|
1121 | * Device callback data for audio output.
|
---|
1122 | */
|
---|
1123 | typedef struct PDMAUDIODEVICECBDATA_DATA_OUTPUT
|
---|
1124 | {
|
---|
1125 | /** Input: How many bytes are free for the device emulation to write. */
|
---|
1126 | uint32_t cbInFree;
|
---|
1127 | /** Output: How many bytes were written by the device emulation. */
|
---|
1128 | uint32_t cbOutWritten;
|
---|
1129 | } PDMAUDIODEVICECBDATA_DATA_OUTPUT, *PPDMAUDIODEVICECBDATA_DATA_OUTPUT;
|
---|
1130 |
|
---|
1131 | /**
|
---|
1132 | * Audio backend callback types.
|
---|
1133 | * Those callbacks are being sent from the backend -> audio connector.
|
---|
1134 | */
|
---|
1135 | typedef enum PDMAUDIOBACKENDCBTYPE
|
---|
1136 | {
|
---|
1137 | /** Invalid, do not use. */
|
---|
1138 | PDMAUDIOBACKENDCBTYPE_INVALID = 0,
|
---|
1139 | /** The backend's status has changed. */
|
---|
1140 | PDMAUDIOBACKENDCBTYPE_STATUS,
|
---|
1141 | /** One or more host audio devices have changed. */
|
---|
1142 | PDMAUDIOBACKENDCBTYPE_DEVICES_CHANGED,
|
---|
1143 | /** Hack to blow the type up to 32-bit. */
|
---|
1144 | PDMAUDIOBACKENDCBTYPE_32BIT_HACK = 0x7fffffff
|
---|
1145 | } PDMAUDIOBACKENDCBTYPE;
|
---|
1146 |
|
---|
1147 | /** Pointer to a host audio interface. */
|
---|
1148 | typedef struct PDMIHOSTAUDIO *PPDMIHOSTAUDIO;
|
---|
1149 |
|
---|
1150 | /**
|
---|
1151 | * Host audio callback function.
|
---|
1152 | * This function will be called from a backend to communicate with the host audio interface.
|
---|
1153 | *
|
---|
1154 | * @returns IPRT status code.
|
---|
1155 | * @param pDrvIns Pointer to driver instance which called us.
|
---|
1156 | * @param enmType Callback type.
|
---|
1157 | * @param pvUser User argument.
|
---|
1158 | * @param cbUser Size (in bytes) of user argument.
|
---|
1159 | */
|
---|
1160 | typedef DECLCALLBACK(int) FNPDMHOSTAUDIOCALLBACK(PPDMDRVINS pDrvIns, PDMAUDIOBACKENDCBTYPE enmType, void *pvUser, size_t cbUser);
|
---|
1161 | /** Pointer to a FNPDMHOSTAUDIOCALLBACK(). */
|
---|
1162 | typedef FNPDMHOSTAUDIOCALLBACK *PFNPDMHOSTAUDIOCALLBACK;
|
---|
1163 |
|
---|
1164 | /**
|
---|
1165 | * Audio callback registration record.
|
---|
1166 | */
|
---|
1167 | typedef struct PDMAUDIOCBRECORD
|
---|
1168 | {
|
---|
1169 | /** List node. */
|
---|
1170 | RTLISTANCHOR Node;
|
---|
1171 | /** Callback source. */
|
---|
1172 | PDMAUDIOCBSOURCE enmSource;
|
---|
1173 | /** Callback type, based on the given source. */
|
---|
1174 | union
|
---|
1175 | {
|
---|
1176 | /** Device callback stuff. */
|
---|
1177 | struct
|
---|
1178 | {
|
---|
1179 | PDMAUDIODEVICECBTYPE enmType;
|
---|
1180 | } Device;
|
---|
1181 | } RT_UNION_NM(u);
|
---|
1182 | /** Pointer to context data. Optional. */
|
---|
1183 | void *pvCtx;
|
---|
1184 | /** Size (in bytes) of context data.
|
---|
1185 | * Must be 0 if pvCtx is NULL. */
|
---|
1186 | size_t cbCtx;
|
---|
1187 | } PDMAUDIOCBRECORD, *PPDMAUDIOCBRECORD;
|
---|
1188 |
|
---|
1189 | #define PPDMAUDIOBACKENDSTREAM void *
|
---|
1190 |
|
---|
1191 | /**
|
---|
1192 | * Audio connector interface (up).
|
---|
1193 | */
|
---|
1194 | typedef struct PDMIAUDIOCONNECTOR
|
---|
1195 | {
|
---|
1196 | /**
|
---|
1197 | * Enables or disables the given audio direction for this driver.
|
---|
1198 | *
|
---|
1199 | * When disabled, assiociated output streams consume written audio without passing them further down to the backends.
|
---|
1200 | * Associated input streams then return silence when read from those.
|
---|
1201 | *
|
---|
1202 | * @returns VBox status code.
|
---|
1203 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1204 | * @param enmDir Audio direction to enable or disable driver for.
|
---|
1205 | * @param fEnable Whether to enable or disable the specified audio direction.
|
---|
1206 | */
|
---|
1207 | DECLR3CALLBACKMEMBER(int, pfnEnable, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir, bool fEnable));
|
---|
1208 |
|
---|
1209 | /**
|
---|
1210 | * Returns whether the given audio direction for this driver is enabled or not.
|
---|
1211 | *
|
---|
1212 | * @returns True if audio is enabled for the given direction, false if not.
|
---|
1213 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1214 | * @param enmDir Audio direction to retrieve enabled status for.
|
---|
1215 | */
|
---|
1216 | DECLR3CALLBACKMEMBER(bool, pfnIsEnabled, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir));
|
---|
1217 |
|
---|
1218 | /**
|
---|
1219 | * Retrieves the current configuration of the host audio backend.
|
---|
1220 | *
|
---|
1221 | * @returns VBox status code.
|
---|
1222 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1223 | * @param pCfg Where to store the host audio backend configuration data.
|
---|
1224 | */
|
---|
1225 | DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOBACKENDCFG pCfg));
|
---|
1226 |
|
---|
1227 | /**
|
---|
1228 | * Retrieves the current status of the host audio backend.
|
---|
1229 | *
|
---|
1230 | * @returns Status of the host audio backend.
|
---|
1231 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1232 | * @param enmDir Audio direction to check host audio backend for. Specify PDMAUDIODIR_ANY for the overall
|
---|
1233 | * backend status.
|
---|
1234 | */
|
---|
1235 | DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIAUDIOCONNECTOR pInterface, PDMAUDIODIR enmDir));
|
---|
1236 |
|
---|
1237 | /**
|
---|
1238 | * Creates an audio stream.
|
---|
1239 | *
|
---|
1240 | * @returns VBox status code.
|
---|
1241 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1242 | * @param pCfgHost Stream configuration for host side.
|
---|
1243 | * @param pCfgGuest Stream configuration for guest side.
|
---|
1244 | * @param ppStream Pointer where to return the created audio stream on success.
|
---|
1245 | */
|
---|
1246 | DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest, PPDMAUDIOSTREAM *ppStream));
|
---|
1247 |
|
---|
1248 | /**
|
---|
1249 | * Destroys an audio stream.
|
---|
1250 | *
|
---|
1251 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1252 | * @param pStream Pointer to audio stream.
|
---|
1253 | */
|
---|
1254 | DECLR3CALLBACKMEMBER(int, pfnStreamDestroy, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
|
---|
1255 |
|
---|
1256 | /**
|
---|
1257 | * Adds a reference to the specified audio stream.
|
---|
1258 | *
|
---|
1259 | * @returns New reference count. UINT32_MAX on error.
|
---|
1260 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1261 | * @param pStream Pointer to audio stream adding the reference to.
|
---|
1262 | */
|
---|
1263 | DECLR3CALLBACKMEMBER(uint32_t, pfnStreamRetain, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
|
---|
1264 |
|
---|
1265 | /**
|
---|
1266 | * Releases a reference from the specified stream.
|
---|
1267 | *
|
---|
1268 | * @returns New reference count. UINT32_MAX on error.
|
---|
1269 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1270 | * @param pStream Pointer to audio stream releasing a reference from.
|
---|
1271 | */
|
---|
1272 | DECLR3CALLBACKMEMBER(uint32_t, pfnStreamRelease, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
|
---|
1273 |
|
---|
1274 | /**
|
---|
1275 | * Reads PCM audio data from the host (input).
|
---|
1276 | *
|
---|
1277 | * @returns VBox status code.
|
---|
1278 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1279 | * @param pStream Pointer to audio stream to write to.
|
---|
1280 | * @param pvBuf Where to store the read data.
|
---|
1281 | * @param cbBuf Number of bytes to read.
|
---|
1282 | * @param pcbRead Bytes of audio data read. Optional.
|
---|
1283 | */
|
---|
1284 | DECLR3CALLBACKMEMBER(int, pfnStreamRead, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead));
|
---|
1285 |
|
---|
1286 | /**
|
---|
1287 | * Writes PCM audio data to the host (output).
|
---|
1288 | *
|
---|
1289 | * @returns VBox status code.
|
---|
1290 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1291 | * @param pStream Pointer to audio stream to read from.
|
---|
1292 | * @param pvBuf Audio data to be written.
|
---|
1293 | * @param cbBuf Number of bytes to be written.
|
---|
1294 | * @param pcbWritten Bytes of audio data written. Optional.
|
---|
1295 | */
|
---|
1296 | DECLR3CALLBACKMEMBER(int, pfnStreamWrite, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten));
|
---|
1297 |
|
---|
1298 | /**
|
---|
1299 | * Controls a specific audio stream.
|
---|
1300 | *
|
---|
1301 | * @returns VBox status code.
|
---|
1302 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1303 | * @param pStream Pointer to audio stream.
|
---|
1304 | * @param enmStreamCmd The stream command to issue.
|
---|
1305 | */
|
---|
1306 | DECLR3CALLBACKMEMBER(int, pfnStreamControl, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd));
|
---|
1307 |
|
---|
1308 | /**
|
---|
1309 | * Processes stream data.
|
---|
1310 | *
|
---|
1311 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1312 | * @param pStream Pointer to audio stream.
|
---|
1313 | */
|
---|
1314 | DECLR3CALLBACKMEMBER(int, pfnStreamIterate, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
|
---|
1315 |
|
---|
1316 | /**
|
---|
1317 | * Returns the number of readable data (in bytes) of a specific audio input stream.
|
---|
1318 | *
|
---|
1319 | * @returns Number of readable data (in bytes).
|
---|
1320 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1321 | * @param pStream Pointer to audio stream.
|
---|
1322 | */
|
---|
1323 | DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetReadable, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
|
---|
1324 |
|
---|
1325 | /**
|
---|
1326 | * Returns the number of writable data (in bytes) of a specific audio output stream.
|
---|
1327 | *
|
---|
1328 | * @returns Number of writable data (in bytes).
|
---|
1329 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1330 | * @param pStream Pointer to audio stream.
|
---|
1331 | */
|
---|
1332 | DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetWritable, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
|
---|
1333 |
|
---|
1334 | /**
|
---|
1335 | * Returns the status of a specific audio stream.
|
---|
1336 | *
|
---|
1337 | * @returns Audio stream status
|
---|
1338 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1339 | * @param pStream Pointer to audio stream.
|
---|
1340 | */
|
---|
1341 | DECLR3CALLBACKMEMBER(PDMAUDIOSTREAMSTS, pfnStreamGetStatus, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream));
|
---|
1342 |
|
---|
1343 | /**
|
---|
1344 | * Sets the audio volume of a specific audio stream.
|
---|
1345 | *
|
---|
1346 | * @returns VBox status code.
|
---|
1347 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1348 | * @param pStream Pointer to audio stream.
|
---|
1349 | * @param pVol Pointer to audio volume structure to set the stream's audio volume to.
|
---|
1350 | */
|
---|
1351 | DECLR3CALLBACKMEMBER(int, pfnStreamSetVolume, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, PPDMAUDIOVOLUME pVol));
|
---|
1352 |
|
---|
1353 | /**
|
---|
1354 | * Plays (transfers) available audio frames to the host backend. Only works with output streams.
|
---|
1355 | *
|
---|
1356 | * @returns VBox status code.
|
---|
1357 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1358 | * @param pStream Pointer to audio stream.
|
---|
1359 | * @param pcFramesPlayed Number of frames played. Optional.
|
---|
1360 | */
|
---|
1361 | DECLR3CALLBACKMEMBER(int, pfnStreamPlay, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcFramesPlayed));
|
---|
1362 |
|
---|
1363 | /**
|
---|
1364 | * Captures (transfers) available audio frames from the host backend. Only works with input streams.
|
---|
1365 | *
|
---|
1366 | * @returns VBox status code.
|
---|
1367 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1368 | * @param pStream Pointer to audio stream.
|
---|
1369 | * @param pcFramesCaptured Number of frames captured. Optional.
|
---|
1370 | */
|
---|
1371 | DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, uint32_t *pcFramesCaptured));
|
---|
1372 |
|
---|
1373 | /**
|
---|
1374 | * Registers (device) callbacks.
|
---|
1375 | * This is handy for letting the device emulation know of certain events, e.g. processing input / output data
|
---|
1376 | * or configuration changes.
|
---|
1377 | *
|
---|
1378 | * @returns VBox status code.
|
---|
1379 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1380 | * @param paCallbacks Pointer to array of callbacks to register.
|
---|
1381 | * @param cCallbacks Number of callbacks to register.
|
---|
1382 | */
|
---|
1383 | DECLR3CALLBACKMEMBER(int, pfnRegisterCallbacks, (PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOCBRECORD paCallbacks, size_t cCallbacks));
|
---|
1384 |
|
---|
1385 | } PDMIAUDIOCONNECTOR;
|
---|
1386 |
|
---|
1387 | /** PDMIAUDIOCONNECTOR interface ID. */
|
---|
1388 | #define PDMIAUDIOCONNECTOR_IID "A643B40C-733F-4307-9549-070AF0EE0ED6"
|
---|
1389 |
|
---|
1390 | /**
|
---|
1391 | * Assigns all needed interface callbacks for an audio backend.
|
---|
1392 | *
|
---|
1393 | * @param a_Prefix The function name prefix.
|
---|
1394 | */
|
---|
1395 | #define PDMAUDIO_IHOSTAUDIO_CALLBACKS(a_Prefix) \
|
---|
1396 | do { \
|
---|
1397 | pThis->IHostAudio.pfnInit = RT_CONCAT(a_Prefix,Init); \
|
---|
1398 | pThis->IHostAudio.pfnShutdown = RT_CONCAT(a_Prefix,Shutdown); \
|
---|
1399 | pThis->IHostAudio.pfnGetConfig = RT_CONCAT(a_Prefix,GetConfig); \
|
---|
1400 | /** @todo Add pfnGetDevices here as soon as supported by all backends. */ \
|
---|
1401 | pThis->IHostAudio.pfnGetStatus = RT_CONCAT(a_Prefix,GetStatus); \
|
---|
1402 | /** @todo Ditto for pfnSetCallback. */ \
|
---|
1403 | pThis->IHostAudio.pfnStreamCreate = RT_CONCAT(a_Prefix,StreamCreate); \
|
---|
1404 | pThis->IHostAudio.pfnStreamDestroy = RT_CONCAT(a_Prefix,StreamDestroy); \
|
---|
1405 | pThis->IHostAudio.pfnStreamControl = RT_CONCAT(a_Prefix,StreamControl); \
|
---|
1406 | pThis->IHostAudio.pfnStreamGetReadable = RT_CONCAT(a_Prefix,StreamGetReadable); \
|
---|
1407 | pThis->IHostAudio.pfnStreamGetWritable = RT_CONCAT(a_Prefix,StreamGetWritable); \
|
---|
1408 | pThis->IHostAudio.pfnStreamGetStatus = RT_CONCAT(a_Prefix,StreamGetStatus); \
|
---|
1409 | pThis->IHostAudio.pfnStreamIterate = RT_CONCAT(a_Prefix,StreamIterate); \
|
---|
1410 | pThis->IHostAudio.pfnStreamPlay = RT_CONCAT(a_Prefix,StreamPlay); \
|
---|
1411 | pThis->IHostAudio.pfnStreamCapture = RT_CONCAT(a_Prefix,StreamCapture); \
|
---|
1412 | } while (0)
|
---|
1413 |
|
---|
1414 | /**
|
---|
1415 | * PDM host audio interface.
|
---|
1416 | */
|
---|
1417 | typedef struct PDMIHOSTAUDIO
|
---|
1418 | {
|
---|
1419 | /**
|
---|
1420 | * Initializes the host backend (driver).
|
---|
1421 | *
|
---|
1422 | * @returns VBox status code.
|
---|
1423 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1424 | */
|
---|
1425 | DECLR3CALLBACKMEMBER(int, pfnInit, (PPDMIHOSTAUDIO pInterface));
|
---|
1426 |
|
---|
1427 | /**
|
---|
1428 | * Shuts down the host backend (driver).
|
---|
1429 | *
|
---|
1430 | * @returns VBox status code.
|
---|
1431 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1432 | */
|
---|
1433 | DECLR3CALLBACKMEMBER(void, pfnShutdown, (PPDMIHOSTAUDIO pInterface));
|
---|
1434 |
|
---|
1435 | /**
|
---|
1436 | * Returns the host backend's configuration (backend).
|
---|
1437 | *
|
---|
1438 | * @returns VBox status code.
|
---|
1439 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1440 | * @param pBackendCfg Where to store the backend audio configuration to.
|
---|
1441 | */
|
---|
1442 | DECLR3CALLBACKMEMBER(int, pfnGetConfig, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDCFG pBackendCfg));
|
---|
1443 |
|
---|
1444 | /**
|
---|
1445 | * Returns (enumerates) host audio device information.
|
---|
1446 | *
|
---|
1447 | * @returns VBox status code.
|
---|
1448 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1449 | * @param pDeviceEnum Where to return the enumerated audio devices.
|
---|
1450 | */
|
---|
1451 | DECLR3CALLBACKMEMBER(int, pfnGetDevices, (PPDMIHOSTAUDIO pInterface, PPDMAUDIODEVICEENUM pDeviceEnum));
|
---|
1452 |
|
---|
1453 | /**
|
---|
1454 | * Returns the current status from the audio backend.
|
---|
1455 | *
|
---|
1456 | * @returns PDMAUDIOBACKENDSTS enum.
|
---|
1457 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1458 | * @param enmDir Audio direction to get status for. Pass PDMAUDIODIR_ANY for overall status.
|
---|
1459 | */
|
---|
1460 | DECLR3CALLBACKMEMBER(PDMAUDIOBACKENDSTS, pfnGetStatus, (PPDMIHOSTAUDIO pInterface, PDMAUDIODIR enmDir));
|
---|
1461 |
|
---|
1462 | /**
|
---|
1463 | * Sets a callback the audio backend can call. Optional.
|
---|
1464 | *
|
---|
1465 | * @returns VBox status code.
|
---|
1466 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1467 | * @param pfnCallback The callback function to use, or NULL when unregistering.
|
---|
1468 | */
|
---|
1469 | DECLR3CALLBACKMEMBER(int, pfnSetCallback, (PPDMIHOSTAUDIO pInterface, PFNPDMHOSTAUDIOCALLBACK pfnCallback));
|
---|
1470 |
|
---|
1471 | /**
|
---|
1472 | * Creates an audio stream using the requested stream configuration.
|
---|
1473 | * If a backend is not able to create this configuration, it will return its best match in the acquired configuration
|
---|
1474 | * structure on success.
|
---|
1475 | *
|
---|
1476 | * @returns VBox status code.
|
---|
1477 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1478 | * @param pStream Pointer to audio stream.
|
---|
1479 | * @param pCfgReq Pointer to requested stream configuration.
|
---|
1480 | * @param pCfgAcq Pointer to acquired stream configuration.
|
---|
1481 | */
|
---|
1482 | DECLR3CALLBACKMEMBER(int, pfnStreamCreate, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgReq, PPDMAUDIOSTREAMCFG pCfgAcq));
|
---|
1483 |
|
---|
1484 | /**
|
---|
1485 | * Destroys an audio stream.
|
---|
1486 | *
|
---|
1487 | * @returns VBox status code.
|
---|
1488 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1489 | * @param pStream Pointer to audio stream.
|
---|
1490 | */
|
---|
1491 | DECLR3CALLBACKMEMBER(int, pfnStreamDestroy, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
|
---|
1492 |
|
---|
1493 | /**
|
---|
1494 | * Controls an audio stream.
|
---|
1495 | *
|
---|
1496 | * @returns VBox status code.
|
---|
1497 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1498 | * @param pStream Pointer to audio stream.
|
---|
1499 | * @param enmStreamCmd The stream command to issue.
|
---|
1500 | */
|
---|
1501 | DECLR3CALLBACKMEMBER(int, pfnStreamControl, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd));
|
---|
1502 |
|
---|
1503 | /**
|
---|
1504 | * Returns the amount which is readable from the audio (input) stream.
|
---|
1505 | *
|
---|
1506 | * @returns For non-raw layout streams: Number of readable bytes.
|
---|
1507 | * for raw layout streams : Number of readable audio frames.
|
---|
1508 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1509 | * @param pStream Pointer to audio stream.
|
---|
1510 | */
|
---|
1511 | DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetReadable, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
|
---|
1512 |
|
---|
1513 | /**
|
---|
1514 | * Returns the amount which is writable to the audio (output) stream.
|
---|
1515 | *
|
---|
1516 | * @returns For non-raw layout streams: Number of writable bytes.
|
---|
1517 | * for raw layout streams : Number of writable audio frames.
|
---|
1518 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1519 | * @param pStream Pointer to audio stream.
|
---|
1520 | */
|
---|
1521 | DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetWritable, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
|
---|
1522 |
|
---|
1523 | /**
|
---|
1524 | * Returns the amount which is pending (in other words has not yet been processed) by/from the backend yet.
|
---|
1525 | * Optional.
|
---|
1526 | *
|
---|
1527 | * For input streams this is read audio data by the backend which has not been processed by the host yet.
|
---|
1528 | * For output streams this is written audio data to the backend which has not been processed by the backend yet.
|
---|
1529 | *
|
---|
1530 | * @returns For non-raw layout streams: Number of pending bytes.
|
---|
1531 | * for raw layout streams : Number of pending audio frames.
|
---|
1532 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1533 | * @param pStream Pointer to audio stream.
|
---|
1534 | */
|
---|
1535 | DECLR3CALLBACKMEMBER(uint32_t, pfnStreamGetPending, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
|
---|
1536 |
|
---|
1537 | /**
|
---|
1538 | * Returns the current status of the given backend stream.
|
---|
1539 | *
|
---|
1540 | * @returns PDMAUDIOSTREAMSTS
|
---|
1541 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1542 | * @param pStream Pointer to audio stream.
|
---|
1543 | */
|
---|
1544 | DECLR3CALLBACKMEMBER(PDMAUDIOSTREAMSTS, pfnStreamGetStatus, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
|
---|
1545 |
|
---|
1546 | /**
|
---|
1547 | * Gives the host backend the chance to do some (necessary) iteration work.
|
---|
1548 | *
|
---|
1549 | * @returns VBox status code.
|
---|
1550 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1551 | * @param pStream Pointer to audio stream.
|
---|
1552 | */
|
---|
1553 | DECLR3CALLBACKMEMBER(int, pfnStreamIterate, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
|
---|
1554 |
|
---|
1555 | /**
|
---|
1556 | * Signals the backend that the host wants to begin playing for this iteration. Optional.
|
---|
1557 | *
|
---|
1558 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1559 | * @param pStream Pointer to audio stream.
|
---|
1560 | */
|
---|
1561 | DECLR3CALLBACKMEMBER(void, pfnStreamPlayBegin, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
|
---|
1562 |
|
---|
1563 | /**
|
---|
1564 | * Plays (writes to) an audio (output) stream.
|
---|
1565 | *
|
---|
1566 | * @returns VBox status code.
|
---|
1567 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1568 | * @param pStream Pointer to audio stream.
|
---|
1569 | * @param pvBuf Pointer to audio data buffer to play.
|
---|
1570 | * @param cxBuf For non-raw layout streams: Size (in bytes) of audio data buffer,
|
---|
1571 | * for raw layout streams : Size (in audio frames) of audio data buffer.
|
---|
1572 | * @param pcxWritten For non-raw layout streams: Returns number of bytes written. Optional.
|
---|
1573 | * for raw layout streams : Returns number of frames written. Optional.
|
---|
1574 | */
|
---|
1575 | DECLR3CALLBACKMEMBER(int, pfnStreamPlay, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, const void *pvBuf, uint32_t cxBuf, uint32_t *pcxWritten));
|
---|
1576 |
|
---|
1577 | /**
|
---|
1578 | * Signals the backend that the host finished playing for this iteration. Optional.
|
---|
1579 | *
|
---|
1580 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1581 | * @param pStream Pointer to audio stream.
|
---|
1582 | */
|
---|
1583 | DECLR3CALLBACKMEMBER(void, pfnStreamPlayEnd, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
|
---|
1584 |
|
---|
1585 | /**
|
---|
1586 | * Signals the backend that the host wants to begin capturing for this iteration. Optional.
|
---|
1587 | *
|
---|
1588 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1589 | * @param pStream Pointer to audio stream.
|
---|
1590 | */
|
---|
1591 | DECLR3CALLBACKMEMBER(void, pfnStreamCaptureBegin, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
|
---|
1592 |
|
---|
1593 | /**
|
---|
1594 | * Captures (reads from) an audio (input) stream.
|
---|
1595 | *
|
---|
1596 | * @returns VBox status code.
|
---|
1597 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1598 | * @param pStream Pointer to audio stream.
|
---|
1599 | * @param pvBuf Buffer where to store read audio data.
|
---|
1600 | * @param cxBuf For non-raw layout streams: Size (in bytes) of audio data buffer,
|
---|
1601 | * for raw layout streams : Size (in audio frames) of audio data buffer.
|
---|
1602 | * @param pcxRead For non-raw layout streams: Returns number of bytes read. Optional.
|
---|
1603 | * for raw layout streams : Returns number of frames read. Optional.
|
---|
1604 | */
|
---|
1605 | DECLR3CALLBACKMEMBER(int, pfnStreamCapture, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream, void *pvBuf, uint32_t cxBuf, uint32_t *pcxRead));
|
---|
1606 |
|
---|
1607 | /**
|
---|
1608 | * Signals the backend that the host finished capturing for this iteration. Optional.
|
---|
1609 | *
|
---|
1610 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
1611 | * @param pStream Pointer to audio stream.
|
---|
1612 | */
|
---|
1613 | DECLR3CALLBACKMEMBER(void, pfnStreamCaptureEnd, (PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream));
|
---|
1614 |
|
---|
1615 | } PDMIHOSTAUDIO;
|
---|
1616 |
|
---|
1617 | /** PDMIHOSTAUDIO interface ID. */
|
---|
1618 | #define PDMIHOSTAUDIO_IID "640F5A31-8245-491C-538F-29A0F9D08881"
|
---|
1619 |
|
---|
1620 | /** @} */
|
---|
1621 |
|
---|
1622 | #endif /* !___VBox_vmm_pdmaudioifs_h */
|
---|
1623 |
|
---|