1 | /* $Id: vkatInternal.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VKAT - Internal header file for common definitions + structs.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2021-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef VBOX_INCLUDED_SRC_audio_vkatInternal_h
|
---|
38 | #define VBOX_INCLUDED_SRC_audio_vkatInternal_h
|
---|
39 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
40 | # pragma once
|
---|
41 | #endif
|
---|
42 |
|
---|
43 |
|
---|
44 | /*********************************************************************************************************************************
|
---|
45 | * Header Files *
|
---|
46 | *********************************************************************************************************************************/
|
---|
47 | #include <iprt/getopt.h>
|
---|
48 |
|
---|
49 | #include <VBox/vmm/pdmdrv.h>
|
---|
50 | #include <VBox/vmm/pdmaudioinline.h>
|
---|
51 | #include <VBox/vmm/pdmaudiohostenuminline.h>
|
---|
52 |
|
---|
53 | #include "Audio/AudioMixBuffer.h"
|
---|
54 | #include "Audio/AudioTest.h"
|
---|
55 | #include "Audio/AudioTestService.h"
|
---|
56 | #include "Audio/AudioTestServiceClient.h"
|
---|
57 |
|
---|
58 | #include "VBoxDD.h"
|
---|
59 |
|
---|
60 |
|
---|
61 | /*********************************************************************************************************************************
|
---|
62 | * Common defines *
|
---|
63 | *********************************************************************************************************************************/
|
---|
64 | /** Default (failsafe) timeout (in ms). */
|
---|
65 | #define AUDIOTEST_TIMEOUT_DEFAULT_MS RT_MS_5MIN
|
---|
66 |
|
---|
67 |
|
---|
68 | /*********************************************************************************************************************************
|
---|
69 | * Structures and Typedefs *
|
---|
70 | *********************************************************************************************************************************/
|
---|
71 | /**
|
---|
72 | * Audio driver stack.
|
---|
73 | *
|
---|
74 | * This can be just be backend driver alone or DrvAudio with a backend.
|
---|
75 | * @todo add automatic resampling via mixer so we can test more of the audio
|
---|
76 | * stack used by the device emulations.
|
---|
77 | */
|
---|
78 | typedef struct AUDIOTESTDRVSTACK
|
---|
79 | {
|
---|
80 | /** The device registration record for the backend. */
|
---|
81 | PCPDMDRVREG pDrvReg;
|
---|
82 | /** The backend driver instance. */
|
---|
83 | PPDMDRVINS pDrvBackendIns;
|
---|
84 | /** The backend's audio interface. */
|
---|
85 | PPDMIHOSTAUDIO pIHostAudio;
|
---|
86 |
|
---|
87 | /** The DrvAudio instance. */
|
---|
88 | PPDMDRVINS pDrvAudioIns;
|
---|
89 | /** This is NULL if we don't use DrvAudio. */
|
---|
90 | PPDMIAUDIOCONNECTOR pIAudioConnector;
|
---|
91 |
|
---|
92 | /** The current (last) audio device enumeration to use. */
|
---|
93 | PDMAUDIOHOSTENUM DevEnum;
|
---|
94 | } AUDIOTESTDRVSTACK;
|
---|
95 | /** Pointer to an audio driver stack. */
|
---|
96 | typedef AUDIOTESTDRVSTACK *PAUDIOTESTDRVSTACK;
|
---|
97 |
|
---|
98 | /**
|
---|
99 | * Backend-only stream structure.
|
---|
100 | */
|
---|
101 | typedef struct AUDIOTESTDRVSTACKSTREAM
|
---|
102 | {
|
---|
103 | /** The public stream data. */
|
---|
104 | PDMAUDIOSTREAM Core;
|
---|
105 | /** The backend data (variable size). */
|
---|
106 | PDMAUDIOBACKENDSTREAM Backend;
|
---|
107 | } AUDIOTESTDRVSTACKSTREAM;
|
---|
108 | /** Pointer to a backend-only stream structure. */
|
---|
109 | typedef AUDIOTESTDRVSTACKSTREAM *PAUDIOTESTDRVSTACKSTREAM;
|
---|
110 |
|
---|
111 | /**
|
---|
112 | * Mixer setup for a stream.
|
---|
113 | */
|
---|
114 | typedef struct AUDIOTESTDRVMIXSTREAM
|
---|
115 | {
|
---|
116 | /** Pointer to the driver stack. */
|
---|
117 | PAUDIOTESTDRVSTACK pDrvStack;
|
---|
118 | /** Pointer to the stream. */
|
---|
119 | PPDMAUDIOSTREAM pStream;
|
---|
120 | /** Properties to use. */
|
---|
121 | PCPDMAUDIOPCMPROPS pProps;
|
---|
122 | /** Set if we're mixing or just passing thru to the driver stack. */
|
---|
123 | bool fDoMixing;
|
---|
124 | /** Mixer buffer. */
|
---|
125 | AUDIOMIXBUF MixBuf;
|
---|
126 | /** Write state. */
|
---|
127 | AUDIOMIXBUFWRITESTATE WriteState;
|
---|
128 | /** Peek state. */
|
---|
129 | AUDIOMIXBUFPEEKSTATE PeekState;
|
---|
130 | } AUDIOTESTDRVMIXSTREAM;
|
---|
131 | /** Pointer to mixer setup for a stream. */
|
---|
132 | typedef AUDIOTESTDRVMIXSTREAM *PAUDIOTESTDRVMIXSTREAM;
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Enumeration specifying the current audio test mode.
|
---|
136 | */
|
---|
137 | typedef enum AUDIOTESTMODE
|
---|
138 | {
|
---|
139 | /** Unknown mode. */
|
---|
140 | AUDIOTESTMODE_UNKNOWN = 0,
|
---|
141 | /** VKAT is running on the guest side. */
|
---|
142 | AUDIOTESTMODE_GUEST,
|
---|
143 | /** VKAT is running on the host side. */
|
---|
144 | AUDIOTESTMODE_HOST
|
---|
145 | } AUDIOTESTMODE;
|
---|
146 |
|
---|
147 | struct AUDIOTESTENV;
|
---|
148 | /** Pointer a audio test environment. */
|
---|
149 | typedef AUDIOTESTENV *PAUDIOTESTENV;
|
---|
150 |
|
---|
151 | struct AUDIOTESTDESC;
|
---|
152 | /** Pointer a audio test descriptor. */
|
---|
153 | typedef AUDIOTESTDESC *PAUDIOTESTDESC;
|
---|
154 |
|
---|
155 | /**
|
---|
156 | * Callback to set up the test parameters for a specific test.
|
---|
157 | *
|
---|
158 | * @returns IPRT status code.
|
---|
159 | * @retval VINF_SUCCESS if setting the parameters up succeeded. Any other error code
|
---|
160 | * otherwise indicating the kind of error.
|
---|
161 | * @param pszTest Test name.
|
---|
162 | * @param pTstParmsAcq The audio test parameters to set up.
|
---|
163 | */
|
---|
164 | typedef DECLCALLBACKTYPE(int, FNAUDIOTESTSETUP,(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc, PAUDIOTESTPARMS pTstParmsAcq, void **ppvCtx));
|
---|
165 | /** Pointer to an audio test setup callback. */
|
---|
166 | typedef FNAUDIOTESTSETUP *PFNAUDIOTESTSETUP;
|
---|
167 |
|
---|
168 | typedef DECLCALLBACKTYPE(int, FNAUDIOTESTEXEC,(PAUDIOTESTENV pTstEnv, void *pvCtx, PAUDIOTESTPARMS pTstParms));
|
---|
169 | /** Pointer to an audio test exec callback. */
|
---|
170 | typedef FNAUDIOTESTEXEC *PFNAUDIOTESTEXEC;
|
---|
171 |
|
---|
172 | typedef DECLCALLBACKTYPE(int, FNAUDIOTESTDESTROY,(PAUDIOTESTENV pTstEnv, void *pvCtx));
|
---|
173 | /** Pointer to an audio test destroy callback. */
|
---|
174 | typedef FNAUDIOTESTDESTROY *PFNAUDIOTESTDESTROY;
|
---|
175 |
|
---|
176 | /**
|
---|
177 | * Structure for keeping an audio test audio stream.
|
---|
178 | */
|
---|
179 | typedef struct AUDIOTESTSTREAM
|
---|
180 | {
|
---|
181 | /** The PDM stream. */
|
---|
182 | PPDMAUDIOSTREAM pStream;
|
---|
183 | /** The backend stream. */
|
---|
184 | PPDMAUDIOBACKENDSTREAM pBackend;
|
---|
185 | /** The stream config. */
|
---|
186 | PDMAUDIOSTREAMCFG Cfg;
|
---|
187 | /** Associated mixing stream. Optional. */
|
---|
188 | AUDIOTESTDRVMIXSTREAM Mix;
|
---|
189 | } AUDIOTESTSTREAM;
|
---|
190 | /** Pointer to audio test stream. */
|
---|
191 | typedef AUDIOTESTSTREAM *PAUDIOTESTSTREAM;
|
---|
192 |
|
---|
193 | /** Maximum audio streams a test environment can handle. */
|
---|
194 | #define AUDIOTESTENV_MAX_STREAMS 8
|
---|
195 |
|
---|
196 | /**
|
---|
197 | * Structure for keeping TCP/IP-specific options.
|
---|
198 | */
|
---|
199 | typedef struct AUDIOTESTENVTCPOPTS
|
---|
200 | {
|
---|
201 | /** Connection mode(s) to use. */
|
---|
202 | ATSCONNMODE enmConnMode;
|
---|
203 | /** Bind address (server mode). When empty, "0.0.0.0" (any host) will be used. */
|
---|
204 | char szBindAddr[128];
|
---|
205 | /** Bind port (server mode). */
|
---|
206 | uint16_t uBindPort;
|
---|
207 | /** Connection address (client mode). */
|
---|
208 | char szConnectAddr[128];
|
---|
209 | /** Connection port (client mode). */
|
---|
210 | uint16_t uConnectPort;
|
---|
211 | } AUDIOTESTENVTCPOPTS;
|
---|
212 | /** Pointer to audio test TCP options. */
|
---|
213 | typedef AUDIOTESTENVTCPOPTS *PAUDIOTESTENVTCPOPTS;
|
---|
214 |
|
---|
215 | /**
|
---|
216 | * Structure holding additional I/O options.
|
---|
217 | */
|
---|
218 | typedef struct AUDIOTESTIOOPTS
|
---|
219 | {
|
---|
220 | /** Whether to use the audio connector or not. */
|
---|
221 | bool fWithDrvAudio;
|
---|
222 | /** Whether to use a mixing buffer or not. */
|
---|
223 | bool fWithMixer;
|
---|
224 | /** Buffer size (in ms). */
|
---|
225 | uint32_t cMsBufferSize;
|
---|
226 | /** Pre-buffering size (in ms). */
|
---|
227 | uint32_t cMsPreBuffer;
|
---|
228 | /** Scheduling (in ms). */
|
---|
229 | uint32_t cMsSchedulingHint;
|
---|
230 | /** Audio vlume to use (in percent). */
|
---|
231 | uint8_t uVolumePercent;
|
---|
232 | /** PCM audio properties to use. */
|
---|
233 | PDMAUDIOPCMPROPS Props;
|
---|
234 | } AUDIOTESTIOOPTS;
|
---|
235 | /** Pointer to additional playback options. */
|
---|
236 | typedef AUDIOTESTIOOPTS *PAUDIOTESTIOOPTS;
|
---|
237 |
|
---|
238 | /**
|
---|
239 | * Structure for keeping a user context for the test service callbacks.
|
---|
240 | */
|
---|
241 | typedef struct ATSCALLBACKCTX
|
---|
242 | {
|
---|
243 | /** The test environment bound to this context. */
|
---|
244 | PAUDIOTESTENV pTstEnv;
|
---|
245 | /** Absolute path to the packed up test set archive.
|
---|
246 | * Keep it simple for now and only support one (open) archive at a time. */
|
---|
247 | char szTestSetArchive[RTPATH_MAX];
|
---|
248 | /** File handle to the (opened) test set archive for reading. */
|
---|
249 | RTFILE hTestSetArchive;
|
---|
250 | /** Number of currently connected clients. */
|
---|
251 | uint8_t cClients;
|
---|
252 | } ATSCALLBACKCTX;
|
---|
253 | typedef ATSCALLBACKCTX *PATSCALLBACKCTX;
|
---|
254 |
|
---|
255 | /**
|
---|
256 | * Audio test environment parameters.
|
---|
257 | *
|
---|
258 | * This is global to all tests defined.
|
---|
259 | */
|
---|
260 | typedef struct AUDIOTESTENV
|
---|
261 | {
|
---|
262 | /** Audio testing mode. */
|
---|
263 | AUDIOTESTMODE enmMode;
|
---|
264 | /** Failsafe timeout (in ms). Defaults to AUDIOTEST_TIMEOUT_DEFAULT_MS. */
|
---|
265 | RTMSINTERVAL msTimeout;
|
---|
266 | /** Whether self test mode is active or not. */
|
---|
267 | bool fSelftest;
|
---|
268 | /** Whether skip the actual verification or not. */
|
---|
269 | bool fSkipVerify;
|
---|
270 | /** Name of the audio device to use.
|
---|
271 | * If empty the default audio device will be used. */
|
---|
272 | char szDev[128];
|
---|
273 | /** Zero-based index of current test (will be increased for every run test). */
|
---|
274 | uint32_t idxTest;
|
---|
275 | /** Number of iterations for *all* tests specified.
|
---|
276 | * When set to 0 (default), a random value (see specific test) will be chosen. */
|
---|
277 | uint32_t cIterations;
|
---|
278 | /** I/O options to use. */
|
---|
279 | AUDIOTESTIOOPTS IoOpts;
|
---|
280 | /** Test tone parameters to use. */
|
---|
281 | AUDIOTESTTONEPARMS ToneParms;
|
---|
282 | /** Output path for storing the test environment's final test files. */
|
---|
283 | char szTag[AUDIOTEST_TAG_MAX];
|
---|
284 | /** Output path for storing the test environment's final test files. */
|
---|
285 | char szPathOut[RTPATH_MAX];
|
---|
286 | /** Temporary path for this test environment. */
|
---|
287 | char szPathTemp[RTPATH_MAX];
|
---|
288 | /** Pointer to audio test driver stack to use. */
|
---|
289 | PAUDIOTESTDRVSTACK pDrvStack;
|
---|
290 | /** Audio stream. */
|
---|
291 | AUDIOTESTSTREAM aStreams[AUDIOTESTENV_MAX_STREAMS];
|
---|
292 | /** The audio test set to use. */
|
---|
293 | AUDIOTESTSET Set;
|
---|
294 | /** TCP options to use for ATS. */
|
---|
295 | AUDIOTESTENVTCPOPTS TcpOpts;
|
---|
296 | /** ATS server instance to use.
|
---|
297 | * NULL if not in use. */
|
---|
298 | PATSSERVER pSrv;
|
---|
299 | /** ATS callback context to use. */
|
---|
300 | ATSCALLBACKCTX CallbackCtx;
|
---|
301 | union
|
---|
302 | {
|
---|
303 | struct
|
---|
304 | {
|
---|
305 | /** Client connected to the ATS on the guest side. */
|
---|
306 | ATSCLIENT AtsClGuest;
|
---|
307 | /** Path to the guest's test set downloaded to the host. */
|
---|
308 | char szPathTestSetGuest[RTPATH_MAX];
|
---|
309 | /** Client connected to the Validation Kit audio driver ATS. */
|
---|
310 | ATSCLIENT AtsClValKit;
|
---|
311 | /** Path to the Validation Kit audio driver's test set downloaded to the host. */
|
---|
312 | char szPathTestSetValKit[RTPATH_MAX];
|
---|
313 | } Host;
|
---|
314 | } u;
|
---|
315 | } AUDIOTESTENV;
|
---|
316 |
|
---|
317 | /**
|
---|
318 | * Audio test descriptor.
|
---|
319 | */
|
---|
320 | typedef struct AUDIOTESTDESC
|
---|
321 | {
|
---|
322 | /** (Sort of) Descriptive test name. */
|
---|
323 | const char *pszName;
|
---|
324 | /** Flag whether the test is excluded. */
|
---|
325 | bool fExcluded;
|
---|
326 | /** The setup callback. */
|
---|
327 | PFNAUDIOTESTSETUP pfnSetup;
|
---|
328 | /** The exec callback. */
|
---|
329 | PFNAUDIOTESTEXEC pfnExec;
|
---|
330 | /** The destruction callback. */
|
---|
331 | PFNAUDIOTESTDESTROY pfnDestroy;
|
---|
332 | } AUDIOTESTDESC;
|
---|
333 |
|
---|
334 | /**
|
---|
335 | * Backend description.
|
---|
336 | */
|
---|
337 | typedef struct AUDIOTESTBACKENDDESC
|
---|
338 | {
|
---|
339 | /** The driver registration structure. */
|
---|
340 | PCPDMDRVREG pDrvReg;
|
---|
341 | /** The backend name.
|
---|
342 | * Aliases are implemented by having multiple entries for the same backend. */
|
---|
343 | const char *pszName;
|
---|
344 | } AUDIOTESTBACKENDDESC;
|
---|
345 |
|
---|
346 | /**
|
---|
347 | * VKAT command table entry.
|
---|
348 | */
|
---|
349 | typedef struct VKATCMD
|
---|
350 | {
|
---|
351 | /** The command name. */
|
---|
352 | const char *pszCommand;
|
---|
353 | /** The command handler. */
|
---|
354 | DECLCALLBACKMEMBER(RTEXITCODE, pfnHandler,(PRTGETOPTSTATE pGetState));
|
---|
355 |
|
---|
356 | /** Command description. */
|
---|
357 | const char *pszDesc;
|
---|
358 | /** Options array. */
|
---|
359 | PCRTGETOPTDEF paOptions;
|
---|
360 | /** Number of options in the option array. */
|
---|
361 | size_t cOptions;
|
---|
362 | /** Gets help for an option. */
|
---|
363 | DECLCALLBACKMEMBER(const char *, pfnOptionHelp,(PCRTGETOPTDEF pOpt));
|
---|
364 | /** Flag indicating if the command needs the ATS transport layer.
|
---|
365 | * Needed for command line parsing. */
|
---|
366 | bool fNeedsTransport;
|
---|
367 | } VKATCMD;
|
---|
368 | /** Pointer to a const VKAT command entry. */
|
---|
369 | typedef VKATCMD const *PCVKATCMD;
|
---|
370 |
|
---|
371 |
|
---|
372 | /*********************************************************************************************************************************
|
---|
373 | * Global Variables *
|
---|
374 | *********************************************************************************************************************************/
|
---|
375 | /** Terminate ASAP if set. Set on Ctrl-C. */
|
---|
376 | extern bool volatile g_fTerminate;
|
---|
377 | /** The release logger. */
|
---|
378 | extern PRTLOGGER g_pRelLogger;
|
---|
379 |
|
---|
380 | /** The test handle. */
|
---|
381 | extern RTTEST g_hTest;
|
---|
382 | /** The current verbosity level. */
|
---|
383 | extern unsigned g_uVerbosity;
|
---|
384 | /** DrvAudio: Enable debug (or not). */
|
---|
385 | extern bool g_fDrvAudioDebug;
|
---|
386 | /** DrvAudio: The debug output path. */
|
---|
387 | extern const char *g_pszDrvAudioDebug;
|
---|
388 |
|
---|
389 | extern const VKATCMD g_CmdTest;
|
---|
390 | extern const VKATCMD g_CmdVerify;
|
---|
391 | extern const VKATCMD g_CmdBackends;
|
---|
392 | extern const VKATCMD g_CmdEnum;
|
---|
393 | extern const VKATCMD g_CmdPlay;
|
---|
394 | extern const VKATCMD g_CmdRec;
|
---|
395 | extern const VKATCMD g_CmdSelfTest;
|
---|
396 |
|
---|
397 |
|
---|
398 | extern AUDIOTESTDESC g_aTests[];
|
---|
399 | extern unsigned g_cTests;
|
---|
400 |
|
---|
401 | extern AUDIOTESTBACKENDDESC const g_aBackends[];
|
---|
402 | extern unsigned g_cBackends;
|
---|
403 |
|
---|
404 |
|
---|
405 | /*********************************************************************************************************************************
|
---|
406 | * Prototypes *
|
---|
407 | *********************************************************************************************************************************/
|
---|
408 |
|
---|
409 | /** @name Command line handlers
|
---|
410 | * @{ */
|
---|
411 | RTEXITCODE audioTestUsage(PRTSTREAM pStrm, PCVKATCMD pOnlyCmd);
|
---|
412 | RTEXITCODE audioTestVersion(void);
|
---|
413 | void audioTestShowLogo(PRTSTREAM pStream);
|
---|
414 | /** @} */
|
---|
415 |
|
---|
416 | /** @name Driver stack
|
---|
417 | * @{ */
|
---|
418 | int AudioTestDriverStackPerformSelftest(void);
|
---|
419 |
|
---|
420 | void audioTestDriverStackDelete(PAUDIOTESTDRVSTACK pDrvStack);
|
---|
421 | int audioTestDriverStackInitEx(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fEnabledIn, bool fEnabledOut, bool fWithDrvAudio);
|
---|
422 | int audioTestDriverStackInit(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, bool fWithDrvAudio);
|
---|
423 | int audioTestDriverStackProbe(PAUDIOTESTDRVSTACK pDrvStack, bool fEnabledIn, bool fEnabledOut, bool fWithDrvAudio);
|
---|
424 | int audioTestDriverStackSetDevice(PAUDIOTESTDRVSTACK pDrvStack, PDMAUDIODIR enmDir, const char *pszDevId);
|
---|
425 | /** @} */
|
---|
426 |
|
---|
427 | /** @name Driver
|
---|
428 | * @{ */
|
---|
429 | int audioTestDrvConstruct(PAUDIOTESTDRVSTACK pDrvStack, PCPDMDRVREG pDrvReg, PPDMDRVINS pParentDrvIns, PPPDMDRVINS ppDrvIns);
|
---|
430 | /** @} */
|
---|
431 |
|
---|
432 | /** @name Driver stack stream
|
---|
433 | * @{ */
|
---|
434 | int audioTestDriverStackStreamCreateInput(PAUDIOTESTDRVSTACK pDrvStack, PCPDMAUDIOPCMPROPS pProps,
|
---|
435 | uint32_t cMsBufferSize, uint32_t cMsPreBuffer, uint32_t cMsSchedulingHint,
|
---|
436 | PPDMAUDIOSTREAM *ppStream, PPDMAUDIOSTREAMCFG pCfgAcq);
|
---|
437 | int audioTestDriverStackStreamCreateOutput(PAUDIOTESTDRVSTACK pDrvStack, PCPDMAUDIOPCMPROPS pProps,
|
---|
438 | uint32_t cMsBufferSize, uint32_t cMsPreBuffer, uint32_t cMsSchedulingHint,
|
---|
439 | PPDMAUDIOSTREAM *ppStream, PPDMAUDIOSTREAMCFG pCfgAcq);
|
---|
440 | void audioTestDriverStackStreamDestroy(PAUDIOTESTDRVSTACK pDrvStack, PPDMAUDIOSTREAM pStream);
|
---|
441 | int audioTestDriverStackStreamDrain(PAUDIOTESTDRVSTACK pDrvStack, PPDMAUDIOSTREAM pStream, bool fSync);
|
---|
442 | int audioTestDriverStackStreamEnable(PAUDIOTESTDRVSTACK pDrvStack, PPDMAUDIOSTREAM pStream);
|
---|
443 | int AudioTestDriverStackStreamDisable(PAUDIOTESTDRVSTACK pDrvStack, PPDMAUDIOSTREAM pStream);
|
---|
444 | bool audioTestDriverStackStreamIsOkay(PAUDIOTESTDRVSTACK pDrvStack, PPDMAUDIOSTREAM pStream);
|
---|
445 | uint32_t audioTestDriverStackStreamGetWritable(PAUDIOTESTDRVSTACK pDrvStack, PPDMAUDIOSTREAM pStream);
|
---|
446 | int audioTestDriverStackStreamPlay(PAUDIOTESTDRVSTACK pDrvStack, PPDMAUDIOSTREAM pStream, void const *pvBuf,
|
---|
447 | uint32_t cbBuf, uint32_t *pcbPlayed);
|
---|
448 | uint32_t audioTestDriverStackStreamGetReadable(PAUDIOTESTDRVSTACK pDrvStack, PPDMAUDIOSTREAM pStream);
|
---|
449 | int audioTestDriverStackStreamCapture(PAUDIOTESTDRVSTACK pDrvStack, PPDMAUDIOSTREAM pStream,
|
---|
450 | void *pvBuf, uint32_t cbBuf, uint32_t *pcbCaptured);
|
---|
451 | /** @} */
|
---|
452 |
|
---|
453 | /** @name Backend handling
|
---|
454 | * @{ */
|
---|
455 | PCPDMDRVREG AudioTestGetDefaultBackend(void);
|
---|
456 | PCPDMDRVREG AudioTestFindBackendOpt(const char *pszBackend);
|
---|
457 | /** @} */
|
---|
458 |
|
---|
459 | /** @name Mixing stream
|
---|
460 | * @{ */
|
---|
461 | int AudioTestMixStreamInit(PAUDIOTESTDRVMIXSTREAM pMix, PAUDIOTESTDRVSTACK pDrvStack, PPDMAUDIOSTREAM pStream,
|
---|
462 | PCPDMAUDIOPCMPROPS pProps, uint32_t cMsBuffer);
|
---|
463 | void AudioTestMixStreamTerm(PAUDIOTESTDRVMIXSTREAM pMix);
|
---|
464 | int AudioTestMixStreamEnable(PAUDIOTESTDRVMIXSTREAM pMix);
|
---|
465 | int AudioTestMixStreamDrain(PAUDIOTESTDRVMIXSTREAM pMix, bool fSync);
|
---|
466 | int AudioTestMixStreamDisable(PAUDIOTESTDRVMIXSTREAM pMix);
|
---|
467 | bool AudioTestMixStreamIsOkay(PAUDIOTESTDRVMIXSTREAM pMix);
|
---|
468 | uint32_t AudioTestMixStreamGetWritable(PAUDIOTESTDRVMIXSTREAM pMix);
|
---|
469 | int AudioTestMixStreamPlay(PAUDIOTESTDRVMIXSTREAM pMix, void const *pvBuf, uint32_t cbBuf, uint32_t *pcbPlayed);
|
---|
470 | uint32_t AudioTestMixStreamGetReadable(PAUDIOTESTDRVMIXSTREAM pMix);
|
---|
471 | int AudioTestMixStreamCapture(PAUDIOTESTDRVMIXSTREAM pMix, void *pvBuf, uint32_t cbBuf, uint32_t *pcbCaptured);
|
---|
472 | void AudioTestMixStreamSetVolume(PAUDIOTESTDRVMIXSTREAM pMix, uint8_t uVolumePercent);
|
---|
473 | /** @} */
|
---|
474 |
|
---|
475 | /** @name Device handling
|
---|
476 | * @{ */
|
---|
477 | int audioTestDeviceOpen(PPDMAUDIOHOSTDEV pDev);
|
---|
478 | int audioTestDeviceClose(PPDMAUDIOHOSTDEV pDev);
|
---|
479 |
|
---|
480 | int audioTestDevicesEnumerateAndCheck(PAUDIOTESTDRVSTACK pDrvStack, const char *pszDev, PPDMAUDIOHOSTDEV *ppDev);
|
---|
481 | /** @} */
|
---|
482 |
|
---|
483 | /** @name ATS routines
|
---|
484 | * @{ */
|
---|
485 | int audioTestEnvConnectToValKitAts(PAUDIOTESTENV pTstEnv,
|
---|
486 | const char *pszHostTcpAddr, uint32_t uHostTcpPort);
|
---|
487 | /** @} */
|
---|
488 |
|
---|
489 | /** @name Test environment handling
|
---|
490 | * @{ */
|
---|
491 | void audioTestEnvInit(PAUDIOTESTENV pTstEnv);
|
---|
492 | int audioTestEnvCreate(PAUDIOTESTENV pTstEnv, PAUDIOTESTDRVSTACK pDrvStack);
|
---|
493 | void audioTestEnvDestroy(PAUDIOTESTENV pTstEnv);
|
---|
494 | int audioTestEnvPrologue(PAUDIOTESTENV pTstEnv, bool fPack, char *pszPackFile, size_t cbPackFile);
|
---|
495 |
|
---|
496 | void audioTestParmsInit(PAUDIOTESTPARMS pTstParms);
|
---|
497 | void audioTestParmsDestroy(PAUDIOTESTPARMS pTstParms);
|
---|
498 | /** @} */
|
---|
499 |
|
---|
500 | int audioTestWorker(PAUDIOTESTENV pTstEnv);
|
---|
501 |
|
---|
502 | /** @todo Test tone handling */
|
---|
503 | int audioTestPlayTone(PAUDIOTESTIOOPTS pIoOpts, PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream, PAUDIOTESTTONEPARMS pParms);
|
---|
504 | void audioTestToneParmsInit(PAUDIOTESTTONEPARMS pToneParms);
|
---|
505 | /** @} */
|
---|
506 |
|
---|
507 | void audioTestIoOptsInitDefaults(PAUDIOTESTIOOPTS pIoOpts);
|
---|
508 |
|
---|
509 |
|
---|
510 | /*********************************************************************************************************************************
|
---|
511 | * Common command line stuff *
|
---|
512 | *********************************************************************************************************************************/
|
---|
513 |
|
---|
514 | /**
|
---|
515 | * Common long options values.
|
---|
516 | */
|
---|
517 | enum
|
---|
518 | {
|
---|
519 | AUDIO_TEST_OPT_CMN_DAEMONIZE = 256,
|
---|
520 | AUDIO_TEST_OPT_CMN_DAEMONIZED,
|
---|
521 | AUDIO_TEST_OPT_CMN_DEBUG_AUDIO_ENABLE,
|
---|
522 | AUDIO_TEST_OPT_CMN_DEBUG_AUDIO_PATH
|
---|
523 | };
|
---|
524 |
|
---|
525 | /** For use in the option switch to handle common options. */
|
---|
526 | #define AUDIO_TEST_COMMON_OPTION_CASES(a_ValueUnion, a_pCmd) \
|
---|
527 | case 'q': \
|
---|
528 | g_uVerbosity = 0; \
|
---|
529 | if (g_pRelLogger) \
|
---|
530 | RTLogGroupSettings(g_pRelLogger, "all=0 all.e"); \
|
---|
531 | break; \
|
---|
532 | \
|
---|
533 | case 'v': \
|
---|
534 | /* No-op here, has been handled by main() already. */ /** @todo r-bird: -q works, so -v must too! */ \
|
---|
535 | break; \
|
---|
536 | \
|
---|
537 | case 'V': \
|
---|
538 | return audioTestVersion(); \
|
---|
539 | \
|
---|
540 | case 'h': \
|
---|
541 | return audioTestUsage(g_pStdOut, a_pCmd); \
|
---|
542 | \
|
---|
543 | case AUDIO_TEST_OPT_CMN_DEBUG_AUDIO_ENABLE: \
|
---|
544 | g_fDrvAudioDebug = true; \
|
---|
545 | break; \
|
---|
546 | \
|
---|
547 | case AUDIO_TEST_OPT_CMN_DEBUG_AUDIO_PATH: \
|
---|
548 | g_pszDrvAudioDebug = (a_ValueUnion).psz; \
|
---|
549 | break; \
|
---|
550 | case AUDIO_TEST_OPT_CMN_DAEMONIZE: \
|
---|
551 | break; \
|
---|
552 | case AUDIO_TEST_OPT_CMN_DAEMONIZED: \
|
---|
553 | break;
|
---|
554 |
|
---|
555 | #endif /* !VBOX_INCLUDED_SRC_audio_vkatInternal_h */
|
---|
556 |
|
---|