Changeset 92396 in vbox for trunk/src/VBox/ValidationKit/utils
- Timestamp:
- Nov 12, 2021 11:46:06 AM (3 years ago)
- Location:
- trunk/src/VBox/ValidationKit/utils/audio
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r92382 r92396 282 282 pTstParmsAcq->enmType = AUDIOTESTTYPE_TESTTONE_PLAY; 283 283 pTstParmsAcq->enmDir = PDMAUDIODIR_OUT; 284 pTstParmsAcq->cIterations = pTstEnv->cIterations == 0 ? RTRandU32Ex(1, 10) : pTstEnv->cIterations;285 pTstParmsAcq->idxCurrent = 0;286 284 287 285 pTstParmsAcq->TestTone = pTstEnv->ToneParms; 288 286 287 pTstParmsAcq->TestTone.Hdr.idxTest = pTstEnv->idxTest; /* Assign unique test ID. */ 288 289 289 return rc; 290 290 } … … 299 299 int rc = VINF_SUCCESS; 300 300 301 for (uint32_t i = 0; i < pTstParms->cIterations; i++) 302 { 303 PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone; 304 305 pToneParms->Hdr.idxSeq = i; 306 RTTIMESPEC NowTimeSpec; 307 RTTimeExplode(&pToneParms->Hdr.tsCreated, RTTimeNow(&NowTimeSpec)); 308 309 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32 (%RU32/%RU32): Playing test tone (%RU16Hz, %RU32ms)\n", 310 pTstParms->idxCurrent, i + 1, pTstParms->cIterations, (uint16_t)pToneParms->dbFreqHz, pToneParms->msDuration); 301 PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone; 302 303 uint32_t const idxTest = pToneParms->Hdr.idxTest; 304 305 RTTIMESPEC NowTimeSpec; 306 RTTimeExplode(&pToneParms->Hdr.tsCreated, RTTimeNow(&NowTimeSpec)); 307 308 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Playing test tone (%RU16Hz, %RU32ms)\n", 309 idxTest, (uint16_t)pToneParms->dbFreqHz, pToneParms->msDuration); 310 311 /* 312 * 1. Arm the (host) ValKit ATS with the recording parameters. 313 */ 314 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, 315 "Test #%RU32: Telling ValKit audio driver on host to record new tone ...\n", idxTest); 316 317 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClValKit, pToneParms); 318 if (RT_SUCCESS(rc)) 319 { 320 /* Give the Validaiton Kit audio driver on the host a bit of time to register / arming the new test. */ 321 RTThreadSleep(5000); /* Fudge factor. */ 311 322 312 323 /* 313 * 1. Arm the (host) ValKit ATS with the recording parameters.324 * 2. Tell VKAT on guest to start playback. 314 325 */ 315 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Telling ValKit audio driver on host to record new tone ...\n"); 316 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClValKit, pToneParms); 317 if (RT_SUCCESS(rc)) 318 { 319 /* Give the Validaiton Kit audio driver on the host a bit of time to register / arming the new test. */ 320 RTThreadSleep(5000); /* Fudge factor. */ 321 322 /* 323 * 2. Tell VKAT on guest to start playback. 324 */ 325 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Telling VKAT on guest to play tone ...\n"); 326 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClGuest, pToneParms); 327 if (RT_FAILURE(rc)) 328 RTTestFailed(g_hTest, "Test #%RU32 (%RU32/%RU32): AudioTestSvcClientTonePlay() failed with %Rrc\n", 329 pTstParms->idxCurrent, i + 1, pTstParms->cIterations, rc); 330 } 331 else 332 RTTestFailed(g_hTest, "Test #%RU32 (%RU32/%RU32): AudioTestSvcClientToneRecord() failed with %Rrc\n", 333 pTstParms->idxCurrent, i + 1, pTstParms->cIterations, rc); 334 335 if (RT_SUCCESS(rc)) 336 { 337 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Playing tone done\n"); 338 339 /* Give the audio stack a random amount of time for draining data before the next iteration. */ 340 if (pTstParms->cIterations > 1) 341 RTThreadSleep(RTRandU32Ex(2000, 5000)); /** @todo Implement some dedicated ATS command for this? */ 342 } 343 326 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Telling VKAT on guest to play tone ...\n", idxTest); 327 328 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClGuest, pToneParms); 344 329 if (RT_FAILURE(rc)) 345 { 346 RTTestFailed(g_hTest, "Test #%RU32 (%RU32/%RU32): Playing test tone failed with %Rrc\n", 347 pTstParms->idxCurrent, i + 1, pTstParms->cIterations, rc); 348 break; /* Not worth retrying, bail out. */ 349 } 350 } 330 RTTestFailed(g_hTest, "Test #%RU32: AudioTestSvcClientTonePlay() failed with %Rrc\n", idxTest, rc); 331 } 332 else 333 RTTestFailed(g_hTest, "Test #%RU32: AudioTestSvcClientToneRecord() failed with %Rrc\n", idxTest, rc); 334 335 if (RT_SUCCESS(rc)) 336 { 337 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Playing tone done\n", idxTest); 338 339 /* Give the audio stack a random amount of time for draining data before the next iteration. */ 340 if (pTstEnv->cIterations > 1) 341 RTThreadSleep(RTRandU32Ex(2000, 5000)); /** @todo Implement some dedicated ATS command for this? */ 342 } 343 344 if (RT_FAILURE(rc)) 345 RTTestFailed(g_hTest, "Test #%RU32: Playing test tone failed with %Rrc\n", idxTest, rc); 351 346 352 347 return rc; … … 381 376 pTstParmsAcq->enmType = AUDIOTESTTYPE_TESTTONE_RECORD; 382 377 pTstParmsAcq->enmDir = PDMAUDIODIR_IN; 383 pTstParmsAcq->cIterations = pTstEnv->cIterations == 0 ? RTRandU32Ex(1, 10) : pTstEnv->cIterations;384 pTstParmsAcq->idxCurrent = 0;385 378 386 379 pTstParmsAcq->TestTone = pTstEnv->ToneParms; 387 380 381 pTstParmsAcq->TestTone.Hdr.idxTest = pTstEnv->idxTest; /* Assign unique test ID. */ 382 388 383 return rc; 389 384 } … … 398 393 int rc = VINF_SUCCESS; 399 394 400 for (uint32_t i = 0; i < pTstParms->cIterations; i++) 401 { 402 PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone; 403 404 pToneParms->Hdr.idxSeq = i; 405 RTTIMESPEC NowTimeSpec; 406 RTTimeExplode(&pToneParms->Hdr.tsCreated, RTTimeNow(&NowTimeSpec)); 407 408 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32 (%RU32/%RU32): Recording test tone (%RU16Hz, %RU32ms)\n", 409 pTstParms->idxCurrent, i + 1, pTstParms->cIterations, (uint16_t)pToneParms->dbFreqHz, pToneParms->msDuration); 410 395 PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone; 396 397 uint32_t const idxTest = pToneParms->Hdr.idxTest; 398 399 RTTIMESPEC NowTimeSpec; 400 RTTimeExplode(&pToneParms->Hdr.tsCreated, RTTimeNow(&NowTimeSpec)); 401 402 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Recording test tone (%RU16Hz, %RU32ms)\n", 403 idxTest, (uint16_t)pToneParms->dbFreqHz, pToneParms->msDuration); 404 405 /* 406 * 1. Arm the (host) ValKit ATS with the playback parameters. 407 */ 408 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, 409 "Test #%RU32: Telling ValKit audio driver on host to inject recording data ...\n", idxTest); 410 411 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClValKit, &pTstParms->TestTone); 412 if (RT_SUCCESS(rc)) 413 { 411 414 /* 412 * 1. Arm the (host) ValKit ATS with the playback parameters.415 * 2. Tell the guest ATS to start recording. 413 416 */ 414 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Telling ValKit audio driver on host to inject recording data ...\n"); 415 rc = AudioTestSvcClientTonePlay(&pTstEnv->u.Host.AtsClValKit, &pTstParms->TestTone); 416 if (RT_SUCCESS(rc)) 417 { 418 /* 419 * 2. Tell the guest ATS to start recording. 420 */ 421 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Telling VKAT on guest to record audio ...\n"); 422 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClGuest, &pTstParms->TestTone); 423 if (RT_FAILURE(rc)) 424 RTTestFailed(g_hTest, "Test #%RU32 (%RU32/%RU32): AudioTestSvcClientToneRecord() failed with %Rrc\n", 425 pTstParms->idxCurrent, i + 1, pTstParms->cIterations, rc); 426 } 427 else 428 RTTestFailed(g_hTest, "Test #%RU32 (%RU32/%RU32): AudioTestSvcClientTonePlay() failed with %Rrc\n", 429 pTstParms->idxCurrent, i + 1, pTstParms->cIterations, rc); 430 431 if (RT_SUCCESS(rc)) 432 { 433 /* Wait a bit to let the left over audio bits being processed. */ 434 if (pTstParms->cIterations > 1) 435 RTThreadSleep(RTRandU32Ex(2000, 5000)); /** @todo Implement some dedicated ATS command for this? */ 436 } 437 417 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32: Telling VKAT on guest to record audio ...\n", idxTest); 418 419 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClGuest, &pTstParms->TestTone); 438 420 if (RT_FAILURE(rc)) 439 { 440 RTTestFailed(g_hTest, "Test #%RU32 (%RU32/%RU32): Recording test tone failed with %Rrc\n", 441 pTstParms->idxCurrent, i + 1, pTstParms->cIterations, rc); 442 break; /* Not worth retrying, bail out. */ 443 } 444 } 421 RTTestFailed(g_hTest, "Test #%RU32: AudioTestSvcClientToneRecord() failed with %Rrc\n", idxTest, rc); 422 } 423 else 424 RTTestFailed(g_hTest, "Test #%RU32: AudioTestSvcClientTonePlay() failed with %Rrc\n", idxTest, rc); 425 426 if (RT_SUCCESS(rc)) 427 { 428 /* Wait a bit to let the left over audio bits being processed. */ 429 if (pTstEnv->cIterations > 1) 430 RTThreadSleep(RTRandU32Ex(2000, 5000)); /** @todo Implement some dedicated ATS command for this? */ 431 } 432 433 if (RT_FAILURE(rc)) 434 RTTestFailed(g_hTest, "Test #%RU32: Recording test tone failed with %Rrc\n", idxTest, rc); 445 435 446 436 return rc; … … 478 468 * @param pTstEnv Test environment to use for running the test. 479 469 * @param pTstDesc Test to run. 480 * @param uSeq Test sequence # in case there are more tests. 481 */ 482 static int audioTestOne(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc, unsigned uSeq) 483 { 484 RT_NOREF(uSeq); 485 486 int rc; 470 */ 471 static int audioTestOne(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc) 472 { 473 int rc = VINF_SUCCESS; 487 474 488 475 AUDIOTESTPARMS TstParms; … … 493 480 if (pTstDesc->fExcluded) 494 481 { 495 RTTestSkipped(g_hTest, "Test #% u is excluded from list, skipping", uSeq);482 RTTestSkipped(g_hTest, "Test #%RU32 is excluded from list, skipping", pTstEnv->idxTest); 496 483 return VINF_SUCCESS; 497 484 } 498 485 486 pTstEnv->cIterations = pTstEnv->cIterations == 0 ? RTRandU32Ex(1, 10) : pTstEnv->cIterations; 487 488 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32 (%RU32 iterations total)\n", pTstEnv->idxTest, pTstEnv->cIterations); 489 499 490 void *pvCtx = NULL; /* Test-specific opaque context. Optional and can be NULL. */ 500 491 501 if (pTstDesc->pfnSetup) 502 { 503 rc = pTstDesc->pfnSetup(pTstEnv, pTstDesc, &TstParms, &pvCtx); 504 if (RT_FAILURE(rc)) 492 AssertPtr(pTstDesc->pfnExec); 493 for (uint32_t i = 0; i < pTstEnv->cIterations; i++) 494 { 495 int rc2; 496 497 if (pTstDesc->pfnSetup) 505 498 { 506 RTTestFailed(g_hTest, "Test #%u setup failed with %Rrc\n", uSeq, rc); 507 return rc; 499 rc2 = pTstDesc->pfnSetup(pTstEnv, pTstDesc, &TstParms, &pvCtx); 500 if (RT_FAILURE(rc2)) 501 RTTestFailed(g_hTest, "Test #%RU32 setup failed with %Rrc\n", pTstEnv->idxTest, rc2); 508 502 } 509 } 510 511 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%u (%RU32 iterations total)\n", uSeq, TstParms.cIterations); 512 513 AssertPtr(pTstDesc->pfnExec); 514 rc = pTstDesc->pfnExec(pTstEnv, pvCtx, &TstParms); 515 if (RT_FAILURE(rc)) 516 RTTestFailed(g_hTest, "Test #%u failed with %Rrc\n", uSeq, rc); 517 518 RTTestSubDone(g_hTest); 519 520 if (pTstDesc->pfnDestroy) 521 { 522 int rc2 = pTstDesc->pfnDestroy(pTstEnv, pvCtx); 503 else 504 rc2 = VINF_SUCCESS; 505 506 if (RT_SUCCESS(rc2)) 507 { 508 AssertPtrBreakStmt(pTstDesc->pfnExec, VERR_INVALID_POINTER); 509 rc2 = pTstDesc->pfnExec(pTstEnv, pvCtx, &TstParms); 510 if (RT_FAILURE(rc2)) 511 RTTestFailed(g_hTest, "Test #%RU32 execution failed with %Rrc\n", pTstEnv->idxTest, rc2); 512 } 513 514 if (pTstDesc->pfnDestroy) 515 { 516 rc2 = pTstDesc->pfnDestroy(pTstEnv, pvCtx); 517 if (RT_FAILURE(rc2)) 518 RTTestFailed(g_hTest, "Test #%RU32 destruction failed with %Rrc\n", pTstEnv->idxTest, rc2); 519 } 520 523 521 if (RT_SUCCESS(rc)) 524 522 rc = rc2; 525 523 526 if (RT_FAILURE(rc2)) 527 RTTestFailed(g_hTest, "Test #%u destruction failed with %Rrc\n", uSeq, rc2); 528 } 524 /* Keep going. */ 525 pTstEnv->idxTest++; 526 } 527 528 RTTestSubDone(g_hTest); 529 529 530 530 audioTestParmsDestroy(&TstParms); … … 578 578 if (RT_SUCCESS(rc)) 579 579 { 580 unsigned uSeq = 0;581 580 for (unsigned i = 0; i < RT_ELEMENTS(g_aTests); i++) 582 581 { 583 int rc2 = audioTestOne(pTstEnv, &g_aTests[i] , uSeq);582 int rc2 = audioTestOne(pTstEnv, &g_aTests[i]); 584 583 if (RT_SUCCESS(rc)) 585 584 rc = rc2; 586 587 if (!g_aTests[i].fExcluded)588 uSeq++;589 585 590 586 if (g_fTerminate) -
trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp
r92299 r92396 528 528 * We always start with the pre beacon. */ 529 529 AUDIOTESTTONEBEACON Beacon; 530 AudioTestBeaconInit(&Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_PRE, &pStream->Cfg.Props);530 AudioTestBeaconInit(&Beacon, (uint8_t)pParms->Hdr.idxTest, AUDIOTESTTONEBEACONTYPE_PLAY_PRE, &pStream->Cfg.Props); 531 531 532 532 uint32_t const cbBeacon = AudioTestBeaconGetSize(&Beacon); … … 537 537 } 538 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 } 539 AudioTestObjAddMetadataStr(Obj, "test_id=%04RU32\n", pParms->Hdr.idxTest); 540 AudioTestObjAddMetadataStr(Obj, "beacon_type=%RU32\n", (uint32_t)AudioTestBeaconGetType(&Beacon)); 541 AudioTestObjAddMetadataStr(Obj, "beacon_pre_bytes=%RU32\n", cbBeacon); 542 AudioTestObjAddMetadataStr(Obj, "beacon_post_bytes=%RU32\n", cbBeacon); 543 AudioTestObjAddMetadataStr(Obj, "stream_to_play_bytes=%RU32\n", cbToPlayTotal); 544 AudioTestObjAddMetadataStr(Obj, "stream_period_size_frames=%RU32\n", pStream->Cfg.Backend.cFramesPeriod); 545 AudioTestObjAddMetadataStr(Obj, "stream_buffer_size_frames=%RU32\n", pStream->Cfg.Backend.cFramesBufferSize); 546 AudioTestObjAddMetadataStr(Obj, "stream_prebuf_size_frames=%RU32\n", pStream->Cfg.Backend.cFramesPreBuffering); 547 /* Note: This mostly is provided by backend (e.g. PulseAudio / ALSA / ++) and 548 * has nothing to do with the device emulation scheduling hint. */ 549 AudioTestObjAddMetadataStr(Obj, "device_scheduling_hint_ms=%RU32\n", pStream->Cfg.Device.cMsSchedulingHint); 552 550 553 551 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Playing %RU32 bytes total\n", cbToPlayTotal); … … 618 616 if (AudioTestBeaconGetSize(&Beacon)) /* Play the post beacon, if any. */ 619 617 { 620 AudioTestBeaconInit(&Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_POST, &pStream->Cfg.Props); 618 AudioTestBeaconInit(&Beacon, (uint8_t)pParms->Hdr.idxTest, AUDIOTESTTONEBEACONTYPE_PLAY_POST, 619 &pStream->Cfg.Props); 621 620 continue; 622 621 } … … 753 752 * We always start with the pre beacon. */ 754 753 AUDIOTESTTONEBEACON Beacon; 755 AudioTestBeaconInit(&Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_PRE, &pStream->Cfg.Props);754 AudioTestBeaconInit(&Beacon, (uint8_t)pParms->Hdr.idxTest, AUDIOTESTTONEBEACONTYPE_PLAY_PRE, &pStream->Cfg.Props); 756 755 757 756 uint32_t const cbBeacon = AudioTestBeaconGetSize(&Beacon); … … 759 758 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Expecting 2 x %RU32 bytes pre/post beacons\n", cbBeacon); 760 759 760 AudioTestObjAddMetadataStr(Obj, "test_id=%04RU32\n", pParms->Hdr.idxTest); 761 761 AudioTestObjAddMetadataStr(Obj, "beacon_type=%RU32\n", (uint32_t)AudioTestBeaconGetType(&Beacon)); 762 762 AudioTestObjAddMetadataStr(Obj, "beacon_pre_bytes=%RU32\n", cbBeacon); … … 870 870 enmState = AUDIOTESTSTATE_POST; 871 871 /* Re-use the beacon object, but this time it's the post beacon. */ 872 AudioTestBeaconInit(&Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_POST, &pStream->Cfg.Props); 872 AudioTestBeaconInit(&Beacon, (uint8_t)pParms->Hdr.idxTest, AUDIOTESTTONEBEACONTYPE_PLAY_POST, 873 &pStream->Cfg.Props); 873 874 } 874 875 } … … 1034 1035 1035 1036 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Got request for playing test tone #%RU32 (%RU16Hz, %RU32ms) ...\n", 1036 pToneParms->Hdr.idx Seq, (uint16_t)pToneParms->dbFreqHz, pToneParms->msDuration);1037 pToneParms->Hdr.idxTest, (uint16_t)pToneParms->dbFreqHz, pToneParms->msDuration); 1037 1038 1038 1039 char szTimeCreated[RTTIME_STR_LEN]; … … 1082 1083 1083 1084 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Got request for recording test tone #%RU32 (%RU32ms) ...\n", 1084 pToneParms->Hdr.idx Seq, pToneParms->msDuration);1085 pToneParms->Hdr.idxTest, pToneParms->msDuration); 1085 1086 1086 1087 char szTimeCreated[RTTIME_STR_LEN]; -
trunk/src/VBox/ValidationKit/utils/audio/vkatInternal.h
r92169 r92396 238 238 /** 239 239 * Audio test environment parameters. 240 * Not necessarily bound to a specific test (can be reused). 240 * 241 * This is global to all tests defined. 241 242 */ 242 243 typedef struct AUDIOTESTENV … … 251 252 * If empty the default audio device will be used. */ 252 253 char szDev[128]; 254 /** Zero-based index of current test (will be increased for every run test). */ 255 uint32_t idxTest; 253 256 /** Number of iterations for *all* tests specified. 254 257 * When set to 0 (default), a random value (see specific test) will be chosen. */
Note:
See TracChangeset
for help on using the changeset viewer.