Changeset 92396 in vbox
- Timestamp:
- Nov 12, 2021 11:46:06 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 148250
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTest.cpp
r92379 r92396 2411 2411 * @returns VBox status code. 2412 2412 * @param pBeacon Audio test beacon to (re-)initialize. 2413 * @param uTest Test number to set beacon to. 2413 2414 * @param enmType Beacon type to set. 2414 2415 * @param pProps PCM properties to use for producing audio beacon data. 2415 2416 */ 2416 void AudioTestBeaconInit(PAUDIOTESTTONEBEACON pBeacon, AUDIOTESTTONEBEACONTYPE enmType, PPDMAUDIOPCMPROPS pProps)2417 void AudioTestBeaconInit(PAUDIOTESTTONEBEACON pBeacon, uint8_t uTest, AUDIOTESTTONEBEACONTYPE enmType, PPDMAUDIOPCMPROPS pProps) 2417 2418 { 2418 2419 AssertReturnVoid(PDMAudioPropsFrameSize(pProps) == 4); /** @todo Make this more dynamic. */ … … 2420 2421 RT_BZERO(pBeacon, sizeof(AUDIOTESTTONEBEACON)); 2421 2422 2423 pBeacon->uTest = uTest; 2422 2424 pBeacon->enmType = enmType; 2423 2425 memcpy(&pBeacon->Props, pProps, sizeof(PDMAUDIOPCMPROPS)); … … 2430 2432 * 2431 2433 * @returns Beacon byte if found, 0 otherwise. 2434 * @param uTest Test number to get beacon byte for. 2432 2435 * @param enmType Beacon type to get beacon byte for. 2433 2436 */ 2434 DECLINLINE(uint8_t) AudioTestBeaconByteFromType( AUDIOTESTTONEBEACONTYPE enmType)2437 DECLINLINE(uint8_t) AudioTestBeaconByteFromType(uint8_t uTest, AUDIOTESTTONEBEACONTYPE enmType) 2435 2438 { 2436 2439 switch (enmType) 2437 2440 { 2438 case AUDIOTESTTONEBEACONTYPE_PLAY_PRE: return AUDIOTEST_BEACON_ BYTE_PLAY_PRE;2439 case AUDIOTESTTONEBEACONTYPE_PLAY_POST: return AUDIOTEST_BEACON_ BYTE_PLAY_POST;2440 case AUDIOTESTTONEBEACONTYPE_REC_PRE: return AUDIOTEST_BEACON_ BYTE_REC_PRE;2441 case AUDIOTESTTONEBEACONTYPE_REC_POST: return AUDIOTEST_BEACON_ BYTE_REC_POST;2441 case AUDIOTESTTONEBEACONTYPE_PLAY_PRE: return AUDIOTEST_BEACON_MAKE_PRE(uTest); 2442 case AUDIOTESTTONEBEACONTYPE_PLAY_POST: return AUDIOTEST_BEACON_MAKE_POST(uTest); 2443 case AUDIOTESTTONEBEACONTYPE_REC_PRE: return AUDIOTEST_BEACON_MAKE_PRE(uTest); 2444 case AUDIOTESTTONEBEACONTYPE_REC_POST: return AUDIOTEST_BEACON_MAKE_POST(uTest); 2442 2445 default: break; 2443 2446 } … … 2503 2506 AssertReturn(pBeacon->cbUsed + cbBuf <= pBeacon->cbSize, VERR_BUFFER_OVERFLOW); 2504 2507 2505 memset(pvBuf, AudioTestBeaconByteFromType(pBeacon-> enmType), cbBuf);2508 memset(pvBuf, AudioTestBeaconByteFromType(pBeacon->uTest, pBeacon->enmType), cbBuf); 2506 2509 2507 2510 pBeacon->cbUsed += cbBuf; … … 2552 2555 uint32_t const cbFrameSize = PDMAudioPropsFrameSize(&pBeacon->Props); /* Use the audio frame size as chunk size. */ 2553 2556 2554 uint8_t const byBeacon = AudioTestBeaconByteFromType(pBeacon-> enmType);2557 uint8_t const byBeacon = AudioTestBeaconByteFromType(pBeacon->uTest, pBeacon->enmType); 2555 2558 unsigned const cbStep = cbFrameSize; 2556 2559 … … 2624 2627 2625 2628 AUDIOTESTTONEBEACON Beacon; 2626 AudioTestBeaconInit(&Beacon, 2629 AudioTestBeaconInit(&Beacon, pVerJob->idxTest, 2627 2630 fIn 2628 2631 ? (fPre ? AUDIOTESTTONEBEACONTYPE_PLAY_PRE : AUDIOTESTTONEBEACONTYPE_PLAY_POST) -
trunk/src/VBox/Devices/Audio/AudioTest.h
r92234 r92396 32 32 /** Prefix for audio test (set) directories. */ 33 33 #define AUDIOTEST_PATH_PREFIX_STR "vkat" 34 /** Audio beacon data (single byte) to use for the playback pre beacon (intro). */ 35 #define AUDIOTEST_BEACON_BYTE_PLAY_PRE 0x42 36 /** Audio beacon data (single byte) to use for the playback post beacon (outro). */ 37 #define AUDIOTEST_BEACON_BYTE_PLAY_POST 0x24 38 /** Audio beacon data (single byte) to use for the recording pre beacon (intro). */ 39 #define AUDIOTEST_BEACON_BYTE_REC_PRE 0x75 40 /** Audio beacon data (single byte) to use for the recording post beacon (outro). */ 41 #define AUDIOTEST_BEACON_BYTE_REC_POST 0x57 34 /** Maximum tests a beacon can have. 35 * Maximum number of tests is 240 (so it can fit into 8-bit mono channels). */ 36 #define AUDIOTEST_BEACON_TESTS_MAX 240 37 /** Returns a pre-beacon for a given test number. 38 * Maximum number of tests is 240 (so it can fit into 8-bit mono channels). 39 * 40 * That way it's easy to visually inspect beacon data in a hex editor -- 41 * e.g. for test #5 a pre-beacon would be 0x5A + post-beacon 0x5B. */ 42 #define AUDIOTEST_BEACON_MAKE_PRE(a_TstNum) \ 43 ( (uint8_t)((a_TstNum) & 0xf) << 4 \ 44 | (uint8_t)(0xA)) 45 /** Returns a post-beacon for a given test number. 46 * Maximum number of tests is 250 (so it can fit into 8-bit mono channels). 47 * 48 * That way it's easy to visually inspect beacon data in a hex editor -- 49 * e.g. for test #2 a pre-beacon would be 0x2A + post-beacon 0x2B. */ 50 #define AUDIOTEST_BEACON_MAKE_POST(a_TstNum) \ 51 ( (uint8_t)((a_TstNum) & 0xf) << 4 \ 52 | (uint8_t)(0xB)) 42 53 /** Pre / post audio beacon size (in audio frames). */ 43 54 #define AUDIOTEST_BEACON_SIZE_FRAMES 1024 … … 86 97 typedef struct AUDIOTESTPARMSHDR 87 98 { 88 /** Index in some defined sequence this test has. Can be freely used / assigned 89 * and depends on the actual implementation. 99 /** Test index these test parameters belong to. 90 100 * Set to UINT32_MAX if not being used. */ 91 uint32_t idx Seq;101 uint32_t idxTest; 92 102 /** Time of the caller when this test was being created. */ 93 103 RTTIME tsCreated; … … 147 157 typedef struct AUDIOTESTTONEBEACON 148 158 { 159 /** Test number this beacon is for. */ 160 uint8_t uTest; 149 161 /** The beacon type. */ 150 162 AUDIOTESTTONEBEACONTYPE enmType; … … 200 212 typedef struct AUDIOTESTPARMS 201 213 { 202 /** Specifies the current test iteration. */203 uint32_t idxCurrent;204 /** How many iterations the test should be executed. */205 uint32_t cIterations;206 214 /** Audio device to use. */ 207 215 PDMAUDIOHOSTDEV Dev; … … 377 385 int AudioTestToneGenerate(PAUDIOTESTTONE pTone, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten); 378 386 379 void AudioTestBeaconInit(PAUDIOTESTTONEBEACON pBeacon, AUDIOTESTTONEBEACONTYPE enmType, PPDMAUDIOPCMPROPS pProps);387 void AudioTestBeaconInit(PAUDIOTESTTONEBEACON pBeacon, uint8_t uTest, AUDIOTESTTONEBEACONTYPE enmType, PPDMAUDIOPCMPROPS pProps); 380 388 int AudioTestBeaconAddConsecutive(PAUDIOTESTTONEBEACON pBeacon, const uint8_t *auBuf, size_t cbBuf, size_t *pOff); 381 389 int AudioTestBeaconWrite(PAUDIOTESTTONEBEACON pBeacon, void *pvBuf, uint32_t cbBuf); -
trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp
r92348 r92396 157 157 /** Number of total tests in \a lstTestsRec and \a lstTestsPlay. */ 158 158 uint32_t cTestsTotal; 159 /** Increasing number to identify tests. */160 uint32_t idxTest;161 159 /** Number of tests in \a lstTestsRec. */ 162 160 uint32_t cTestsRec; … … 503 501 PDRVHOSTVALKITAUDIO pThis = (PDRVHOSTVALKITAUDIO)pvUser; 504 502 505 PVALKITTESTDATA pT estData= (PVALKITTESTDATA)RTMemAllocZ(sizeof(VALKITTESTDATA));506 AssertPtrReturn(pT estData, VERR_NO_MEMORY);507 508 pT estData->enmState = AUDIOTESTSTATE_INIT;509 510 memcpy(&pT estData->t.TestTone.Parms, pToneParms, sizeof(AUDIOTESTTONEPARMS));511 512 PPDMAUDIOPCMPROPS const pProps = &pT estData->t.TestTone.Parms.Props;513 514 AssertReturn(pT estData->t.TestTone.Parms.msDuration, VERR_INVALID_PARAMETER);503 PVALKITTESTDATA pTst = (PVALKITTESTDATA)RTMemAllocZ(sizeof(VALKITTESTDATA)); 504 AssertPtrReturn(pTst, VERR_NO_MEMORY); 505 506 pTst->enmState = AUDIOTESTSTATE_INIT; 507 508 memcpy(&pTst->t.TestTone.Parms, pToneParms, sizeof(AUDIOTESTTONEPARMS)); 509 510 PPDMAUDIOPCMPROPS const pProps = &pTst->t.TestTone.Parms.Props; 511 512 AssertReturn(pTst->t.TestTone.Parms.msDuration, VERR_INVALID_PARAMETER); 515 513 AssertReturn(PDMAudioPropsAreValid(pProps), VERR_INVALID_PARAMETER); 516 514 517 AudioTestToneInit(&pT estData->t.TestTone.Tone, pProps, pTestData->t.TestTone.Parms.dbFreqHz);518 519 pT estData->t.TestTone.u.Rec.cbToWrite = PDMAudioPropsMilliToBytes(pProps,520 pT estData->t.TestTone.Parms.msDuration);515 AudioTestToneInit(&pTst->t.TestTone.Tone, pProps, pTst->t.TestTone.Parms.dbFreqHz); 516 517 pTst->t.TestTone.u.Rec.cbToWrite = PDMAudioPropsMilliToBytes(pProps, 518 pTst->t.TestTone.Parms.msDuration); 521 519 522 520 /* We inject a pre + post beacon before + after the actual test tone. 523 521 * We always start with the pre beacon. */ 524 AudioTestBeaconInit(&pT estData->t.TestTone.Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_PRE, pProps);522 AudioTestBeaconInit(&pTst->t.TestTone.Beacon, pToneParms->Hdr.idxTest, AUDIOTESTTONEBEACONTYPE_PLAY_PRE, pProps); 525 523 526 524 int rc = RTCritSectEnter(&pThis->CritSect); … … 528 526 { 529 527 LogRel(("ValKit: Registering guest recording test #%RU32 (%RU32ms, %RU64 bytes, host test #%RU32)\n", 530 pThis-> idxTest, pTestData->t.TestTone.Parms.msDuration, pTestData->t.TestTone.u.Rec.cbToWrite,531 pToneParms->Hdr.idx Seq));532 533 const uint32_t cbBeacon = AudioTestBeaconGetSize(&pT estData->t.TestTone.Beacon);528 pThis->cTestsRec, pTst->t.TestTone.Parms.msDuration, pTst->t.TestTone.u.Rec.cbToWrite, 529 pToneParms->Hdr.idxTest)); 530 531 const uint32_t cbBeacon = AudioTestBeaconGetSize(&pTst->t.TestTone.Beacon); 534 532 if (cbBeacon) 535 533 LogRel2(("ValKit: Guest recording test #%RU32 includes 2 x %RU32 bytes of pre/post beacons\n", 536 pThis-> idxTest, cbBeacon));537 538 RTListAppend(&pThis->lstTestsRec, &pT estData->Node);539 540 pT estData->msRegisteredTS = RTTimeMilliTS();541 pT estData->idxTest = pThis->idxTest++;534 pThis->cTestsRec, cbBeacon)); 535 536 RTListAppend(&pThis->lstTestsRec, &pTst->Node); 537 538 pTst->msRegisteredTS = RTTimeMilliTS(); 539 pTst->idxTest = pToneParms->Hdr.idxTest; /* Use the test ID from the host (so that the beacon IDs match). */ 542 540 543 541 pThis->cTestsRec++; … … 560 558 PDRVHOSTVALKITAUDIO pThis = (PDRVHOSTVALKITAUDIO)pvUser; 561 559 562 PVALKITTESTDATA pT estData= (PVALKITTESTDATA)RTMemAllocZ(sizeof(VALKITTESTDATA));563 AssertPtrReturn(pT estData, VERR_NO_MEMORY);564 565 pT estData->enmState = AUDIOTESTSTATE_INIT;566 567 memcpy(&pT estData->t.TestTone.Parms, pToneParms, sizeof(AUDIOTESTTONEPARMS));568 569 PPDMAUDIOPCMPROPS const pProps = &pT estData->t.TestTone.Parms.Props;570 571 AssertReturn(pT estData->t.TestTone.Parms.msDuration, VERR_INVALID_PARAMETER);560 PVALKITTESTDATA pTst = (PVALKITTESTDATA)RTMemAllocZ(sizeof(VALKITTESTDATA)); 561 AssertPtrReturn(pTst, VERR_NO_MEMORY); 562 563 pTst->enmState = AUDIOTESTSTATE_INIT; 564 565 memcpy(&pTst->t.TestTone.Parms, pToneParms, sizeof(AUDIOTESTTONEPARMS)); 566 567 PPDMAUDIOPCMPROPS const pProps = &pTst->t.TestTone.Parms.Props; 568 569 AssertReturn(pTst->t.TestTone.Parms.msDuration, VERR_INVALID_PARAMETER); 572 570 AssertReturn(PDMAudioPropsAreValid(pProps), VERR_INVALID_PARAMETER); 573 571 574 pT estData->t.TestTone.u.Play.cbToRead = PDMAudioPropsMilliToBytes(pProps,575 pT estData->t.TestTone.Parms.msDuration);572 pTst->t.TestTone.u.Play.cbToRead = PDMAudioPropsMilliToBytes(pProps, 573 pTst->t.TestTone.Parms.msDuration); 576 574 577 575 /* We play a pre + post beacon before + after the actual test tone. 578 576 * We always start with the pre beacon. */ 579 AudioTestBeaconInit(&pT estData->t.TestTone.Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_PRE, pProps);577 AudioTestBeaconInit(&pTst->t.TestTone.Beacon, pToneParms->Hdr.idxTest, AUDIOTESTTONEBEACONTYPE_PLAY_PRE, pProps); 580 578 581 579 int rc = RTCritSectEnter(&pThis->CritSect); … … 583 581 { 584 582 LogRel(("ValKit: Registering guest playback test #%RU32 (%RU32ms, %RU64 bytes, host test #%RU32)\n", 585 pThis-> idxTest, pTestData->t.TestTone.Parms.msDuration, pTestData->t.TestTone.u.Play.cbToRead,586 pToneParms->Hdr.idx Seq));587 588 const uint32_t cbBeacon = AudioTestBeaconGetSize(&pT estData->t.TestTone.Beacon);583 pThis->cTestsPlay, pTst->t.TestTone.Parms.msDuration, pTst->t.TestTone.u.Play.cbToRead, 584 pToneParms->Hdr.idxTest)); 585 586 const uint32_t cbBeacon = AudioTestBeaconGetSize(&pTst->t.TestTone.Beacon); 589 587 if (cbBeacon) 590 588 LogRel2(("ValKit: Guest playback test #%RU32 includes 2 x %RU32 bytes of pre/post beacons\n", 591 pThis-> idxTest, cbBeacon));592 593 RTListAppend(&pThis->lstTestsPlay, &pT estData->Node);594 595 pT estData->msRegisteredTS = RTTimeMilliTS();596 pT estData->idxTest = pThis->idxTest++;589 pThis->cTestsPlay, cbBeacon)); 590 591 RTListAppend(&pThis->lstTestsPlay, &pTst->Node); 592 593 pTst->msRegisteredTS = RTTimeMilliTS(); 594 pTst->idxTest = pToneParms->Hdr.idxTest; /* Use the test ID from the host (so that the beacon IDs match). */ 597 595 598 596 pThis->cTestsTotal++; … … 876 874 pTst->idxTest, (uint16_t)pTst->t.TestTone.Tone.rdFreqHz, 877 875 pTst->t.TestTone.Parms.msDuration, pTst->t.TestTone.u.Rec.cbToWrite, 878 Parms.TestTone.Hdr.idx Seq, RTTimeMilliTS() - pTst->msRegisteredTS));876 Parms.TestTone.Hdr.idxTest, RTTimeMilliTS() - pTst->msRegisteredTS)); 879 877 880 878 char szTimeCreated[RTTIME_STR_LEN]; … … 1081 1079 LogRel(("ValKit: Test #%RU32: Recording audio data (%RU16Hz, %RU32ms) for host test #%RU32 started (delay is %RU32ms)\n", 1082 1080 pTst->idxTest, (uint16_t)Parms.TestTone.dbFreqHz, Parms.TestTone.msDuration, 1083 Parms.TestTone.Hdr.idx Seq, RTTimeMilliTS() - pTst->msRegisteredTS));1081 Parms.TestTone.Hdr.idxTest, RTTimeMilliTS() - pTst->msRegisteredTS)); 1084 1082 1085 1083 char szTimeCreated[RTTIME_STR_LEN]; … … 1182 1180 1183 1181 /* Re-use the beacon object, but this time it's the post beacon. */ 1184 AudioTestBeaconInit(&pTst->t.TestTone.Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_POST, &pTst->t.TestTone.Parms.Props); 1182 AudioTestBeaconInit(&pTst->t.TestTone.Beacon, pTst->idxTest, AUDIOTESTTONEBEACONTYPE_PLAY_POST, 1183 &pTst->t.TestTone.Parms.Props); 1185 1184 } 1186 1185 break; … … 1373 1372 1374 1373 pTst->enmState = AUDIOTESTSTATE_POST; 1374 1375 1375 /* Re-use the beacon object, but this time it's the post beacon. */ 1376 AudioTestBeaconInit(&pTst->t.TestTone.Beacon, AUDIOTESTTONEBEACONTYPE_PLAY_POST, &pTst->t.TestTone.Parms.Props); 1376 AudioTestBeaconInit(&pTst->t.TestTone.Beacon, pTst->idxTest, AUDIOTESTTONEBEACONTYPE_PLAY_POST, 1377 &pTst->t.TestTone.Parms.Props); 1378 1377 1379 pStrmValKit->cbAvail += AudioTestBeaconGetSize(&pTst->t.TestTone.Beacon); 1378 1380 } -
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.