Changeset 89992 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Jul 2, 2021 8:56:55 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145469
- Location:
- trunk/src/VBox/ValidationKit/utils/audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r89966 r89992 253 253 pTstParmsAcq->enmDir = PDMAUDIODIR_OUT; 254 254 #ifdef DEBUG 255 pTstParmsAcq->cIterations = 1;255 pTstParmsAcq->cIterations = 4; 256 256 #else 257 257 pTstParmsAcq->cIterations = RTRandU32Ex(1, 10); … … 265 265 pToneParms->msPrequel = 0; /** @todo Implement analyzing this first! */ 266 266 #ifdef DEBUG_andy 267 pToneParms->msDuration = 2000;267 pToneParms->msDuration = RTRandU32Ex(50, 2500); 268 268 #else 269 269 pToneParms->msDuration = RTRandU32Ex(0, RT_MS_10SEC); /** @todo Probably a bit too long, but let's see. */ … … 286 286 for (uint32_t i = 0; i < pTstParms->cIterations; i++) 287 287 { 288 PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone; 289 290 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32/%RU16: Playing test tone (%RU16Hz, %RU32ms)\n", 291 pTstParms->idxCurrent, i, (uint16_t)pToneParms->dbFreqHz, pToneParms->msDuration); 292 288 293 /* 289 294 * 1. Arm the (host) ValKit ATS with the recording parameters. 290 295 */ 291 PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone;292 296 rc = AudioTestSvcClientToneRecord(&pTstEnv->u.Host.AtsClValKit, pToneParms); 293 297 if (RT_SUCCESS(rc)) … … 299 303 } 300 304 301 if (RT_FAILURE(rc)) 302 RTTestFailed(g_hTest, "Playing tone failed\n"); 305 if (RT_SUCCESS(rc)) 306 { 307 if (pTstParms->cIterations) 308 RTThreadSleep(RTRandU32Ex(2000, 5000)); 309 } 310 else 311 RTTestFailed(g_hTest, "Test #%RU32/%RU16: Playing tone failed\n", pTstParms->idxCurrent, i); 303 312 } 304 313 … … 336 345 pTstParmsAcq->enmDir = PDMAUDIODIR_IN; 337 346 #ifdef DEBUG 338 pTstParmsAcq->cIterations = 1;347 pTstParmsAcq->cIterations = 4; 339 348 #else 340 349 pTstParmsAcq->cIterations = RTRandU32Ex(1, 10); … … 342 351 pTstParmsAcq->idxCurrent = 0; 343 352 353 PAUDIOTESTTONEPARMS pToneParms = &pTstParmsAcq->TestTone; 354 355 pToneParms->Props = pTstParmsAcq->Props; 356 pToneParms->dbFreqHz = AudioTestToneGetRandomFreq(); 357 pToneParms->msPrequel = 0; /** @todo Implement analyzing this first! */ 358 pToneParms->Props = pTstParmsAcq->Props; 359 #ifdef DEBUG_andy 360 pToneParms->msDuration = RTRandU32Ex(50 /* ms */, 2500); 361 #else 362 pToneParms->msDuration = RTRandU32Ex(50 /* ms */, RT_MS_30SEC); /** @todo Record even longer? */ 363 #endif 364 pToneParms->msSequel = 0; /** @todo Implement analyzing this first! */ 365 pToneParms->uVolumePercent = 100; /** @todo Implement analyzing this first! */ 366 344 367 return rc; 345 368 } … … 356 379 for (uint32_t i = 0; i < pTstParms->cIterations; i++) 357 380 { 358 pTstParms->TestTone.Props = pTstParms->Props; 359 #ifdef DEBUG_andy 360 pTstParms->TestTone.msDuration = RTRandU32Ex(50 /* ms */, 2000); 361 #else 362 pTstParms->TestTone.msDuration = RTRandU32Ex(50 /* ms */, RT_MS_30SEC); /** @todo Record even longer? */ 363 #endif 381 PAUDIOTESTTONEPARMS const pToneParms = &pTstParms->TestTone; 382 383 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%RU32/%RU16: Recording test tone (%RU16Hz, %RU32ms)\n", 384 pTstParms->idxCurrent, i, (uint16_t)pToneParms->dbFreqHz, pToneParms->msDuration); 385 364 386 /* 365 387 * 1. Arm the (host) ValKit ATS with the playback parameters. … … 375 397 376 398 if (RT_FAILURE(rc)) 377 RTTestFailed(g_hTest, "Recording tone failed\n"); 399 RTTestFailed(g_hTest, "Test #%RU32/%RU16: Recording tone failed\n", pTstParms->idxCurrent, i); 400 401 /* Wait a bit to let the left over audio bits being processed. */ 402 if (pTstParms->cIterations) 403 RTThreadSleep(RTRandU32Ex(2000, 5000)); 378 404 } 379 405 … … 427 453 if (pTstDesc->fExcluded) 428 454 { 429 RTTestSkipped(g_hTest, " Excluded from list");455 RTTestSkipped(g_hTest, "Test #%u is excluded from list, skipping", uSeq); 430 456 return VINF_SUCCESS; 431 457 } … … 438 464 if (RT_FAILURE(rc)) 439 465 { 440 RTTestFailed(g_hTest, "Test setup failed with %Rrc\n", rc);466 RTTestFailed(g_hTest, "Test #%u setup failed with %Rrc\n", uSeq, rc); 441 467 return rc; 442 468 } 443 469 } 444 470 445 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%u : %RU32 iterations\n", uSeq, TstParms.cIterations);471 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Test #%u (%RU32 iterations total)\n", uSeq, TstParms.cIterations); 446 472 447 473 AssertPtr(pTstDesc->pfnExec); 448 474 rc = pTstDesc->pfnExec(pTstEnv, pvCtx, &TstParms); 449 475 if (RT_FAILURE(rc)) 450 RTTestFailed(g_hTest, "Test failed with %Rrc\n", rc);476 RTTestFailed(g_hTest, "Test #%u failed with %Rrc\n", uSeq, rc); 451 477 452 478 RTTestSubDone(g_hTest); … … 459 485 460 486 if (RT_FAILURE(rc2)) 461 RTTestFailed(g_hTest, "Test destruction failed with %Rrc\n", rc2);487 RTTestFailed(g_hTest, "Test #%u destruction failed with %Rrc\n", uSeq, rc2); 462 488 } 463 489 -
trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp
r89988 r89992 368 368 const char *pcszPathOut = pTstEnv->Set.szPathAbs; 369 369 370 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Recording test tone ( for %RU32ms)\n", pParms->msDuration);370 RTTestPrintf(g_hTest, RTTESTLVL_ALWAYS, "Recording test tone (tone frequency is %RU16Hz, %RU32ms)\n", (uint16_t)pParms->dbFreqHz, pParms->msDuration); 371 371 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Writing to '%s'\n", pcszPathOut); 372 372 … … 376 376 AssertRCReturn(rc, rc); 377 377 378 if (audioTestDriverStackStreamIsOkay(&pTstEnv->DrvStack, pStream->pStream)) 379 { 380 const uint32_t cbPerSched = PDMAudioPropsMilliToBytes(&pParms->Props, pTstEnv->cMsSchedulingHint); 381 AssertStmt(cbPerSched, rc = VERR_INVALID_PARAMETER); 382 uint32_t cbToRead = PDMAudioPropsMilliToBytes(&pParms->Props, pParms->msDuration); 383 AssertStmt(cbToRead, rc = VERR_INVALID_PARAMETER); 384 378 PAUDIOTESTDRVMIXSTREAM pMix = &pStream->Mix; 379 380 rc = AudioTestMixStreamEnable(pMix); 381 if (RT_SUCCESS(rc)) 382 { 383 uint64_t cbToRecTotal = PDMAudioPropsMilliToBytes(&pStream->Cfg.Props, pParms->msDuration); 384 385 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Recording %RU32 bytes total\n", cbToRecTotal); 386 387 AudioTestSetObjAddMetadataStr(pObj, "stream_to_record_bytes=%RU32\n", cbToRecTotal); 388 AudioTestSetObjAddMetadataStr(pObj, "stream_buffer_size_ms=%RU32\n", pTstEnv->cMsBufferSize); 389 AudioTestSetObjAddMetadataStr(pObj, "stream_prebuf_size_ms=%RU32\n", pTstEnv->cMsPreBuffer); 390 /* Note: This mostly is provided by backend (e.g. PulseAudio / ALSA / ++) and 391 * has nothing to do with the device emulation scheduling hint. */ 392 AudioTestSetObjAddMetadataStr(pObj, "device_scheduling_hint_ms=%RU32\n", pTstEnv->cMsSchedulingHint); 393 394 uint8_t abSamples[16384]; 395 uint32_t const cbSamplesAligned = PDMAudioPropsFloorBytesToFrame(pMix->pProps, sizeof(abSamples)); 396 uint64_t cbRecTotal = 0; 397 while (!g_fTerminate && cbRecTotal < cbToRecTotal) 398 { 399 /* 400 * Anything we can read? 401 */ 402 uint32_t const cbCanRead = AudioTestMixStreamGetReadable(pMix); 403 if (cbCanRead) 404 { 405 uint32_t const cbToRead = RT_MIN(cbCanRead, cbSamplesAligned); 406 uint32_t cbRecorded = 0; 407 rc = AudioTestMixStreamCapture(pMix, abSamples, cbToRead, &cbRecorded); 408 if (RT_SUCCESS(rc)) 409 { 410 if (cbRecorded) 411 { 412 rc = AudioTestSetObjWrite(pObj, abSamples, cbRecorded); 413 if (RT_SUCCESS(rc)) 414 { 415 cbRecTotal += cbRecorded; 416 417 /** @todo Clamp result? */ 418 } 419 } 420 } 421 } 422 else if (AudioTestMixStreamIsOkay(pMix)) 423 RTThreadSleep(RT_MIN(RT_MAX(1, pTstEnv->cMsSchedulingHint), 256)); 424 425 if (RT_FAILURE(rc)) 426 break; 427 } 428 429 int rc2 = AudioTestMixStreamDisable(pMix); 385 430 if (RT_SUCCESS(rc)) 386 { 387 AudioTestSetObjAddMetadataStr(pObj, "buffer_size_ms=%RU32\n", pTstEnv->cMsBufferSize); 388 AudioTestSetObjAddMetadataStr(pObj, "prebuf_size_ms=%RU32\n", pTstEnv->cMsPreBuffer); 389 AudioTestSetObjAddMetadataStr(pObj, "scheduling_hint_ms=%RU32\n", pTstEnv->cMsSchedulingHint); 390 391 uint8_t abBuf[_4K]; 392 393 while (cbToRead) 394 { 395 const uint32_t cbChunk = RT_MIN(cbToRead, RT_MIN(cbPerSched, sizeof(abBuf))); 396 397 uint32_t cbRead = 0; 398 rc = audioTestDriverStackStreamCapture(&pTstEnv->DrvStack, pStream->pStream, (void *)abBuf, cbChunk, &cbRead); 399 if (RT_SUCCESS(rc)) 400 rc = AudioTestSetObjWrite(pObj, abBuf, cbRead); 401 402 if (RT_FAILURE(rc)) 403 break; 404 405 RTThreadSleep(pTstEnv->cMsSchedulingHint); 406 407 Assert(cbToRead >= cbRead); 408 cbToRead -= cbRead; 409 } 410 } 411 } 412 else 413 rc = VERR_AUDIO_STREAM_NOT_READY; 431 rc = rc2; 432 } 414 433 415 434 int rc2 = AudioTestSetObjClose(pObj); … … 465 484 PATSCALLBACKCTX pCtx = (PATSCALLBACKCTX)pvUser; 466 485 PAUDIOTESTENV pTstEnv = pCtx->pTstEnv; 467 468 AUDIOTESTTONE TstTone;469 AudioTestToneInitRandom(&TstTone, &pToneParms->Props);470 486 471 487 const PAUDIOTESTSTREAM pTstStream = &pTstEnv->aStreams[0]; /** @todo Make this dynamic. */
Note:
See TracChangeset
for help on using the changeset viewer.