1 | /* $Id: vkatCommon.cpp 92195 2021-11-03 17:27:10Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Validation Kit Audio Test (VKAT) - Self test code.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2021 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*********************************************************************************************************************************
|
---|
29 | * Header Files *
|
---|
30 | *********************************************************************************************************************************/
|
---|
31 | #define LOG_GROUP LOG_GROUP_AUDIO_TEST
|
---|
32 | #include <iprt/log.h>
|
---|
33 |
|
---|
34 | #ifdef VBOX_WITH_AUDIO_ALSA
|
---|
35 | # include "DrvHostAudioAlsaStubsMangling.h"
|
---|
36 | # include <alsa/asoundlib.h>
|
---|
37 | # include <alsa/control.h> /* For device enumeration. */
|
---|
38 | # include <alsa/version.h>
|
---|
39 | # include "DrvHostAudioAlsaStubs.h"
|
---|
40 | #endif
|
---|
41 | #ifdef VBOX_WITH_AUDIO_OSS
|
---|
42 | # include <errno.h>
|
---|
43 | # include <fcntl.h>
|
---|
44 | # include <sys/ioctl.h>
|
---|
45 | # include <sys/mman.h>
|
---|
46 | # include <sys/soundcard.h>
|
---|
47 | # include <unistd.h>
|
---|
48 | #endif
|
---|
49 | #ifdef RT_OS_WINDOWS
|
---|
50 | # include <iprt/win/windows.h>
|
---|
51 | # include <iprt/win/audioclient.h>
|
---|
52 | # include <endpointvolume.h> /* For IAudioEndpointVolume. */
|
---|
53 | # include <audiopolicy.h> /* For IAudioSessionManager. */
|
---|
54 | # include <AudioSessionTypes.h>
|
---|
55 | # include <Mmdeviceapi.h>
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #include <iprt/ctype.h>
|
---|
59 | #include <iprt/dir.h>
|
---|
60 | #include <iprt/errcore.h>
|
---|
61 | #include <iprt/getopt.h>
|
---|
62 | #include <iprt/message.h>
|
---|
63 | #include <iprt/rand.h>
|
---|
64 | #include <iprt/test.h>
|
---|
65 |
|
---|
66 | #include "Audio/AudioHlp.h"
|
---|
67 | #include "Audio/AudioTest.h"
|
---|
68 | #include "Audio/AudioTestService.h"
|
---|
69 | #include "Audio/AudioTestServiceClient.h"
|
---|
70 |
|
---|
71 | #include "vkatInternal.h"
|
---|
72 |
|
---|
73 |
|
---|
74 | /*********************************************************************************************************************************
|
---|
75 | * Defined Constants And Macros *
|
---|
76 | *********************************************************************************************************************************/
|
---|
77 |
|
---|
78 |
|
---|
79 | /*********************************************************************************************************************************
|
---|
80 | * Internal Functions *
|
---|
81 | *********************************************************************************************************************************/
|
---|
82 | static int audioTestStreamInit(PAUDIOTESTDRVSTACK pDrvStack, PAUDIOTESTSTREAM pStream, PDMAUDIODIR enmDir, PAUDIOTESTIOOPTS pPlayOpt);
|
---|
83 | static int audioTestStreamDestroy(PAUDIOTESTDRVSTACK pDrvStack, PAUDIOTESTSTREAM pStream);
|
---|
84 |
|
---|
85 |
|
---|
86 | /*********************************************************************************************************************************
|
---|
87 | * Volume handling. *
|
---|
88 | *********************************************************************************************************************************/
|
---|
89 |
|
---|
90 | #ifdef VBOX_WITH_AUDIO_ALSA
|
---|
91 | /**
|
---|
92 | * Sets the system's master volume via ALSA, if available.
|
---|
93 | *
|
---|
94 | * @returns VBox status code.
|
---|
95 | * @param uVolPercent Volume (in percent) to set.
|
---|
96 | */
|
---|
97 | static int audioTestSetMasterVolumeALSA(unsigned uVolPercent)
|
---|
98 | {
|
---|
99 | int rc = audioLoadAlsaLib();
|
---|
100 | if (RT_FAILURE(rc))
|
---|
101 | return rc;
|
---|
102 |
|
---|
103 | int err;
|
---|
104 | snd_mixer_t *handle;
|
---|
105 |
|
---|
106 | # define ALSA_CHECK_RET(a_Exp, a_Text) \
|
---|
107 | if (!(a_Exp)) \
|
---|
108 | { \
|
---|
109 | AssertLogRelMsg(a_Exp, a_Text); \
|
---|
110 | if (handle) \
|
---|
111 | snd_mixer_close(handle); \
|
---|
112 | return VERR_GENERAL_FAILURE; \
|
---|
113 | }
|
---|
114 |
|
---|
115 | # define ALSA_CHECK_ERR_RET(a_Text) \
|
---|
116 | ALSA_CHECK_RET(err >= 0, a_Text)
|
---|
117 |
|
---|
118 | err = snd_mixer_open(&handle, 0 /* Index */);
|
---|
119 | ALSA_CHECK_ERR_RET(("ALSA: Failed to open mixer: %s\n", snd_strerror(err)));
|
---|
120 | err = snd_mixer_attach(handle, "default");
|
---|
121 | ALSA_CHECK_ERR_RET(("ALSA: Failed to attach to default sink: %s\n", snd_strerror(err)));
|
---|
122 | err = snd_mixer_selem_register(handle, NULL, NULL);
|
---|
123 | ALSA_CHECK_ERR_RET(("ALSA: Failed to attach to default sink: %s\n", snd_strerror(err)));
|
---|
124 | err = snd_mixer_load(handle);
|
---|
125 | ALSA_CHECK_ERR_RET(("ALSA: Failed to load mixer: %s\n", snd_strerror(err)));
|
---|
126 |
|
---|
127 | snd_mixer_selem_id_t *sid = NULL;
|
---|
128 | snd_mixer_selem_id_alloca(&sid);
|
---|
129 |
|
---|
130 | snd_mixer_selem_id_set_index(sid, 0 /* Index */);
|
---|
131 | snd_mixer_selem_id_set_name(sid, "Master");
|
---|
132 |
|
---|
133 | snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid);
|
---|
134 | ALSA_CHECK_RET(elem != NULL, ("ALSA: Failed to find mixer element: %s\n", snd_strerror(err)));
|
---|
135 |
|
---|
136 | long uVolMin, uVolMax;
|
---|
137 | snd_mixer_selem_get_playback_volume_range(elem, &uVolMin, &uVolMax);
|
---|
138 | ALSA_CHECK_ERR_RET(("ALSA: Failed to get playback volume range: %s\n", snd_strerror(err)));
|
---|
139 |
|
---|
140 | long const uVol = RT_MIN(uVolPercent, 100) * uVolMax / 100;
|
---|
141 |
|
---|
142 | err = snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, uVol);
|
---|
143 | ALSA_CHECK_ERR_RET(("ALSA: Failed to set playback volume left: %s\n", snd_strerror(err)));
|
---|
144 | err = snd_mixer_selem_set_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, uVol);
|
---|
145 | ALSA_CHECK_ERR_RET(("ALSA: Failed to set playback volume right: %s\n", snd_strerror(err)));
|
---|
146 |
|
---|
147 | snd_mixer_close(handle);
|
---|
148 |
|
---|
149 | return VINF_SUCCESS;
|
---|
150 |
|
---|
151 | # undef ALSA_CHECK_RET
|
---|
152 | # undef ALSA_CHECK_ERR_RET
|
---|
153 | }
|
---|
154 | #endif /* VBOX_WITH_AUDIO_ALSA */
|
---|
155 |
|
---|
156 | #ifdef VBOX_WITH_AUDIO_OSS
|
---|
157 | /**
|
---|
158 | * Sets the system's master volume via OSS, if available.
|
---|
159 | *
|
---|
160 | * @returns VBox status code.
|
---|
161 | * @param uVolPercent Volume (in percent) to set.
|
---|
162 | */
|
---|
163 | static int audioTestSetMasterVolumeOSS(unsigned uVolPercent)
|
---|
164 | {
|
---|
165 | int hFile = open("/dev/dsp", O_WRONLY | O_NONBLOCK, 0);
|
---|
166 | if (hFile == -1)
|
---|
167 | {
|
---|
168 | /* Try opening the mixing device instead. */
|
---|
169 | hFile = open("/dev/mixer", O_RDONLY | O_NONBLOCK, 0);
|
---|
170 | }
|
---|
171 |
|
---|
172 | if (hFile != -1)
|
---|
173 | {
|
---|
174 | /* OSS maps 0 (muted) - 100 (max), so just use uVolPercent unmodified here. */
|
---|
175 | uint16_t uVol = RT_MAKE_U16(uVolPercent, uVolPercent);
|
---|
176 | AssertLogRelMsgReturnStmt(ioctl(hFile, SOUND_MIXER_PCM /* SNDCTL_DSP_SETPLAYVOL */, &uVol) >= 0,
|
---|
177 | ("OSS: Failed to set DSP playback volume: %s (%d)\n",
|
---|
178 | strerror(errno), errno), close(hFile), RTErrConvertFromErrno(errno));
|
---|
179 | return VINF_SUCCESS;
|
---|
180 | }
|
---|
181 |
|
---|
182 | return VERR_NOT_SUPPORTED;
|
---|
183 | }
|
---|
184 | #endif /* VBOX_WITH_AUDIO_OSS */
|
---|
185 |
|
---|
186 | #ifdef RT_OS_WINDOWS
|
---|
187 | static int audioTestSetMasterVolumeWASAPI(unsigned uVolPercent)
|
---|
188 | {
|
---|
189 | HRESULT hr;
|
---|
190 |
|
---|
191 | # define WASAPI_CHECK_HR_RET(a_Text) \
|
---|
192 | if (FAILED(hr)) \
|
---|
193 | { \
|
---|
194 | AssertLogRelMsgFailed(a_Text); \
|
---|
195 | return VERR_GENERAL_FAILURE; \
|
---|
196 | }
|
---|
197 |
|
---|
198 | hr = CoInitialize(NULL);
|
---|
199 | WASAPI_CHECK_HR_RET(("CoInitialize() failed, hr=%Rhrc", hr));
|
---|
200 | IMMDeviceEnumerator* pIEnumerator = NULL;
|
---|
201 | hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void **)&pIEnumerator);
|
---|
202 | WASAPI_CHECK_HR_RET(("WASAPI: Unable to create IMMDeviceEnumerator, hr=%Rhrc", hr));
|
---|
203 |
|
---|
204 | IMMDevice *pIMMDevice = NULL;
|
---|
205 | hr = pIEnumerator->GetDefaultAudioEndpoint(EDataFlow::eRender, ERole::eConsole, &pIMMDevice);
|
---|
206 | WASAPI_CHECK_HR_RET(("WASAPI: Unable to get audio endpoint, hr=%Rhrc", hr));
|
---|
207 | pIEnumerator->Release();
|
---|
208 |
|
---|
209 | IAudioEndpointVolume *pIAudioEndpointVolume = NULL;
|
---|
210 | hr = pIMMDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, (void **)&pIAudioEndpointVolume);
|
---|
211 | WASAPI_CHECK_HR_RET(("WASAPI: Unable to activate audio endpoint volume, hr=%Rhrc", hr));
|
---|
212 | pIMMDevice->Release();
|
---|
213 |
|
---|
214 | float dbMin, dbMax, dbInc;
|
---|
215 | hr = pIAudioEndpointVolume->GetVolumeRange(&dbMin, &dbMax, &dbInc);
|
---|
216 | WASAPI_CHECK_HR_RET(("WASAPI: Unable to get volume range, hr=%Rhrc", hr));
|
---|
217 |
|
---|
218 | float const dbSteps = (dbMax - dbMin) / dbInc;
|
---|
219 | float const dbStepsPerPercent = (dbSteps * dbInc) / 100;
|
---|
220 | float const dbVol = dbMin + (dbStepsPerPercent * (float(RT_MIN(uVolPercent, 100.0))));
|
---|
221 |
|
---|
222 | hr = pIAudioEndpointVolume->SetMasterVolumeLevel(dbVol, NULL);
|
---|
223 | WASAPI_CHECK_HR_RET(("WASAPI: Unable to set master volume level, hr=%Rhrc", hr));
|
---|
224 | pIAudioEndpointVolume->Release();
|
---|
225 |
|
---|
226 | return VINF_SUCCESS;
|
---|
227 |
|
---|
228 | # undef WASAPI_CHECK_HR_RET
|
---|
229 | }
|
---|
230 | #endif /* RT_OS_WINDOWS */
|
---|
231 |
|
---|
232 | /**
|
---|
233 | * Sets the system's master volume, if available.
|
---|
234 | *
|
---|
235 | * @returns VBox status code. VERR_NOT_SUPPORTED if not supported.
|
---|
236 | * @param uVolPercent Volume (in percent) to set.
|
---|
237 | */
|
---|
238 | int audioTestSetMasterVolume(unsigned uVolPercent)
|
---|
239 | {
|
---|
240 | int rc = VINF_SUCCESS;
|
---|
241 |
|
---|
242 | #ifdef VBOX_WITH_AUDIO_ALSA
|
---|
243 | rc = audioTestSetMasterVolumeALSA(uVolPercent);
|
---|
244 | if (RT_SUCCESS(rc))
|
---|
245 | return rc;
|
---|
246 | /* else try OSS (if available) below. */
|
---|
247 | #endif /* VBOX_WITH_AUDIO_ALSA */
|
---|
248 |
|
---|
249 | #ifdef VBOX_WITH_AUDIO_OSS
|
---|
250 | rc = audioTestSetMasterVolumeOSS(uVolPercent);
|
---|
251 | if (RT_SUCCESS(rc))
|
---|
252 | return rc;
|
---|
253 | #endif /* VBOX_WITH_AUDIO_OSS */
|
---|
254 |
|
---|
255 | #ifdef RT_OS_WINDOWS
|
---|
256 | rc = audioTestSetMasterVolumeWASAPI(uVolPercent);
|
---|
257 | if (RT_SUCCESS(rc))
|
---|
258 | return rc;
|
---|
259 | #endif
|
---|
260 |
|
---|
261 | RT_NOREF(rc, uVolPercent);
|
---|
262 | /** @todo Port other platforms. */
|
---|
263 | return VERR_NOT_SUPPORTED;
|
---|
264 | }
|
---|
265 |
|
---|
266 |
|
---|
267 | /*********************************************************************************************************************************
|
---|
268 | * Device enumeration + handling. *
|
---|
269 | *********************************************************************************************************************************/
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * Enumerates audio devices and optionally searches for a specific device.
|
---|
273 | *
|
---|
274 | * @returns VBox status code.
|
---|
275 | * @param pDrvStack Driver stack to use for enumeration.
|
---|
276 | * @param pszDev Device name to search for. Can be NULL if the default device shall be used.
|
---|
277 | * @param ppDev Where to return the pointer of the device enumeration of \a pTstEnv when a
|
---|
278 | * specific device was found.
|
---|
279 | */
|
---|
280 | int audioTestDevicesEnumerateAndCheck(PAUDIOTESTDRVSTACK pDrvStack, const char *pszDev, PPDMAUDIOHOSTDEV *ppDev)
|
---|
281 | {
|
---|
282 | RTTestSubF(g_hTest, "Enumerating audio devices and checking for device '%s'", pszDev && *pszDev ? pszDev : "[Default]");
|
---|
283 |
|
---|
284 | if (!pDrvStack->pIHostAudio->pfnGetDevices)
|
---|
285 | {
|
---|
286 | RTTestSkipped(g_hTest, "Backend does not support device enumeration, skipping");
|
---|
287 | return VINF_NOT_SUPPORTED;
|
---|
288 | }
|
---|
289 |
|
---|
290 | Assert(pszDev == NULL || ppDev);
|
---|
291 |
|
---|
292 | if (ppDev)
|
---|
293 | *ppDev = NULL;
|
---|
294 |
|
---|
295 | int rc = pDrvStack->pIHostAudio->pfnGetDevices(pDrvStack->pIHostAudio, &pDrvStack->DevEnum);
|
---|
296 | if (RT_SUCCESS(rc))
|
---|
297 | {
|
---|
298 | PPDMAUDIOHOSTDEV pDev;
|
---|
299 | RTListForEach(&pDrvStack->DevEnum.LstDevices, pDev, PDMAUDIOHOSTDEV, ListEntry)
|
---|
300 | {
|
---|
301 | char szFlags[PDMAUDIOHOSTDEV_MAX_FLAGS_STRING_LEN];
|
---|
302 | if (pDev->pszId)
|
---|
303 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enum: Device '%s' (ID '%s'):\n", pDev->pszName, pDev->pszId);
|
---|
304 | else
|
---|
305 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enum: Device '%s':\n", pDev->pszName);
|
---|
306 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enum: Usage = %s\n", PDMAudioDirGetName(pDev->enmUsage));
|
---|
307 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enum: Flags = %s\n", PDMAudioHostDevFlagsToString(szFlags, pDev->fFlags));
|
---|
308 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enum: Input channels = %RU8\n", pDev->cMaxInputChannels);
|
---|
309 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enum: Output channels = %RU8\n", pDev->cMaxOutputChannels);
|
---|
310 |
|
---|
311 | if ( (pszDev && *pszDev)
|
---|
312 | && !RTStrCmp(pDev->pszName, pszDev))
|
---|
313 | {
|
---|
314 | *ppDev = pDev;
|
---|
315 | }
|
---|
316 | }
|
---|
317 | }
|
---|
318 | else
|
---|
319 | RTTestFailed(g_hTest, "Enumerating audio devices failed with %Rrc", rc);
|
---|
320 |
|
---|
321 | if (RT_SUCCESS(rc))
|
---|
322 | {
|
---|
323 | if ( (pszDev && *pszDev)
|
---|
324 | && *ppDev == NULL)
|
---|
325 | {
|
---|
326 | RTTestFailed(g_hTest, "Audio device '%s' not found", pszDev);
|
---|
327 | rc = VERR_NOT_FOUND;
|
---|
328 | }
|
---|
329 | }
|
---|
330 |
|
---|
331 | RTTestSubDone(g_hTest);
|
---|
332 | return rc;
|
---|
333 | }
|
---|
334 |
|
---|
335 | static int audioTestStreamInit(PAUDIOTESTDRVSTACK pDrvStack, PAUDIOTESTSTREAM pStream,
|
---|
336 | PDMAUDIODIR enmDir, PAUDIOTESTIOOPTS pIoOpts)
|
---|
337 | {
|
---|
338 | int rc;
|
---|
339 |
|
---|
340 | if (enmDir == PDMAUDIODIR_IN)
|
---|
341 | rc = audioTestDriverStackStreamCreateInput(pDrvStack, &pIoOpts->Props, pIoOpts->cMsBufferSize,
|
---|
342 | pIoOpts->cMsPreBuffer, pIoOpts->cMsSchedulingHint, &pStream->pStream, &pStream->Cfg);
|
---|
343 | else if (enmDir == PDMAUDIODIR_OUT)
|
---|
344 | rc = audioTestDriverStackStreamCreateOutput(pDrvStack, &pIoOpts->Props, pIoOpts->cMsBufferSize,
|
---|
345 | pIoOpts->cMsPreBuffer, pIoOpts->cMsSchedulingHint, &pStream->pStream, &pStream->Cfg);
|
---|
346 | else
|
---|
347 | rc = VERR_NOT_SUPPORTED;
|
---|
348 |
|
---|
349 | if (RT_SUCCESS(rc))
|
---|
350 | {
|
---|
351 | if (!pDrvStack->pIAudioConnector)
|
---|
352 | {
|
---|
353 | pStream->pBackend = &((PAUDIOTESTDRVSTACKSTREAM)pStream->pStream)->Backend;
|
---|
354 | }
|
---|
355 | else
|
---|
356 | pStream->pBackend = NULL;
|
---|
357 |
|
---|
358 | /*
|
---|
359 | * Automatically enable the mixer if the PCM properties don't match.
|
---|
360 | */
|
---|
361 | if ( !pIoOpts->fWithMixer
|
---|
362 | && !PDMAudioPropsAreEqual(&pIoOpts->Props, &pStream->Cfg.Props))
|
---|
363 | {
|
---|
364 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enabling stream mixer\n");
|
---|
365 | pIoOpts->fWithMixer = true;
|
---|
366 | }
|
---|
367 |
|
---|
368 | rc = AudioTestMixStreamInit(&pStream->Mix, pDrvStack, pStream->pStream,
|
---|
369 | pIoOpts->fWithMixer ? &pIoOpts->Props : NULL, 100 /* ms */); /** @todo Configure mixer buffer? */
|
---|
370 | }
|
---|
371 |
|
---|
372 | if (RT_FAILURE(rc))
|
---|
373 | RTTestFailed(g_hTest, "Initializing %s stream failed with %Rrc", enmDir == PDMAUDIODIR_IN ? "input" : "output", rc);
|
---|
374 |
|
---|
375 | return rc;
|
---|
376 | }
|
---|
377 |
|
---|
378 | /**
|
---|
379 | * Destroys an audio test stream.
|
---|
380 | *
|
---|
381 | * @returns VBox status code.
|
---|
382 | * @param pDrvStack Driver stack the stream belongs to.
|
---|
383 | * @param pStream Audio stream to destroy.
|
---|
384 | */
|
---|
385 | static int audioTestStreamDestroy(PAUDIOTESTDRVSTACK pDrvStack, PAUDIOTESTSTREAM pStream)
|
---|
386 | {
|
---|
387 | AssertPtrReturn(pStream, VERR_INVALID_POINTER);
|
---|
388 |
|
---|
389 | if (pStream->pStream)
|
---|
390 | {
|
---|
391 | /** @todo Anything else to do here, e.g. test if there are left over samples or some such? */
|
---|
392 |
|
---|
393 | audioTestDriverStackStreamDestroy(pDrvStack, pStream->pStream);
|
---|
394 | pStream->pStream = NULL;
|
---|
395 | pStream->pBackend = NULL;
|
---|
396 | }
|
---|
397 |
|
---|
398 | AudioTestMixStreamTerm(&pStream->Mix);
|
---|
399 |
|
---|
400 | return VINF_SUCCESS;
|
---|
401 | }
|
---|
402 |
|
---|
403 |
|
---|
404 | /*********************************************************************************************************************************
|
---|
405 | * Test Primitives *
|
---|
406 | *********************************************************************************************************************************/
|
---|
407 |
|
---|
408 | /**
|
---|
409 | * Initializes test tone parameters (partly with random values).
|
---|
410 |
|
---|
411 | * @param pToneParms Test tone parameters to initialize.
|
---|
412 | */
|
---|
413 | void audioTestToneParmsInit(PAUDIOTESTTONEPARMS pToneParms)
|
---|
414 | {
|
---|
415 | RT_BZERO(pToneParms, sizeof(AUDIOTESTTONEPARMS));
|
---|
416 |
|
---|
417 | /**
|
---|
418 | * Set default (randomized) test tone parameters if not set explicitly.
|
---|
419 | */
|
---|
420 | pToneParms->dbFreqHz = AudioTestToneGetRandomFreq();
|
---|
421 | pToneParms->msDuration = RTRandU32Ex(200, RT_MS_30SEC);
|
---|
422 | pToneParms->uVolumePercent = 100; /* We always go with maximum volume for now. */
|
---|
423 |
|
---|
424 | PDMAudioPropsInit(&pToneParms->Props,
|
---|
425 | 2 /* 16-bit */, true /* fPcmSigned */, 2 /* cPcmChannels */, 44100 /* uPcmHz */);
|
---|
426 | }
|
---|
427 |
|
---|
428 | /**
|
---|
429 | * Initializes I/O options with some sane default values.
|
---|
430 | *
|
---|
431 | * @param pIoOpts I/O options to initialize.
|
---|
432 | */
|
---|
433 | void audioTestIoOptsInitDefaults(PAUDIOTESTIOOPTS pIoOpts)
|
---|
434 | {
|
---|
435 | RT_BZERO(pIoOpts, sizeof(AUDIOTESTIOOPTS));
|
---|
436 |
|
---|
437 | /* Initialize the PCM properties to some sane values. */
|
---|
438 | PDMAudioPropsInit(&pIoOpts->Props,
|
---|
439 | 2 /* 16-bit */, true /* fPcmSigned */, 2 /* cPcmChannels */, 44100 /* uPcmHz */);
|
---|
440 |
|
---|
441 | pIoOpts->cMsBufferSize = UINT32_MAX;
|
---|
442 | pIoOpts->cMsPreBuffer = UINT32_MAX;
|
---|
443 | pIoOpts->cMsSchedulingHint = UINT32_MAX;
|
---|
444 | pIoOpts->uVolumePercent = 100; /* Use maximum volume by default. */
|
---|
445 | }
|
---|
446 |
|
---|
447 | #if 0 /* Unused */
|
---|
448 | /**
|
---|
449 | * Returns a random scheduling hint (in ms).
|
---|
450 | */
|
---|
451 | DECLINLINE(uint32_t) audioTestEnvGetRandomSchedulingHint(void)
|
---|
452 | {
|
---|
453 | static const unsigned s_aSchedulingHintsMs[] =
|
---|
454 | {
|
---|
455 | 10,
|
---|
456 | 25,
|
---|
457 | 50,
|
---|
458 | 100,
|
---|
459 | 200,
|
---|
460 | 250
|
---|
461 | };
|
---|
462 |
|
---|
463 | return s_aSchedulingHintsMs[RTRandU32Ex(0, RT_ELEMENTS(s_aSchedulingHintsMs) - 1)];
|
---|
464 | }
|
---|
465 | #endif
|
---|
466 |
|
---|
467 | /**
|
---|
468 | * Plays a test tone on a specific audio test stream.
|
---|
469 | *
|
---|
470 | * @returns VBox status code.
|
---|
471 | * @param pIoOpts I/O options to use.
|
---|
472 | * @param pTstEnv Test environment to use for running the test.
|
---|
473 | * Optional and can be NULL (for simple playback only).
|
---|
474 | * @param pStream Stream to use for playing the tone.
|
---|
475 | * @param pParms Tone parameters to use.
|
---|
476 | *
|
---|
477 | * @note Blocking function.
|
---|
478 | */
|
---|
479 | int audioTestPlayTone(PAUDIOTESTIOOPTS pIoOpts, PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream, PAUDIOTESTTONEPARMS pParms)
|
---|
480 | {
|
---|
481 | AUDIOTESTTONE TstTone;
|
---|
482 | AudioTestToneInit(&TstTone, &pStream->Cfg.Props, pParms->dbFreqHz);
|
---|
483 |
|
---|
484 | char const *pcszPathOut = NULL;
|
---|
485 | if (pTstEnv)
|
---|
486 | pcszPathOut = pTstEnv->Set.szPathAbs;
|
---|
487 |
|
---|
488 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Playing test tone (tone frequency is %RU16Hz, %RU32ms, %RU8%% volume)\n",
|
---|
489 | (uint16_t)pParms->dbFreqHz, pParms->msDuration, pParms->uVolumePercent);
|
---|
490 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using %RU32ms stream scheduling hint\n", pStream->Cfg.Device.cMsSchedulingHint);
|
---|
491 | if (pcszPathOut)
|
---|
492 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Writing to '%s'\n", pcszPathOut);
|
---|
493 |
|
---|
494 | int rc;
|
---|
495 |
|
---|
496 | /** @todo Use .WAV here? */
|
---|
497 | AUDIOTESTOBJ Obj;
|
---|
498 | RT_ZERO(Obj); /* Shut up MSVC. */
|
---|
499 | if (pTstEnv)
|
---|
500 | {
|
---|
501 | rc = AudioTestSetObjCreateAndRegister(&pTstEnv->Set, "guest-tone-play.pcm", &Obj);
|
---|
502 | AssertRCReturn(rc, rc);
|
---|
503 | }
|
---|
504 |
|
---|
505 | uint8_t const uVolPercent = pIoOpts->uVolumePercent;
|
---|
506 | int rc2 = audioTestSetMasterVolume(uVolPercent);
|
---|
507 | if (RT_FAILURE(rc2))
|
---|
508 | {
|
---|
509 | if (rc2 == VERR_NOT_SUPPORTED)
|
---|
510 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Setting system's master volume is not supported on this platform, skipping\n");
|
---|
511 | else
|
---|
512 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Setting system's master volume failed with %Rrc\n", rc2);
|
---|
513 | }
|
---|
514 | else
|
---|
515 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Set system's master volume to %RU8%%\n", uVolPercent);
|
---|
516 |
|
---|
517 | rc = AudioTestMixStreamEnable(&pStream->Mix);
|
---|
518 | if ( RT_SUCCESS(rc)
|
---|
519 | && AudioTestMixStreamIsOkay(&pStream->Mix))
|
---|
520 | {
|
---|
521 | uint8_t abBuf[_4K];
|
---|
522 |
|
---|
523 | uint32_t cbToPlayTotal = PDMAudioPropsMilliToBytes(&pStream->Cfg.Props, pParms->msDuration);
|
---|
524 | AssertStmt(cbToPlayTotal, rc = VERR_INVALID_PARAMETER);
|
---|
525 | uint32_t cbPlayedTotal = 0;
|
---|
526 |
|
---|
527 | /* We play a pre + post beacon before + after the actual test tone.
|
---|
528 | * We always start with the pre beacon. */
|
---|
529 | AUDIOTESTTONEBEACON Beacon;
|
---|
530 | AudioTestBeaconInit(&Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_PRE, &pStream->Cfg.Props);
|
---|
531 |
|
---|
532 | uint32_t const cbBeacon = AudioTestBeaconGetSize(&Beacon);
|
---|
533 | if (cbBeacon)
|
---|
534 | {
|
---|
535 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Playing 2 x %RU32 bytes pre/post beacons\n", cbBeacon);
|
---|
536 | cbToPlayTotal += cbBeacon * 2 /* Pre + post beacon */;
|
---|
537 | }
|
---|
538 |
|
---|
539 | if (pTstEnv)
|
---|
540 | {
|
---|
541 | AudioTestObjAddMetadataStr(Obj, "beacon_type=%RU32\n", (uint32_t)AudioTestBeaconGetType(&Beacon));
|
---|
542 | AudioTestObjAddMetadataStr(Obj, "beacon_pre_bytes=%RU32\n", cbBeacon);
|
---|
543 | AudioTestObjAddMetadataStr(Obj, "beacon_post_bytes=%RU32\n", cbBeacon);
|
---|
544 | AudioTestObjAddMetadataStr(Obj, "stream_to_play_bytes=%RU32\n", cbToPlayTotal);
|
---|
545 | AudioTestObjAddMetadataStr(Obj, "stream_period_size_frames=%RU32\n", pStream->Cfg.Backend.cFramesPeriod);
|
---|
546 | AudioTestObjAddMetadataStr(Obj, "stream_buffer_size_frames=%RU32\n", pStream->Cfg.Backend.cFramesBufferSize);
|
---|
547 | AudioTestObjAddMetadataStr(Obj, "stream_prebuf_size_frames=%RU32\n", pStream->Cfg.Backend.cFramesPreBuffering);
|
---|
548 | /* Note: This mostly is provided by backend (e.g. PulseAudio / ALSA / ++) and
|
---|
549 | * has nothing to do with the device emulation scheduling hint. */
|
---|
550 | AudioTestObjAddMetadataStr(Obj, "device_scheduling_hint_ms=%RU32\n", pStream->Cfg.Device.cMsSchedulingHint);
|
---|
551 | }
|
---|
552 |
|
---|
553 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Playing %RU32 bytes total\n", cbToPlayTotal);
|
---|
554 |
|
---|
555 | PAUDIOTESTDRVMIXSTREAM pMix = &pStream->Mix;
|
---|
556 |
|
---|
557 | uint32_t const cbPreBuffer = PDMAudioPropsFramesToBytes(pMix->pProps, pStream->Cfg.Backend.cFramesPreBuffering);
|
---|
558 | uint64_t const nsStarted = RTTimeNanoTS();
|
---|
559 | uint64_t nsDonePreBuffering = 0;
|
---|
560 |
|
---|
561 | uint64_t offStream = 0;
|
---|
562 | uint64_t nsTimeout = RT_MS_5MIN_64 * RT_NS_1MS;
|
---|
563 | uint64_t nsLastMsgCantWrite = 0; /* Timestamp (in ns) when the last message of an unwritable stream was shown. */
|
---|
564 | uint64_t nsLastWrite = 0;
|
---|
565 |
|
---|
566 | while (cbPlayedTotal < cbToPlayTotal)
|
---|
567 | {
|
---|
568 | uint64_t const nsNow = RTTimeNanoTS();
|
---|
569 | if (!nsLastWrite)
|
---|
570 | nsLastWrite = nsNow;
|
---|
571 |
|
---|
572 | /* Pace ourselves a little. */
|
---|
573 | if (offStream >= cbPreBuffer)
|
---|
574 | {
|
---|
575 | if (!nsDonePreBuffering)
|
---|
576 | nsDonePreBuffering = nsNow;
|
---|
577 | uint64_t const cNsWritten = PDMAudioPropsBytesToNano64(pMix->pProps, offStream - cbPreBuffer);
|
---|
578 | uint64_t const cNsElapsed = nsNow - nsStarted;
|
---|
579 | if (cNsWritten > cNsElapsed + RT_NS_10MS)
|
---|
580 | RTThreadSleep((cNsWritten - cNsElapsed - RT_NS_10MS / 2) / RT_NS_1MS);
|
---|
581 | }
|
---|
582 |
|
---|
583 | uint32_t cbPlayed = 0;
|
---|
584 | uint32_t const cbCanWrite = AudioTestMixStreamGetWritable(&pStream->Mix);
|
---|
585 | if (cbCanWrite)
|
---|
586 | {
|
---|
587 | if (g_uVerbosity >= 3)
|
---|
588 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Stream is writable with %RU32ms (%RU32 bytes)\n",
|
---|
589 | PDMAudioPropsBytesToMilli(pMix->pProps, cbCanWrite), cbCanWrite);
|
---|
590 |
|
---|
591 | uint32_t cbToPlay;
|
---|
592 |
|
---|
593 | /* Any beacon to play? */
|
---|
594 | uint32_t const cbBeaconRemaining = AudioTestBeaconGetRemaining(&Beacon);
|
---|
595 | if (cbBeaconRemaining)
|
---|
596 | {
|
---|
597 | /* Limit to exactly one beacon (pre or post). */
|
---|
598 | cbToPlay = RT_MIN(sizeof(abBuf), RT_MIN(cbCanWrite, cbBeaconRemaining));
|
---|
599 | rc = AudioTestBeaconWrite(&Beacon, abBuf, cbToPlay);
|
---|
600 | if (RT_SUCCESS(rc))
|
---|
601 | rc = AudioTestMixStreamPlay(&pStream->Mix, abBuf, cbToPlay, &cbPlayed);
|
---|
602 | if (RT_FAILURE(rc))
|
---|
603 | break;
|
---|
604 |
|
---|
605 | if (pTstEnv)
|
---|
606 | {
|
---|
607 | /* Also write the beacon data to the test object.
|
---|
608 | * Note: We use cbPlayed here instead of cbToPlay to know if the data actually was
|
---|
609 | * reported as being played by the audio stack. */
|
---|
610 | rc = AudioTestObjWrite(Obj, abBuf, cbPlayed);
|
---|
611 | }
|
---|
612 | }
|
---|
613 | else /* Play test tone */
|
---|
614 | {
|
---|
615 | uint32_t const cbTestToneToPlay = cbToPlayTotal - cbPlayedTotal - (cbBeacon /* Pre / post beacon */);
|
---|
616 | if (cbTestToneToPlay == 0) /* Done playing the test tone? */
|
---|
617 | {
|
---|
618 | if (AudioTestBeaconGetSize(&Beacon)) /* Play the post beacon, if any. */
|
---|
619 | {
|
---|
620 | AudioTestBeaconInit(&Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_POST, &pStream->Cfg.Props);
|
---|
621 | continue;
|
---|
622 | }
|
---|
623 |
|
---|
624 | break;
|
---|
625 | }
|
---|
626 |
|
---|
627 | uint32_t const cbToGenerate = RT_MIN(RT_MIN(cbTestToneToPlay, sizeof(abBuf)), cbCanWrite);
|
---|
628 | rc = AudioTestToneGenerate(&TstTone, abBuf, cbToGenerate, &cbToPlay);
|
---|
629 | if (RT_SUCCESS(rc))
|
---|
630 | {
|
---|
631 | if (pTstEnv)
|
---|
632 | {
|
---|
633 | /* Write stuff to disk before trying to play it. Help analysis later. */
|
---|
634 | rc = AudioTestObjWrite(Obj, abBuf, cbToPlay);
|
---|
635 | }
|
---|
636 | if (RT_SUCCESS(rc))
|
---|
637 | {
|
---|
638 | rc = AudioTestMixStreamPlay(&pStream->Mix, abBuf, cbToPlay, &cbPlayed);
|
---|
639 | if (RT_SUCCESS(rc))
|
---|
640 | {
|
---|
641 | AssertBreakStmt(cbPlayed <= cbToPlay, rc = VERR_TOO_MUCH_DATA);
|
---|
642 |
|
---|
643 | offStream += cbPlayed;
|
---|
644 |
|
---|
645 | if (cbPlayed != cbToPlay)
|
---|
646 | RTTestFailed(g_hTest, "Only played %RU32/%RU32 bytes", cbPlayed, cbToPlay);
|
---|
647 |
|
---|
648 | if (cbPlayed)
|
---|
649 | nsLastWrite = nsNow;
|
---|
650 | }
|
---|
651 | }
|
---|
652 | }
|
---|
653 | }
|
---|
654 |
|
---|
655 | if (RT_FAILURE(rc))
|
---|
656 | break;
|
---|
657 |
|
---|
658 | nsLastMsgCantWrite = 0;
|
---|
659 | }
|
---|
660 | else if (AudioTestMixStreamIsOkay(&pStream->Mix))
|
---|
661 | {
|
---|
662 | RTMSINTERVAL const msSleep = RT_MIN(RT_MAX(1, pStream->Cfg.Device.cMsSchedulingHint), 256);
|
---|
663 |
|
---|
664 | if ( g_uVerbosity >= 3
|
---|
665 | && ( !nsLastMsgCantWrite
|
---|
666 | || (nsNow - nsLastMsgCantWrite) > RT_NS_10SEC)) /* Don't spam the output too much. */
|
---|
667 | {
|
---|
668 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Waiting %RU32ms for stream to be writable again (last write %RU64ns ago) ...\n",
|
---|
669 | msSleep, nsNow - nsLastWrite);
|
---|
670 | nsLastMsgCantWrite = nsNow;
|
---|
671 | }
|
---|
672 |
|
---|
673 | RTThreadSleep(msSleep);
|
---|
674 | }
|
---|
675 | else
|
---|
676 | AssertFailedBreakStmt(rc = VERR_AUDIO_STREAM_NOT_READY);
|
---|
677 |
|
---|
678 | cbPlayedTotal += cbPlayed;
|
---|
679 | AssertBreakStmt(cbPlayedTotal <= cbToPlayTotal, VERR_BUFFER_OVERFLOW);
|
---|
680 |
|
---|
681 | /* Fail-safe in case something screwed up while playing back. */
|
---|
682 | uint64_t const cNsElapsed = nsNow - nsStarted;
|
---|
683 | if (cNsElapsed > nsTimeout)
|
---|
684 | {
|
---|
685 | RTTestFailed(g_hTest, "Playback took too long (running %RU64 vs. timeout %RU64), aborting\n", cNsElapsed, nsTimeout);
|
---|
686 | rc = VERR_TIMEOUT;
|
---|
687 | }
|
---|
688 |
|
---|
689 | if (RT_FAILURE(rc))
|
---|
690 | break;
|
---|
691 | }
|
---|
692 |
|
---|
693 | if (cbPlayedTotal != cbToPlayTotal)
|
---|
694 | RTTestFailed(g_hTest, "Playback ended unexpectedly (%RU32/%RU32 played)\n", cbPlayedTotal, cbToPlayTotal);
|
---|
695 |
|
---|
696 | if (RT_SUCCESS(rc))
|
---|
697 | {
|
---|
698 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Draining stream ...\n");
|
---|
699 | rc = AudioTestMixStreamDrain(&pStream->Mix, true /*fSync*/);
|
---|
700 | }
|
---|
701 | }
|
---|
702 | else
|
---|
703 | rc = VERR_AUDIO_STREAM_NOT_READY;
|
---|
704 |
|
---|
705 | if (pTstEnv)
|
---|
706 | {
|
---|
707 | rc2 = AudioTestObjClose(Obj);
|
---|
708 | if (RT_SUCCESS(rc))
|
---|
709 | rc = rc2;
|
---|
710 | }
|
---|
711 |
|
---|
712 | if (RT_FAILURE(rc))
|
---|
713 | RTTestFailed(g_hTest, "Playing tone failed with %Rrc\n", rc);
|
---|
714 |
|
---|
715 | return rc;
|
---|
716 | }
|
---|
717 |
|
---|
718 | /**
|
---|
719 | * Records a test tone from a specific audio test stream.
|
---|
720 | *
|
---|
721 | * @returns VBox status code.
|
---|
722 | * @param pIoOpts I/O options to use.
|
---|
723 | * @param pTstEnv Test environment to use for running the test.
|
---|
724 | * @param pStream Stream to use for recording the tone.
|
---|
725 | * @param pParms Tone parameters to use.
|
---|
726 | *
|
---|
727 | * @note Blocking function.
|
---|
728 | */
|
---|
729 | static int audioTestRecordTone(PAUDIOTESTIOOPTS pIoOpts, PAUDIOTESTENV pTstEnv, PAUDIOTESTSTREAM pStream, PAUDIOTESTTONEPARMS pParms)
|
---|
730 | {
|
---|
731 | const char *pcszPathOut = pTstEnv->Set.szPathAbs;
|
---|
732 |
|
---|
733 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Recording test tone (tone frequency is %RU16Hz, %RU32ms)\n", (uint16_t)pParms->dbFreqHz, pParms->msDuration);
|
---|
734 | RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Writing to '%s'\n", pcszPathOut);
|
---|
735 |
|
---|
736 | /** @todo Use .WAV here? */
|
---|
737 | AUDIOTESTOBJ Obj;
|
---|
738 | int rc = AudioTestSetObjCreateAndRegister(&pTstEnv->Set, "guest-tone-rec.pcm", &Obj);
|
---|
739 | AssertRCReturn(rc, rc);
|
---|
740 |
|
---|
741 | PAUDIOTESTDRVMIXSTREAM pMix = &pStream->Mix;
|
---|
742 |
|
---|
743 | rc = AudioTestMixStreamEnable(pMix);
|
---|
744 | if (RT_SUCCESS(rc))
|
---|
745 | {
|
---|
746 | uint64_t cbRecTotal = 0; /* Counts everything, including silence / whatever. */
|
---|
747 | uint64_t cbTestToRec = PDMAudioPropsMilliToBytes(&pStream->Cfg.Props, pParms->msDuration);
|
---|
748 |
|
---|
749 | /* We expect a pre + post beacon before + after the actual test tone.
|
---|
750 | * We always start with the pre beacon. */
|
---|
751 | AUDIOTESTTONEBEACON Beacon;
|
---|
752 | AudioTestBeaconInit(&Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_PRE, &pStream->Cfg.Props);
|
---|
753 |
|
---|
754 | uint32_t const cbBeacon = AudioTestBeaconGetSize(&Beacon);
|
---|
755 | if (cbBeacon)
|
---|
756 | {
|
---|
757 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Expecting 2 x %RU32 bytes pre/post beacons\n", cbBeacon);
|
---|
758 | cbTestToRec = cbBeacon * 2 /* Pre + post beacon */;
|
---|
759 | }
|
---|
760 |
|
---|
761 | AudioTestObjAddMetadataStr(Obj, "beacon_type=%RU32\n", (uint32_t)AudioTestBeaconGetType(&Beacon));
|
---|
762 | AudioTestObjAddMetadataStr(Obj, "beacon_pre_bytes=%RU32\n", cbBeacon);
|
---|
763 | AudioTestObjAddMetadataStr(Obj, "beacon_post_bytes=%RU32\n", cbBeacon);
|
---|
764 | AudioTestObjAddMetadataStr(Obj, "stream_to_record_bytes=%RU32\n", cbTestToRec);
|
---|
765 | AudioTestObjAddMetadataStr(Obj, "stream_buffer_size_ms=%RU32\n", pIoOpts->cMsBufferSize);
|
---|
766 | AudioTestObjAddMetadataStr(Obj, "stream_prebuf_size_ms=%RU32\n", pIoOpts->cMsPreBuffer);
|
---|
767 | /* Note: This mostly is provided by backend (e.g. PulseAudio / ALSA / ++) and
|
---|
768 | * has nothing to do with the device emulation scheduling hint. */
|
---|
769 | AudioTestObjAddMetadataStr(Obj, "device_scheduling_hint_ms=%RU32\n", pIoOpts->cMsSchedulingHint);
|
---|
770 |
|
---|
771 | RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Recording %RU32 bytes total\n", cbTestToRec);
|
---|
772 |
|
---|
773 | uint8_t abSamples[16384];
|
---|
774 | uint32_t const cbSamplesAligned = PDMAudioPropsFloorBytesToFrame(pMix->pProps, sizeof(abSamples));
|
---|
775 | uint64_t cbTestRec = 0;
|
---|
776 |
|
---|
777 | uint64_t const nsStarted = RTTimeNanoTS();
|
---|
778 |
|
---|
779 | uint64_t nsTimeout = RT_MS_5MIN_64 * RT_NS_1MS;
|
---|
780 | uint64_t nsLastMsgCantRead = 0; /* Timestamp (in ns) when the last message of an unreadable stream was shown. */
|
---|
781 |
|
---|
782 | while (!g_fTerminate && cbTestRec < cbTestToRec)
|
---|
783 | {
|
---|
784 | uint64_t const nsNow = RTTimeNanoTS();
|
---|
785 |
|
---|
786 | /*
|
---|
787 | * Anything we can read?
|
---|
788 | */
|
---|
789 | uint32_t const cbCanRead = AudioTestMixStreamGetReadable(pMix);
|
---|
790 | if (cbCanRead)
|
---|
791 | {
|
---|
792 | if (g_uVerbosity >= 3)
|
---|
793 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Stream is readable with %RU32ms (%RU32 bytes)\n",
|
---|
794 | PDMAudioPropsBytesToMilli(pMix->pProps, cbCanRead), cbCanRead);
|
---|
795 |
|
---|
796 | uint32_t const cbToRead = RT_MIN(cbCanRead, cbSamplesAligned);
|
---|
797 | uint32_t cbRecorded = 0;
|
---|
798 | rc = AudioTestMixStreamCapture(pMix, abSamples, cbToRead, &cbRecorded);
|
---|
799 | if (RT_SUCCESS(rc))
|
---|
800 | {
|
---|
801 | if (cbRecorded)
|
---|
802 | {
|
---|
803 | cbRecTotal += cbRecorded;
|
---|
804 |
|
---|
805 | rc = AudioTestObjWrite(Obj, abSamples, cbRecorded);
|
---|
806 | if (RT_SUCCESS(rc))
|
---|
807 | {
|
---|
808 | if (AudioTestBeaconGetSize(&Beacon))
|
---|
809 | {
|
---|
810 | if (!AudioTestBeaconIsComplete(&Beacon))
|
---|
811 | {
|
---|
812 | bool const fStarted = AudioTestBeaconGetRemaining(&Beacon) == AudioTestBeaconGetSize(&Beacon);
|
---|
813 |
|
---|
814 | uint32_t const cbToAddMax = RT_MIN(cbRecorded, AudioTestBeaconGetRemaining(&Beacon));
|
---|
815 |
|
---|
816 | uint32_t const cbAdded = AudioTestBeaconAddConsecutive(&Beacon, abSamples, cbToAddMax);
|
---|
817 | if (cbAdded)
|
---|
818 | cbTestRec += cbAdded; /* Only count data which belongs to a (complete test tone). */
|
---|
819 |
|
---|
820 | if ( fStarted
|
---|
821 | && g_uVerbosity >= 2)
|
---|
822 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS,
|
---|
823 | "Detection of %s playback beacon started (%RU32ms recorded so far)\n",
|
---|
824 | AudioTestBeaconTypeGetName(Beacon.enmType),
|
---|
825 | PDMAudioPropsBytesToMilli(&pStream->pStream->Cfg.Props, cbRecTotal));
|
---|
826 |
|
---|
827 | if (AudioTestBeaconIsComplete(&Beacon))
|
---|
828 | {
|
---|
829 | if (g_uVerbosity >= 2)
|
---|
830 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Detection of %s playback beacon ended\n",
|
---|
831 | AudioTestBeaconTypeGetName(Beacon.enmType));
|
---|
832 | }
|
---|
833 | }
|
---|
834 | else
|
---|
835 | {
|
---|
836 | uint32_t const cbTestToneToRec = cbTestToRec - cbTestRec - cbBeacon;
|
---|
837 | if (cbTestToneToRec == 0) /* Done recording the test tone? */
|
---|
838 | {
|
---|
839 | AudioTestBeaconInit(&Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_POST, &pStream->Cfg.Props);
|
---|
840 | }
|
---|
841 | else /* Count test tone data. */
|
---|
842 | cbTestRec += cbRecorded;
|
---|
843 | }
|
---|
844 | }
|
---|
845 | }
|
---|
846 | }
|
---|
847 | }
|
---|
848 | }
|
---|
849 | else if (AudioTestMixStreamIsOkay(pMix))
|
---|
850 | {
|
---|
851 | RTMSINTERVAL const msSleep = RT_MIN(RT_MAX(1, pStream->Cfg.Device.cMsSchedulingHint), 256);
|
---|
852 |
|
---|
853 | if ( g_uVerbosity >= 3
|
---|
854 | && ( !nsLastMsgCantRead
|
---|
855 | || (nsNow - nsLastMsgCantRead) > RT_NS_10SEC)) /* Don't spam the output too much. */
|
---|
856 | {
|
---|
857 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Waiting %RU32ms for stream to be readable again ...\n", msSleep);
|
---|
858 | nsLastMsgCantRead = nsNow;
|
---|
859 | }
|
---|
860 |
|
---|
861 | RTThreadSleep(msSleep);
|
---|
862 | }
|
---|
863 |
|
---|
864 | /* Fail-safe in case something screwed up while playing back. */
|
---|
865 | uint64_t const cNsElapsed = nsNow - nsStarted;
|
---|
866 | if (cNsElapsed > nsTimeout)
|
---|
867 | {
|
---|
868 | RTTestFailed(g_hTest, "Recording took too long (running %RU64 vs. timeout %RU64), aborting\n", cNsElapsed, nsTimeout);
|
---|
869 | rc = VERR_TIMEOUT;
|
---|
870 | }
|
---|
871 |
|
---|
872 | if (RT_FAILURE(rc))
|
---|
873 | break;
|
---|
874 | }
|
---|
875 |
|
---|
876 | if (cbTestRec != cbTestToRec)
|
---|
877 | RTTestFailed(g_hTest, "Recording ended unexpectedly (%RU32/%RU32 recorded)\n", cbTestRec, cbTestToRec);
|
---|
878 |
|
---|
879 | int rc2 = AudioTestMixStreamDisable(pMix);
|
---|
880 | if (RT_SUCCESS(rc))
|
---|
881 | rc = rc2;
|
---|
882 | }
|
---|
883 |
|
---|
884 | int rc2 = AudioTestObjClose(Obj);
|
---|
885 | if (RT_SUCCESS(rc))
|
---|
886 | rc = rc2;
|
---|
887 |
|
---|
888 | if (RT_FAILURE(rc))
|
---|
889 | RTTestFailed(g_hTest, "Recording tone done failed with %Rrc\n", rc);
|
---|
890 |
|
---|
891 | return rc;
|
---|
892 | }
|
---|
893 |
|
---|
894 |
|
---|
895 | /*********************************************************************************************************************************
|
---|
896 | * ATS Callback Implementations *
|
---|
897 | *********************************************************************************************************************************/
|
---|
898 |
|
---|
899 | /** @copydoc ATSCALLBACKS::pfnHowdy
|
---|
900 | *
|
---|
901 | * @note Runs as part of the guest ATS.
|
---|
902 | */
|
---|
903 | static DECLCALLBACK(int) audioTestGstAtsHowdyCallback(void const *pvUser)
|
---|
904 | {
|
---|
905 | PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser;
|
---|
906 |
|
---|
907 | AssertReturn(pCtx->cClients <= UINT8_MAX - 1, VERR_BUFFER_OVERFLOW);
|
---|
908 |
|
---|
909 | pCtx->cClients++;
|
---|
910 |
|
---|
911 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "New client connected, now %RU8 total\n", pCtx->cClients);
|
---|
912 |
|
---|
913 | return VINF_SUCCESS;
|
---|
914 | }
|
---|
915 |
|
---|
916 | /** @copydoc ATSCALLBACKS::pfnBye
|
---|
917 | *
|
---|
918 | * @note Runs as part of the guest ATS.
|
---|
919 | */
|
---|
920 | static DECLCALLBACK(int) audioTestGstAtsByeCallback(void const *pvUser)
|
---|
921 | {
|
---|
922 | PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser;
|
---|
923 |
|
---|
924 | AssertReturn(pCtx->cClients, VERR_WRONG_ORDER);
|
---|
925 | pCtx->cClients--;
|
---|
926 |
|
---|
927 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Client wants to disconnect, %RU8 remaining\n", pCtx->cClients);
|
---|
928 |
|
---|
929 | if (0 == pCtx->cClients) /* All clients disconnected? Tear things down. */
|
---|
930 | {
|
---|
931 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Last client disconnected, terminating server ...\n");
|
---|
932 | ASMAtomicWriteBool(&g_fTerminate, true);
|
---|
933 | }
|
---|
934 |
|
---|
935 | return VINF_SUCCESS;
|
---|
936 | }
|
---|
937 |
|
---|
938 | /** @copydoc ATSCALLBACKS::pfnTestSetBegin
|
---|
939 | *
|
---|
940 | * @note Runs as part of the guest ATS.
|
---|
941 | */
|
---|
942 | static DECLCALLBACK(int) audioTestGstAtsTestSetBeginCallback(void const *pvUser, const char *pszTag)
|
---|
943 | {
|
---|
944 | PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser;
|
---|
945 | PAUDIOTESTENV pTstEnv = pCtx->pTstEnv;
|
---|
946 |
|
---|
947 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Got request for beginning test set '%s' in '%s'\n", pszTag, pTstEnv->szPathTemp);
|
---|
948 |
|
---|
949 | return AudioTestSetCreate(&pTstEnv->Set, pTstEnv->szPathTemp, pszTag);
|
---|
950 | }
|
---|
951 |
|
---|
952 | /** @copydoc ATSCALLBACKS::pfnTestSetEnd
|
---|
953 | *
|
---|
954 | * @note Runs as part of the guest ATS.
|
---|
955 | */
|
---|
956 | static DECLCALLBACK(int) audioTestGstAtsTestSetEndCallback(void const *pvUser, const char *pszTag)
|
---|
957 | {
|
---|
958 | PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser;
|
---|
959 | PAUDIOTESTENV pTstEnv = pCtx->pTstEnv;
|
---|
960 |
|
---|
961 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Got request for ending test set '%s'\n", pszTag);
|
---|
962 |
|
---|
963 | /* Pack up everything to be ready for transmission. */
|
---|
964 | return audioTestEnvPrologue(pTstEnv, true /* fPack */, pCtx->szTestSetArchive, sizeof(pCtx->szTestSetArchive));
|
---|
965 | }
|
---|
966 |
|
---|
967 | /** @copydoc ATSCALLBACKS::pfnTonePlay
|
---|
968 | *
|
---|
969 | * @note Runs as part of the guest ATS.
|
---|
970 | */
|
---|
971 | static DECLCALLBACK(int) audioTestGstAtsTonePlayCallback(void const *pvUser, PAUDIOTESTTONEPARMS pToneParms)
|
---|
972 | {
|
---|
973 | PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser;
|
---|
974 | PAUDIOTESTENV pTstEnv = pCtx->pTstEnv;
|
---|
975 | PAUDIOTESTIOOPTS pIoOpts = &pTstEnv->IoOpts;
|
---|
976 |
|
---|
977 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Got request for playing test tone #%RU32 (%RU16Hz, %RU32ms) ...\n",
|
---|
978 | pToneParms->Hdr.idxSeq, (uint16_t)pToneParms->dbFreqHz, pToneParms->msDuration);
|
---|
979 |
|
---|
980 | char szTimeCreated[RTTIME_STR_LEN];
|
---|
981 | RTTimeToString(&pToneParms->Hdr.tsCreated, szTimeCreated, sizeof(szTimeCreated));
|
---|
982 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test created (caller UTC): %s\n", szTimeCreated);
|
---|
983 |
|
---|
984 | const PAUDIOTESTSTREAM pTstStream = &pTstEnv->aStreams[0]; /** @todo Make this dynamic. */
|
---|
985 |
|
---|
986 | int rc = audioTestStreamInit(pTstEnv->pDrvStack, pTstStream, PDMAUDIODIR_OUT, pIoOpts);
|
---|
987 | if (RT_SUCCESS(rc))
|
---|
988 | {
|
---|
989 | AUDIOTESTPARMS TstParms;
|
---|
990 | RT_ZERO(TstParms);
|
---|
991 | TstParms.enmType = AUDIOTESTTYPE_TESTTONE_PLAY;
|
---|
992 | TstParms.enmDir = PDMAUDIODIR_OUT;
|
---|
993 | TstParms.TestTone = *pToneParms;
|
---|
994 |
|
---|
995 | PAUDIOTESTENTRY pTst;
|
---|
996 | rc = AudioTestSetTestBegin(&pTstEnv->Set, "Playing test tone", &TstParms, &pTst);
|
---|
997 | if (RT_SUCCESS(rc))
|
---|
998 | {
|
---|
999 | rc = audioTestPlayTone(&pTstEnv->IoOpts, pTstEnv, pTstStream, pToneParms);
|
---|
1000 | if (RT_SUCCESS(rc))
|
---|
1001 | {
|
---|
1002 | AudioTestSetTestDone(pTst);
|
---|
1003 | }
|
---|
1004 | else
|
---|
1005 | AudioTestSetTestFailed(pTst, rc, "Playing tone failed");
|
---|
1006 | }
|
---|
1007 |
|
---|
1008 | int rc2 = audioTestStreamDestroy(pTstEnv->pDrvStack, pTstStream);
|
---|
1009 | if (RT_SUCCESS(rc))
|
---|
1010 | rc = rc2;
|
---|
1011 | }
|
---|
1012 | else
|
---|
1013 | RTTestFailed(g_hTest, "Error creating output stream, rc=%Rrc\n", rc);
|
---|
1014 |
|
---|
1015 | return rc;
|
---|
1016 | }
|
---|
1017 |
|
---|
1018 | /** @copydoc ATSCALLBACKS::pfnToneRecord */
|
---|
1019 | static DECLCALLBACK(int) audioTestGstAtsToneRecordCallback(void const *pvUser, PAUDIOTESTTONEPARMS pToneParms)
|
---|
1020 | {
|
---|
1021 | PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser;
|
---|
1022 | PAUDIOTESTENV pTstEnv = pCtx->pTstEnv;
|
---|
1023 | PAUDIOTESTIOOPTS pIoOpts = &pTstEnv->IoOpts;
|
---|
1024 |
|
---|
1025 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Got request for recording test tone #%RU32 (%RU32ms) ...\n",
|
---|
1026 | pToneParms->Hdr.idxSeq, pToneParms->msDuration);
|
---|
1027 |
|
---|
1028 | char szTimeCreated[RTTIME_STR_LEN];
|
---|
1029 | RTTimeToString(&pToneParms->Hdr.tsCreated, szTimeCreated, sizeof(szTimeCreated));
|
---|
1030 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test created (caller UTC): %s\n", szTimeCreated);
|
---|
1031 |
|
---|
1032 | const PAUDIOTESTSTREAM pTstStream = &pTstEnv->aStreams[0]; /** @todo Make this dynamic. */
|
---|
1033 |
|
---|
1034 | int rc = audioTestStreamInit(pTstEnv->pDrvStack, pTstStream, PDMAUDIODIR_IN, pIoOpts);
|
---|
1035 | if (RT_SUCCESS(rc))
|
---|
1036 | {
|
---|
1037 | AUDIOTESTPARMS TstParms;
|
---|
1038 | RT_ZERO(TstParms);
|
---|
1039 | TstParms.enmType = AUDIOTESTTYPE_TESTTONE_RECORD;
|
---|
1040 | TstParms.enmDir = PDMAUDIODIR_IN;
|
---|
1041 | TstParms.TestTone = *pToneParms;
|
---|
1042 |
|
---|
1043 | PAUDIOTESTENTRY pTst;
|
---|
1044 | rc = AudioTestSetTestBegin(&pTstEnv->Set, "Recording test tone from host", &TstParms, &pTst);
|
---|
1045 | if (RT_SUCCESS(rc))
|
---|
1046 | {
|
---|
1047 | rc = audioTestRecordTone(pIoOpts, pTstEnv, pTstStream, pToneParms);
|
---|
1048 | if (RT_SUCCESS(rc))
|
---|
1049 | {
|
---|
1050 | AudioTestSetTestDone(pTst);
|
---|
1051 | }
|
---|
1052 | else
|
---|
1053 | AudioTestSetTestFailed(pTst, rc, "Recording tone failed");
|
---|
1054 | }
|
---|
1055 |
|
---|
1056 | int rc2 = audioTestStreamDestroy(pTstEnv->pDrvStack, pTstStream);
|
---|
1057 | if (RT_SUCCESS(rc))
|
---|
1058 | rc = rc2;
|
---|
1059 | }
|
---|
1060 | else
|
---|
1061 | RTTestFailed(g_hTest, "Error creating input stream, rc=%Rrc\n", rc);
|
---|
1062 |
|
---|
1063 | return rc;
|
---|
1064 | }
|
---|
1065 |
|
---|
1066 | /** @copydoc ATSCALLBACKS::pfnTestSetSendBegin */
|
---|
1067 | static DECLCALLBACK(int) audioTestGstAtsTestSetSendBeginCallback(void const *pvUser, const char *pszTag)
|
---|
1068 | {
|
---|
1069 | RT_NOREF(pszTag);
|
---|
1070 |
|
---|
1071 | PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser;
|
---|
1072 |
|
---|
1073 | if (!RTFileExists(pCtx->szTestSetArchive)) /* Has the archive successfully been created yet? */
|
---|
1074 | return VERR_WRONG_ORDER;
|
---|
1075 |
|
---|
1076 | int rc = RTFileOpen(&pCtx->hTestSetArchive, pCtx->szTestSetArchive, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
|
---|
1077 | if (RT_SUCCESS(rc))
|
---|
1078 | {
|
---|
1079 | uint64_t uSize;
|
---|
1080 | rc = RTFileQuerySize(pCtx->hTestSetArchive, &uSize);
|
---|
1081 | if (RT_SUCCESS(rc))
|
---|
1082 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Sending test set '%s' (%zu bytes)\n", pCtx->szTestSetArchive, uSize);
|
---|
1083 | }
|
---|
1084 |
|
---|
1085 | return rc;
|
---|
1086 | }
|
---|
1087 |
|
---|
1088 | /** @copydoc ATSCALLBACKS::pfnTestSetSendRead */
|
---|
1089 | static DECLCALLBACK(int) audioTestGstAtsTestSetSendReadCallback(void const *pvUser,
|
---|
1090 | const char *pszTag, void *pvBuf, size_t cbBuf, size_t *pcbRead)
|
---|
1091 | {
|
---|
1092 | RT_NOREF(pszTag);
|
---|
1093 |
|
---|
1094 | PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser;
|
---|
1095 |
|
---|
1096 | return RTFileRead(pCtx->hTestSetArchive, pvBuf, cbBuf, pcbRead);
|
---|
1097 | }
|
---|
1098 |
|
---|
1099 | /** @copydoc ATSCALLBACKS::pfnTestSetSendEnd */
|
---|
1100 | static DECLCALLBACK(int) audioTestGstAtsTestSetSendEndCallback(void const *pvUser, const char *pszTag)
|
---|
1101 | {
|
---|
1102 | RT_NOREF(pszTag);
|
---|
1103 |
|
---|
1104 | PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser;
|
---|
1105 |
|
---|
1106 | int rc = RTFileClose(pCtx->hTestSetArchive);
|
---|
1107 | if (RT_SUCCESS(rc))
|
---|
1108 | {
|
---|
1109 | pCtx->hTestSetArchive = NIL_RTFILE;
|
---|
1110 | }
|
---|
1111 |
|
---|
1112 | return rc;
|
---|
1113 | }
|
---|
1114 |
|
---|
1115 |
|
---|
1116 | /*********************************************************************************************************************************
|
---|
1117 | * Implementation of audio test environment handling *
|
---|
1118 | *********************************************************************************************************************************/
|
---|
1119 |
|
---|
1120 | /**
|
---|
1121 | * Connects an ATS client via TCP/IP to a peer.
|
---|
1122 | *
|
---|
1123 | * @returns VBox status code.
|
---|
1124 | * @param pTstEnv Test environment to use.
|
---|
1125 | * @param pClient Client to connect.
|
---|
1126 | * @param pszWhat Hint of what to connect to where.
|
---|
1127 | * @param pTcpOpts Pointer to TCP options to use.
|
---|
1128 | */
|
---|
1129 | int audioTestEnvConnectViaTcp(PAUDIOTESTENV pTstEnv, PATSCLIENT pClient, const char *pszWhat, PAUDIOTESTENVTCPOPTS pTcpOpts)
|
---|
1130 | {
|
---|
1131 | RT_NOREF(pTstEnv);
|
---|
1132 |
|
---|
1133 | RTGETOPTUNION Val;
|
---|
1134 | RT_ZERO(Val);
|
---|
1135 |
|
---|
1136 | Val.u32 = pTcpOpts->enmConnMode;
|
---|
1137 | int rc = AudioTestSvcClientHandleOption(pClient, ATSTCPOPT_CONN_MODE, &Val);
|
---|
1138 | AssertRCReturn(rc, rc);
|
---|
1139 |
|
---|
1140 | if ( pTcpOpts->enmConnMode == ATSCONNMODE_BOTH
|
---|
1141 | || pTcpOpts->enmConnMode == ATSCONNMODE_SERVER)
|
---|
1142 | {
|
---|
1143 | Assert(pTcpOpts->uBindPort); /* Always set by the caller. */
|
---|
1144 | Val.u16 = pTcpOpts->uBindPort;
|
---|
1145 | rc = AudioTestSvcClientHandleOption(pClient, ATSTCPOPT_BIND_PORT, &Val);
|
---|
1146 | AssertRCReturn(rc, rc);
|
---|
1147 |
|
---|
1148 | if (pTcpOpts->szBindAddr[0])
|
---|
1149 | {
|
---|
1150 | Val.psz = pTcpOpts->szBindAddr;
|
---|
1151 | rc = AudioTestSvcClientHandleOption(pClient, ATSTCPOPT_BIND_ADDRESS, &Val);
|
---|
1152 | AssertRCReturn(rc, rc);
|
---|
1153 | }
|
---|
1154 | else
|
---|
1155 | {
|
---|
1156 | RTTestFailed(g_hTest, "No bind address specified!\n");
|
---|
1157 | return VERR_INVALID_PARAMETER;
|
---|
1158 | }
|
---|
1159 |
|
---|
1160 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Connecting %s by listening as server at %s:%RU32 ...\n",
|
---|
1161 | pszWhat, pTcpOpts->szBindAddr, pTcpOpts->uBindPort);
|
---|
1162 | }
|
---|
1163 |
|
---|
1164 |
|
---|
1165 | if ( pTcpOpts->enmConnMode == ATSCONNMODE_BOTH
|
---|
1166 | || pTcpOpts->enmConnMode == ATSCONNMODE_CLIENT)
|
---|
1167 | {
|
---|
1168 | Assert(pTcpOpts->uConnectPort); /* Always set by the caller. */
|
---|
1169 | Val.u16 = pTcpOpts->uConnectPort;
|
---|
1170 | rc = AudioTestSvcClientHandleOption(pClient, ATSTCPOPT_CONNECT_PORT, &Val);
|
---|
1171 | AssertRCReturn(rc, rc);
|
---|
1172 |
|
---|
1173 | if (pTcpOpts->szConnectAddr[0])
|
---|
1174 | {
|
---|
1175 | Val.psz = pTcpOpts->szConnectAddr;
|
---|
1176 | rc = AudioTestSvcClientHandleOption(pClient, ATSTCPOPT_CONNECT_ADDRESS, &Val);
|
---|
1177 | AssertRCReturn(rc, rc);
|
---|
1178 | }
|
---|
1179 | else
|
---|
1180 | {
|
---|
1181 | RTTestFailed(g_hTest, "No connect address specified!\n");
|
---|
1182 | return VERR_INVALID_PARAMETER;
|
---|
1183 | }
|
---|
1184 |
|
---|
1185 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Connecting %s by connecting as client to %s:%RU32 ...\n",
|
---|
1186 | pszWhat, pTcpOpts->szConnectAddr, pTcpOpts->uConnectPort);
|
---|
1187 | }
|
---|
1188 |
|
---|
1189 | rc = AudioTestSvcClientConnect(pClient);
|
---|
1190 | if (RT_FAILURE(rc))
|
---|
1191 | {
|
---|
1192 | RTTestFailed(g_hTest, "Connecting %s failed with %Rrc\n", pszWhat, rc);
|
---|
1193 | return rc;
|
---|
1194 | }
|
---|
1195 |
|
---|
1196 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Successfully connected %s\n", pszWhat);
|
---|
1197 | return rc;
|
---|
1198 | }
|
---|
1199 |
|
---|
1200 | /**
|
---|
1201 | * Configures and starts an ATS TCP/IP server.
|
---|
1202 | *
|
---|
1203 | * @returns VBox status code.
|
---|
1204 | * @param pSrv ATS server instance to configure and start.
|
---|
1205 | * @param pCallbacks ATS callback table to use.
|
---|
1206 | * @param pszDesc Hint of server type which is being started.
|
---|
1207 | * @param pTcpOpts TCP options to use.
|
---|
1208 | */
|
---|
1209 | int audioTestEnvConfigureAndStartTcpServer(PATSSERVER pSrv, PCATSCALLBACKS pCallbacks, const char *pszDesc,
|
---|
1210 | PAUDIOTESTENVTCPOPTS pTcpOpts)
|
---|
1211 | {
|
---|
1212 | RTGETOPTUNION Val;
|
---|
1213 | RT_ZERO(Val);
|
---|
1214 |
|
---|
1215 | int rc = AudioTestSvcInit(pSrv, pCallbacks);
|
---|
1216 | if (RT_FAILURE(rc))
|
---|
1217 | return rc;
|
---|
1218 |
|
---|
1219 | Val.u32 = pTcpOpts->enmConnMode;
|
---|
1220 | rc = AudioTestSvcHandleOption(pSrv, ATSTCPOPT_CONN_MODE, &Val);
|
---|
1221 | AssertRCReturn(rc, rc);
|
---|
1222 |
|
---|
1223 | if ( pTcpOpts->enmConnMode == ATSCONNMODE_BOTH
|
---|
1224 | || pTcpOpts->enmConnMode == ATSCONNMODE_SERVER)
|
---|
1225 | {
|
---|
1226 | Assert(pTcpOpts->uBindPort); /* Always set by the caller. */
|
---|
1227 | Val.u16 = pTcpOpts->uBindPort;
|
---|
1228 | rc = AudioTestSvcHandleOption(pSrv, ATSTCPOPT_BIND_PORT, &Val);
|
---|
1229 | AssertRCReturn(rc, rc);
|
---|
1230 |
|
---|
1231 | if (pTcpOpts->szBindAddr[0])
|
---|
1232 | {
|
---|
1233 | Val.psz = pTcpOpts->szBindAddr;
|
---|
1234 | rc = AudioTestSvcHandleOption(pSrv, ATSTCPOPT_BIND_ADDRESS, &Val);
|
---|
1235 | AssertRCReturn(rc, rc);
|
---|
1236 | }
|
---|
1237 | else
|
---|
1238 | {
|
---|
1239 | RTTestFailed(g_hTest, "No bind address specified!\n");
|
---|
1240 | return VERR_INVALID_PARAMETER;
|
---|
1241 | }
|
---|
1242 |
|
---|
1243 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Starting server for %s at %s:%RU32 ...\n",
|
---|
1244 | pszDesc, pTcpOpts->szBindAddr, pTcpOpts->uBindPort);
|
---|
1245 | }
|
---|
1246 |
|
---|
1247 |
|
---|
1248 | if ( pTcpOpts->enmConnMode == ATSCONNMODE_BOTH
|
---|
1249 | || pTcpOpts->enmConnMode == ATSCONNMODE_CLIENT)
|
---|
1250 | {
|
---|
1251 | Assert(pTcpOpts->uConnectPort); /* Always set by the caller. */
|
---|
1252 | Val.u16 = pTcpOpts->uConnectPort;
|
---|
1253 | rc = AudioTestSvcHandleOption(pSrv, ATSTCPOPT_CONNECT_PORT, &Val);
|
---|
1254 | AssertRCReturn(rc, rc);
|
---|
1255 |
|
---|
1256 | if (pTcpOpts->szConnectAddr[0])
|
---|
1257 | {
|
---|
1258 | Val.psz = pTcpOpts->szConnectAddr;
|
---|
1259 | rc = AudioTestSvcHandleOption(pSrv, ATSTCPOPT_CONNECT_ADDRESS, &Val);
|
---|
1260 | AssertRCReturn(rc, rc);
|
---|
1261 | }
|
---|
1262 | else
|
---|
1263 | {
|
---|
1264 | RTTestFailed(g_hTest, "No connect address specified!\n");
|
---|
1265 | return VERR_INVALID_PARAMETER;
|
---|
1266 | }
|
---|
1267 |
|
---|
1268 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Starting server for %s by connecting as client to %s:%RU32 ...\n",
|
---|
1269 | pszDesc, pTcpOpts->szConnectAddr, pTcpOpts->uConnectPort);
|
---|
1270 | }
|
---|
1271 |
|
---|
1272 | if (RT_SUCCESS(rc))
|
---|
1273 | {
|
---|
1274 | rc = AudioTestSvcStart(pSrv);
|
---|
1275 | if (RT_FAILURE(rc))
|
---|
1276 | RTTestFailed(g_hTest, "Starting server for %s failed with %Rrc\n", pszDesc, rc);
|
---|
1277 | }
|
---|
1278 |
|
---|
1279 | return rc;
|
---|
1280 | }
|
---|
1281 |
|
---|
1282 | /**
|
---|
1283 | * Initializes an audio test environment.
|
---|
1284 | *
|
---|
1285 | * @param pTstEnv Audio test environment to initialize.
|
---|
1286 | */
|
---|
1287 | void audioTestEnvInit(PAUDIOTESTENV pTstEnv)
|
---|
1288 | {
|
---|
1289 | RT_BZERO(pTstEnv, sizeof(AUDIOTESTENV));
|
---|
1290 |
|
---|
1291 | audioTestIoOptsInitDefaults(&pTstEnv->IoOpts);
|
---|
1292 | audioTestToneParmsInit(&pTstEnv->ToneParms);
|
---|
1293 | }
|
---|
1294 |
|
---|
1295 | /**
|
---|
1296 | * Creates an audio test environment.
|
---|
1297 | *
|
---|
1298 | * @returns VBox status code.
|
---|
1299 | * @param pTstEnv Audio test environment to create.
|
---|
1300 | * @param pDrvStack Driver stack to use.
|
---|
1301 | */
|
---|
1302 | int audioTestEnvCreate(PAUDIOTESTENV pTstEnv, PAUDIOTESTDRVSTACK pDrvStack)
|
---|
1303 | {
|
---|
1304 | AssertReturn(PDMAudioPropsAreValid(&pTstEnv->IoOpts.Props), VERR_WRONG_ORDER);
|
---|
1305 |
|
---|
1306 | int rc = VINF_SUCCESS;
|
---|
1307 |
|
---|
1308 | pTstEnv->pDrvStack = pDrvStack;
|
---|
1309 |
|
---|
1310 | /*
|
---|
1311 | * Set sane defaults if not already set.
|
---|
1312 | */
|
---|
1313 | if (!RTStrNLen(pTstEnv->szTag, sizeof(pTstEnv->szTag)))
|
---|
1314 | {
|
---|
1315 | rc = AudioTestGenTag(pTstEnv->szTag, sizeof(pTstEnv->szTag));
|
---|
1316 | AssertRCReturn(rc, rc);
|
---|
1317 | }
|
---|
1318 |
|
---|
1319 | if (!RTStrNLen(pTstEnv->szPathTemp, sizeof(pTstEnv->szPathTemp)))
|
---|
1320 | {
|
---|
1321 | rc = AudioTestPathGetTemp(pTstEnv->szPathTemp, sizeof(pTstEnv->szPathTemp));
|
---|
1322 | AssertRCReturn(rc, rc);
|
---|
1323 | }
|
---|
1324 |
|
---|
1325 | if (!RTStrNLen(pTstEnv->szPathOut, sizeof(pTstEnv->szPathOut)))
|
---|
1326 | {
|
---|
1327 | rc = RTPathJoin(pTstEnv->szPathOut, sizeof(pTstEnv->szPathOut), pTstEnv->szPathTemp, "vkat-temp");
|
---|
1328 | AssertRCReturn(rc, rc);
|
---|
1329 | }
|
---|
1330 |
|
---|
1331 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Initializing environment for mode '%s'\n", pTstEnv->enmMode == AUDIOTESTMODE_HOST ? "host" : "guest");
|
---|
1332 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Using tag '%s'\n", pTstEnv->szTag);
|
---|
1333 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Output directory is '%s'\n", pTstEnv->szPathOut);
|
---|
1334 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Temp directory is '%s'\n", pTstEnv->szPathTemp);
|
---|
1335 |
|
---|
1336 | char szPathTemp[RTPATH_MAX];
|
---|
1337 | if ( !strlen(pTstEnv->szPathTemp)
|
---|
1338 | || !strlen(pTstEnv->szPathOut))
|
---|
1339 | rc = RTPathTemp(szPathTemp, sizeof(szPathTemp));
|
---|
1340 |
|
---|
1341 | if ( RT_SUCCESS(rc)
|
---|
1342 | && !strlen(pTstEnv->szPathTemp))
|
---|
1343 | rc = RTPathJoin(pTstEnv->szPathTemp, sizeof(pTstEnv->szPathTemp), szPathTemp, "vkat-temp");
|
---|
1344 |
|
---|
1345 | if (RT_SUCCESS(rc))
|
---|
1346 | {
|
---|
1347 | rc = RTDirCreate(pTstEnv->szPathTemp, RTFS_UNIX_IRWXU, 0 /* fFlags */);
|
---|
1348 | if (rc == VERR_ALREADY_EXISTS)
|
---|
1349 | rc = VINF_SUCCESS;
|
---|
1350 | }
|
---|
1351 |
|
---|
1352 | if ( RT_SUCCESS(rc)
|
---|
1353 | && !strlen(pTstEnv->szPathOut))
|
---|
1354 | rc = RTPathJoin(pTstEnv->szPathOut, sizeof(pTstEnv->szPathOut), szPathTemp, "vkat");
|
---|
1355 |
|
---|
1356 | if (RT_SUCCESS(rc))
|
---|
1357 | {
|
---|
1358 | rc = RTDirCreate(pTstEnv->szPathOut, RTFS_UNIX_IRWXU, 0 /* fFlags */);
|
---|
1359 | if (rc == VERR_ALREADY_EXISTS)
|
---|
1360 | rc = VINF_SUCCESS;
|
---|
1361 | }
|
---|
1362 |
|
---|
1363 | if (RT_FAILURE(rc))
|
---|
1364 | return rc;
|
---|
1365 |
|
---|
1366 | /**
|
---|
1367 | * For NAT'ed VMs we use (default):
|
---|
1368 | * - client mode (uConnectAddr / uConnectPort) on the guest.
|
---|
1369 | * - server mode (uBindAddr / uBindPort) on the host.
|
---|
1370 | */
|
---|
1371 | if ( !pTstEnv->TcpOpts.szConnectAddr[0]
|
---|
1372 | && !pTstEnv->TcpOpts.szBindAddr[0])
|
---|
1373 | RTStrCopy(pTstEnv->TcpOpts.szBindAddr, sizeof(pTstEnv->TcpOpts.szBindAddr), "0.0.0.0");
|
---|
1374 |
|
---|
1375 | /*
|
---|
1376 | * Determine connection mode based on set variables.
|
---|
1377 | */
|
---|
1378 | if ( pTstEnv->TcpOpts.szBindAddr[0]
|
---|
1379 | && pTstEnv->TcpOpts.szConnectAddr[0])
|
---|
1380 | {
|
---|
1381 | pTstEnv->TcpOpts.enmConnMode = ATSCONNMODE_BOTH;
|
---|
1382 | }
|
---|
1383 | else if (pTstEnv->TcpOpts.szBindAddr[0])
|
---|
1384 | pTstEnv->TcpOpts.enmConnMode = ATSCONNMODE_SERVER;
|
---|
1385 | else /* "Reversed mode", i.e. used for NATed VMs. */
|
---|
1386 | pTstEnv->TcpOpts.enmConnMode = ATSCONNMODE_CLIENT;
|
---|
1387 |
|
---|
1388 | /* Set a back reference to the test environment for the callback context. */
|
---|
1389 | pTstEnv->CallbackCtx.pTstEnv = pTstEnv;
|
---|
1390 |
|
---|
1391 | ATSCALLBACKS Callbacks;
|
---|
1392 | RT_ZERO(Callbacks);
|
---|
1393 | Callbacks.pvUser = &pTstEnv->CallbackCtx;
|
---|
1394 |
|
---|
1395 | if (pTstEnv->enmMode == AUDIOTESTMODE_GUEST)
|
---|
1396 | {
|
---|
1397 | Callbacks.pfnHowdy = audioTestGstAtsHowdyCallback;
|
---|
1398 | Callbacks.pfnBye = audioTestGstAtsByeCallback;
|
---|
1399 | Callbacks.pfnTestSetBegin = audioTestGstAtsTestSetBeginCallback;
|
---|
1400 | Callbacks.pfnTestSetEnd = audioTestGstAtsTestSetEndCallback;
|
---|
1401 | Callbacks.pfnTonePlay = audioTestGstAtsTonePlayCallback;
|
---|
1402 | Callbacks.pfnToneRecord = audioTestGstAtsToneRecordCallback;
|
---|
1403 | Callbacks.pfnTestSetSendBegin = audioTestGstAtsTestSetSendBeginCallback;
|
---|
1404 | Callbacks.pfnTestSetSendRead = audioTestGstAtsTestSetSendReadCallback;
|
---|
1405 | Callbacks.pfnTestSetSendEnd = audioTestGstAtsTestSetSendEndCallback;
|
---|
1406 |
|
---|
1407 | if (!pTstEnv->TcpOpts.uBindPort)
|
---|
1408 | pTstEnv->TcpOpts.uBindPort = ATS_TCP_DEF_BIND_PORT_GUEST;
|
---|
1409 |
|
---|
1410 | if (!pTstEnv->TcpOpts.uConnectPort)
|
---|
1411 | pTstEnv->TcpOpts.uConnectPort = ATS_TCP_DEF_CONNECT_PORT_GUEST;
|
---|
1412 |
|
---|
1413 | pTstEnv->pSrv = (PATSSERVER)RTMemAlloc(sizeof(ATSSERVER));
|
---|
1414 | AssertPtrReturn(pTstEnv->pSrv, VERR_NO_MEMORY);
|
---|
1415 |
|
---|
1416 | /*
|
---|
1417 | * Start the ATS (Audio Test Service) on the guest side.
|
---|
1418 | * That service then will perform playback and recording operations on the guest, triggered from the host.
|
---|
1419 | *
|
---|
1420 | * When running this in self-test mode, that service also can be run on the host if nothing else is specified.
|
---|
1421 | * Note that we have to bind to "0.0.0.0" by default so that the host can connect to it.
|
---|
1422 | */
|
---|
1423 | rc = audioTestEnvConfigureAndStartTcpServer(pTstEnv->pSrv, &Callbacks, "guest", &pTstEnv->TcpOpts);
|
---|
1424 | }
|
---|
1425 | else /* Host mode */
|
---|
1426 | {
|
---|
1427 | if (!pTstEnv->TcpOpts.uBindPort)
|
---|
1428 | pTstEnv->TcpOpts.uBindPort = ATS_TCP_DEF_BIND_PORT_HOST;
|
---|
1429 |
|
---|
1430 | if (!pTstEnv->TcpOpts.uConnectPort)
|
---|
1431 | pTstEnv->TcpOpts.uConnectPort = ATS_TCP_DEF_CONNECT_PORT_HOST_PORT_FWD;
|
---|
1432 |
|
---|
1433 | /**
|
---|
1434 | * Note: Don't set pTstEnv->TcpOpts.szTcpConnectAddr by default here, as this specifies what connection mode
|
---|
1435 | * (client / server / both) we use on the host.
|
---|
1436 | */
|
---|
1437 |
|
---|
1438 | /* We need to start a server on the host so that VMs configured with NAT networking
|
---|
1439 | * can connect to it as well. */
|
---|
1440 | rc = AudioTestSvcClientCreate(&pTstEnv->u.Host.AtsClGuest);
|
---|
1441 | if (RT_SUCCESS(rc))
|
---|
1442 | rc = audioTestEnvConnectViaTcp(pTstEnv, &pTstEnv->u.Host.AtsClGuest,
|
---|
1443 | "host -> guest", &pTstEnv->TcpOpts);
|
---|
1444 | if (RT_SUCCESS(rc))
|
---|
1445 | {
|
---|
1446 | AUDIOTESTENVTCPOPTS ValKitTcpOpts;
|
---|
1447 | RT_ZERO(ValKitTcpOpts);
|
---|
1448 |
|
---|
1449 | /* We only connect as client to the Validation Kit audio driver ATS. */
|
---|
1450 | ValKitTcpOpts.enmConnMode = ATSCONNMODE_CLIENT;
|
---|
1451 |
|
---|
1452 | /* For now we ASSUME that the Validation Kit audio driver ATS runs on the same host as VKAT (this binary) runs on. */
|
---|
1453 | ValKitTcpOpts.uConnectPort = ATS_TCP_DEF_CONNECT_PORT_VALKIT; /** @todo Make this dynamic. */
|
---|
1454 | RTStrCopy(ValKitTcpOpts.szConnectAddr, sizeof(ValKitTcpOpts.szConnectAddr), ATS_TCP_DEF_CONNECT_HOST_ADDR_STR); /** @todo Ditto. */
|
---|
1455 |
|
---|
1456 | rc = AudioTestSvcClientCreate(&pTstEnv->u.Host.AtsClValKit);
|
---|
1457 | if (RT_SUCCESS(rc))
|
---|
1458 | {
|
---|
1459 | rc = audioTestEnvConnectViaTcp(pTstEnv, &pTstEnv->u.Host.AtsClValKit,
|
---|
1460 | "host -> valkit", &ValKitTcpOpts);
|
---|
1461 | if (RT_FAILURE(rc))
|
---|
1462 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Unable to connect to the Validation Kit audio driver!\n"
|
---|
1463 | "There could be multiple reasons:\n\n"
|
---|
1464 | " - Wrong host being used\n"
|
---|
1465 | " - VirtualBox host version is too old\n"
|
---|
1466 | " - Audio debug mode is not enabled\n"
|
---|
1467 | " - Support for Validation Kit audio driver is not included\n"
|
---|
1468 | " - Firewall / network configuration problem\n");
|
---|
1469 | }
|
---|
1470 | }
|
---|
1471 | }
|
---|
1472 |
|
---|
1473 | return rc;
|
---|
1474 | }
|
---|
1475 |
|
---|
1476 | /**
|
---|
1477 | * Destroys an audio test environment.
|
---|
1478 | *
|
---|
1479 | * @param pTstEnv Audio test environment to destroy.
|
---|
1480 | */
|
---|
1481 | void audioTestEnvDestroy(PAUDIOTESTENV pTstEnv)
|
---|
1482 | {
|
---|
1483 | if (!pTstEnv)
|
---|
1484 | return;
|
---|
1485 |
|
---|
1486 | /* When in host mode, we need to destroy our ATS clients in order to also let
|
---|
1487 | * the ATS server(s) know we're going to quit. */
|
---|
1488 | if (pTstEnv->enmMode == AUDIOTESTMODE_HOST)
|
---|
1489 | {
|
---|
1490 | AudioTestSvcClientDestroy(&pTstEnv->u.Host.AtsClValKit);
|
---|
1491 | AudioTestSvcClientDestroy(&pTstEnv->u.Host.AtsClGuest);
|
---|
1492 | }
|
---|
1493 |
|
---|
1494 | if (pTstEnv->pSrv)
|
---|
1495 | {
|
---|
1496 | int rc2 = AudioTestSvcDestroy(pTstEnv->pSrv);
|
---|
1497 | AssertRC(rc2);
|
---|
1498 |
|
---|
1499 | RTMemFree(pTstEnv->pSrv);
|
---|
1500 | pTstEnv->pSrv = NULL;
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 | for (unsigned i = 0; i < RT_ELEMENTS(pTstEnv->aStreams); i++)
|
---|
1504 | {
|
---|
1505 | int rc2 = audioTestStreamDestroy(pTstEnv->pDrvStack, &pTstEnv->aStreams[i]);
|
---|
1506 | if (RT_FAILURE(rc2))
|
---|
1507 | RTTestFailed(g_hTest, "Stream destruction for stream #%u failed with %Rrc\n", i, rc2);
|
---|
1508 | }
|
---|
1509 |
|
---|
1510 | /* Try cleaning up a bit. */
|
---|
1511 | RTDirRemove(pTstEnv->szPathTemp);
|
---|
1512 | RTDirRemove(pTstEnv->szPathOut);
|
---|
1513 |
|
---|
1514 | pTstEnv->pDrvStack = NULL;
|
---|
1515 | }
|
---|
1516 |
|
---|
1517 | /**
|
---|
1518 | * Closes, packs up and destroys a test environment.
|
---|
1519 | *
|
---|
1520 | * @returns VBox status code.
|
---|
1521 | * @param pTstEnv Test environment to handle.
|
---|
1522 | * @param fPack Whether to pack the test set up before destroying / wiping it.
|
---|
1523 | * @param pszPackFile Where to store the packed test set file on success. Can be NULL if \a fPack is \c false.
|
---|
1524 | * @param cbPackFile Size (in bytes) of \a pszPackFile. Can be 0 if \a fPack is \c false.
|
---|
1525 | */
|
---|
1526 | int audioTestEnvPrologue(PAUDIOTESTENV pTstEnv, bool fPack, char *pszPackFile, size_t cbPackFile)
|
---|
1527 | {
|
---|
1528 | /* Close the test set first. */
|
---|
1529 | AudioTestSetClose(&pTstEnv->Set);
|
---|
1530 |
|
---|
1531 | int rc = VINF_SUCCESS;
|
---|
1532 |
|
---|
1533 | if (fPack)
|
---|
1534 | {
|
---|
1535 | /* Before destroying the test environment, pack up the test set so
|
---|
1536 | * that it's ready for transmission. */
|
---|
1537 | rc = AudioTestSetPack(&pTstEnv->Set, pTstEnv->szPathOut, pszPackFile, cbPackFile);
|
---|
1538 | if (RT_SUCCESS(rc))
|
---|
1539 | RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test set packed up to '%s'\n", pszPackFile);
|
---|
1540 | }
|
---|
1541 |
|
---|
1542 | if (!g_fDrvAudioDebug) /* Don't wipe stuff when debugging. Can be useful for introspecting data. */
|
---|
1543 | /* ignore rc */ AudioTestSetWipe(&pTstEnv->Set);
|
---|
1544 |
|
---|
1545 | AudioTestSetDestroy(&pTstEnv->Set);
|
---|
1546 |
|
---|
1547 | if (RT_FAILURE(rc))
|
---|
1548 | RTTestFailed(g_hTest, "Test set prologue failed with %Rrc\n", rc);
|
---|
1549 |
|
---|
1550 | return rc;
|
---|
1551 | }
|
---|
1552 |
|
---|
1553 | /**
|
---|
1554 | * Initializes an audio test parameters set.
|
---|
1555 | *
|
---|
1556 | * @param pTstParms Test parameters set to initialize.
|
---|
1557 | */
|
---|
1558 | void audioTestParmsInit(PAUDIOTESTPARMS pTstParms)
|
---|
1559 | {
|
---|
1560 | RT_ZERO(*pTstParms);
|
---|
1561 | }
|
---|
1562 |
|
---|
1563 | /**
|
---|
1564 | * Destroys an audio test parameters set.
|
---|
1565 | *
|
---|
1566 | * @param pTstParms Test parameters set to destroy.
|
---|
1567 | */
|
---|
1568 | void audioTestParmsDestroy(PAUDIOTESTPARMS pTstParms)
|
---|
1569 | {
|
---|
1570 | if (!pTstParms)
|
---|
1571 | return;
|
---|
1572 |
|
---|
1573 | return;
|
---|
1574 | }
|
---|
1575 |
|
---|