- Timestamp:
- May 10, 2021 11:28:35 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r88959 r88960 40 40 41 41 #include <VBox/vmm/pdmaudioinline.h> 42 #include <VBox/vmm/pdmaudiohostenuminline.h> 42 43 43 44 #include "../../../Devices/Audio/AudioHlp.h" … … 65 66 /** How many iterations the test should be executed. */ 66 67 uint32_t cIterations; 67 /** Name or path of audio device to use, depending on the OS. 68 * If NULL, the default device for this specific test (input / output) will be used. */ 69 char *pszDevice; 68 /** Audio device to use. */ 69 PDMAUDIOHOSTDEV Dev; 70 70 /** Absolute path where to store the test audio data. 71 71 * If NULL, no test audio data will be written. */ … … 113 113 typedef struct AUDIOTESTENV 114 114 { 115 PPDMIHOSTAUDIO pDrvAudio; 115 /** The host (backend) driver to use. */ 116 PPDMIHOSTAUDIO pDrvAudio; 117 /** The current (last) audio device enumeration to use. */ 118 PDMAUDIOHOSTENUM DevEnm; 116 119 } AUDIOTESTENV; 117 120 /** Pointer a audio test environment. */ … … 208 211 // PDMAudioPropsInit(&Props, 16 /* bit */ / 8, true /* fSigned */, 2 /* Channels */, 44100 /* Hz */); 209 212 210 //AudioTestToneParamsInitRandom(&pT estParms->ToneParms, &pTestParms->ToneParms.Props);213 //AudioTestToneParamsInitRandom(&pTstParms->ToneParms, &pTstParms->ToneParms.Props); 211 214 212 215 return VINF_SUCCESS; … … 232 235 *********************************************************************************************************************************/ 233 236 234 static void audioTestParmsInit(PAUDIOTESTPARMS pTestParms) 235 { 236 RT_BZERO(pTestParms, sizeof(AUDIOTESTPARMS)); 237 static void audioTestEnvInit(PAUDIOTESTENV pTstEnv, PPDMIHOSTAUDIO pDrvAudio) 238 { 239 RT_BZERO(pTstEnv, sizeof(AUDIOTESTENV)); 240 241 pTstEnv->pDrvAudio = pDrvAudio; 242 PDMAudioHostEnumInit(&pTstEnv->DevEnm); 243 237 244 return; 238 245 } 239 246 240 static void audioTest ParmsDestroy(PAUDIOTESTPARMS pTestParms)241 { 242 if (!pT estParms)247 static void audioTestEnvDestroy(PAUDIOTESTENV pTstEnv) 248 { 249 if (!pTstEnv) 243 250 return; 244 251 245 RTStrFree(pTestParms->pszDevice); 246 pTestParms->pszDevice = NULL; 247 248 RTStrFree(pTestParms->pszPathOutAbs); 249 pTestParms->pszPathOutAbs = NULL; 252 PDMAudioHostEnumDelete(&pTstEnv->DevEnm); 253 } 254 255 static void audioTestParmsInit(PAUDIOTESTPARMS pTstParms) 256 { 257 RT_BZERO(pTstParms, sizeof(AUDIOTESTPARMS)); 258 return; 259 } 260 261 static void audioTestParmsDestroy(PAUDIOTESTPARMS pTstParms) 262 { 263 if (!pTstParms) 264 return; 265 266 RTStrFree(pTstParms->pszPathOutAbs); 267 pTstParms->pszPathOutAbs = NULL; 250 268 251 269 return; … … 340 358 } 341 359 342 /** 343 * Searches for the default audio test device and return the device path. 344 * 345 * @returns Path to the device audio device or NULL if none was found. 346 */ 347 static char *audioTestDeviceFindDefault(void) 348 { 349 /** @todo Implement finding default device. */ 350 return NULL; 351 } 352 353 static int audioTestDeviceOpen(const char *pszDevice) 360 static int audioTestDevicesEnumerateAndCheck(PAUDIOTESTENV pTstEnv, const char *pszDev, PPDMAUDIOHOSTDEV *ppDev) 361 { 362 RTTestSubF(g_hTest, "Enumerating audio devices and checking for device '%s'", pszDev ? pszDev : "<Default>"); 363 364 if (!pTstEnv->pDrvAudio->pfnGetDevices) 365 { 366 RTTestSkipped(g_hTest, "Backend does not support device enumeration, skipping"); 367 return VINF_NOT_SUPPORTED; 368 } 369 370 Assert(pszDev == NULL || ppDev); 371 372 if (ppDev) 373 *ppDev = NULL; 374 375 int rc = pTstEnv->pDrvAudio->pfnGetDevices(pTstEnv->pDrvAudio, &pTstEnv->DevEnm); 376 if (RT_SUCCESS(rc)) 377 { 378 PPDMAUDIOHOSTDEV pDev; 379 RTListForEach(&pTstEnv->DevEnm.LstDevices, pDev, PDMAUDIOHOSTDEV, ListEntry) 380 { 381 char szFlags[PDMAUDIOHOSTDEV_MAX_FLAGS_STRING_LEN]; 382 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enum: Device '%s':\n", pDev->szName); 383 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enum: Usage = %s\n", PDMAudioDirGetName(pDev->enmUsage)); 384 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enum: Flags = %s\n", PDMAudioHostDevFlagsToString(szFlags, pDev->fFlags)); 385 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enum: Input channels = %RU8\n", pDev->cMaxInputChannels); 386 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Enum: Output channels = %RU8\n", pDev->cMaxOutputChannels); 387 388 if ( pszDev 389 && !RTStrCmp(pDev->szName, pszDev)) 390 { 391 *ppDev = pDev; 392 } 393 } 394 } 395 else 396 RTTestFailed(g_hTest, "Enumerating audio devices failed with %Rrc", rc); 397 398 RTTestSubDone(g_hTest); 399 400 if ( pszDev 401 && *ppDev == NULL) 402 { 403 RTTestFailed(g_hTest, "Audio device '%s' not found", pszDev); 404 return VERR_NOT_FOUND; 405 } 406 407 return VINF_SUCCESS; 408 } 409 410 static int audioTestDeviceOpen(PPDMAUDIOHOSTDEV pDev) 354 411 { 355 412 int rc = VINF_SUCCESS; 356 413 357 RTTestSubF(g_hTest, "Opening audio device '%s' ...", pszDevice ? "<Default>>" : pszDevice); 358 359 if (!pszDevice) 360 audioTestDeviceFindDefault(); 414 RTTestSubF(g_hTest, "Opening audio device '%s' ...", pDev->szName); 361 415 362 416 /** @todo Detect + open device here. */ 417 418 RTTestSubDone(g_hTest); 419 420 return rc; 421 } 422 423 static int audioTestDeviceClose(PPDMAUDIOHOSTDEV pDev) 424 { 425 int rc = VINF_SUCCESS; 426 427 RTTestSubF(g_hTest, "Closing audio device '%s' ...", pDev->szName); 428 429 /** @todo Close device here. */ 363 430 364 431 RTTestSubDone(g_hTest); … … 376 443 unsigned uSeq, PAUDIOTESTPARMS pOverrideParms) 377 444 { 445 RT_NOREF(uSeq); 446 378 447 int rc; 379 448 … … 400 469 audioTestCombineParms(&TstParms, pOverrideParms); 401 470 402 /* Open the device on the first test being run. */ 403 if ( uSeq == 0 404 && TstParms.pszDevice 405 && strlen(TstParms.pszDevice)) 406 { 407 rc = audioTestDeviceOpen(TstParms.pszDevice); 408 if (RT_FAILURE(rc)) 409 RTTestFailed(g_hTest, "Unable to find audio device '%s'", TstParms.pszDevice); 410 } 471 if (strlen(TstParms.Dev.szName)) /** @todo Refine this check. */ 472 rc = audioTestDeviceOpen(&TstParms.Dev); 411 473 412 474 AssertPtr(pTstDesc->pfnExec); … … 422 484 } 423 485 486 rc = audioTestDeviceClose(&TstParms.Dev); 487 424 488 audioTestParmsDestroy(&TstParms); 425 489 … … 451 515 AUDIOTESTPARMS TstCust; 452 516 audioTestParmsInit(&TstCust); 517 518 char *pszDevice = NULL; /* Custom device to use. Can be NULL if not being used. */ 453 519 454 520 RT_ZERO(g_DrvIns); … … 539 605 case VKAT_TEST_OPT_DEV: 540 606 { 541 TstCust.pszDevice = RTStrDup(ValueUnion.psz);607 pszDevice = RTStrDup(ValueUnion.psz); 542 608 break; 543 609 } … … 611 677 { 612 678 /* For now all tests have the same test environment. */ 613 AUDIOTESTENV TestEnv; 614 TestEnv.pDrvAudio = pDrvAudio; 615 616 audioTestWorker(&TestEnv, &TstCust); 617 679 AUDIOTESTENV TstEnv; 680 audioTestEnvInit(&TstEnv, pDrvAudio); 681 682 PPDMAUDIOHOSTDEV pDev; 683 rc = audioTestDevicesEnumerateAndCheck(&TstEnv, pszDevice, &pDev); 684 if (RT_SUCCESS(rc)) 685 audioTestWorker(&TstEnv, &TstCust); 686 687 audioTestEnvDestroy(&TstEnv); 618 688 audioTestDrvDestruct(pDrvReg, &g_DrvIns); 619 689 } 620 690 621 691 audioTestParmsDestroy(&TstCust); 692 693 RTStrFree(pszDevice); 622 694 623 695 /*
Note:
See TracChangeset
for help on using the changeset viewer.