Changeset 89992 in vbox
- Timestamp:
- Jul 2, 2021 8:56:55 AM (4 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp
r89962 r89992 719 719 const void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten) 720 720 { 721 RT_NOREF(pStream);722 723 721 if (cbBuf == 0) 724 722 { … … 730 728 PDRVHOSTVALKITAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTVALKITAUDIO, IHostAudio); 731 729 732 PVALKITTESTDATA pTst = NULL;730 bool const fIsSilence = PDMAudioPropsIsBufferSilence(&pStream->pStream->Cfg.Props, pvBuf, cbBuf); 733 731 734 732 int rc = RTCritSectEnter(&pThis->CritSect); … … 736 734 { 737 735 if (pThis->pTestCur == NULL) 736 { 738 737 pThis->pTestCur = RTListGetFirst(&pThis->lstTestsPlay, VALKITTESTDATA, Node); 739 740 pTst = pThis->pTestCur; 738 if (pThis->pTestCur) 739 LogRel(("ValKit: Next guest playback test in queue is test #%RU32\n", pThis->pTestCur->idxTest)); 740 } 741 741 742 742 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 744 744 } 745 745 746 if (pTst == NULL) /* Empty list? */ 747 { 748 LogRel(("ValKit: Warning: Guest is playing back data when no playback test is active\n")); 746 if (pThis->pTestCur == NULL) /* Empty list? */ 747 { 748 #ifdef DEBUG_andy 749 if (!fIsSilence) 750 #endif 751 LogRel(("ValKit: Warning: Guest is playing back audio (%s, %RU32 bytes, %RU64ms) when no playback test is active\n", 752 fIsSilence ? "silence" : "audible", cbBuf, PDMAudioPropsBytesToMilli(&pStream->pStream->Cfg.Props, cbBuf))); 749 753 750 754 *pcbWritten = cbBuf; … … 752 756 } 753 757 754 #if 1 755 if (PDMAudioPropsIsBufferSilence(&pStream->pStream->Cfg.Props, pvBuf, cbBuf)) 756 { 757 LogRel(("ValKit: Skipping %RU32 bytes of silence\n", cbBuf)); 758 759 *pcbWritten = cbBuf; 760 return VINF_SUCCESS; 761 } 758 #ifndef DEBUG_andy 759 if (fIsSilence) 760 LogRel2(("ValKit: Guest is playing back %RU32 bytes (%RU64ms) silence\n", 761 cbBuf, PDMAudioPropsBytesToMilli(&pStream->pStream->Cfg.Props, cbBuf))); 762 762 #endif 763 763 764 if (pTst->t.TestTone.u.Play.cbRead == 0) 764 PVALKITTESTDATA pTst = pThis->pTestCur; 765 766 const bool fHandleSilence = false; /** @todo Skip blocks of entire silence for now. */ 767 768 if (pTst->pEntry == NULL) 765 769 { 766 770 AUDIOTESTPARMS Parms; … … 770 774 Parms.TestTone = pTst->t.TestTone.Parms; 771 775 772 Assert(pTst->pEntry == NULL);773 776 rc = AudioTestSetTestBegin(&pThis->Set, "Recording audio data from guest", 774 777 &Parms, &pTst->pEntry); … … 788 791 if (RT_SUCCESS(rc)) 789 792 { 790 rc = AudioTestSetObjWrite(pTst->pObj, pvBuf, cbBuf); 791 if (RT_SUCCESS(rc)) 792 { 793 if ( !fIsSilence 794 || (fIsSilence && fHandleSilence)) 795 { 796 rc = AudioTestSetObjWrite(pTst->pObj, pvBuf, cbBuf); 793 797 pTst->t.TestTone.u.Play.cbRead += cbBuf; 794 798 795 #if 0796 799 const bool fComplete = pTst->t.TestTone.u.Play.cbRead >= pTst->t.TestTone.u.Play.cbToRead; 797 800 if (fComplete) … … 804 807 pTst->idxTest, pTst->t.TestTone.u.Play.cbRead - pTst->t.TestTone.u.Play.cbToRead)); 805 808 809 AudioTestSetTestDone(pTst->pEntry); 810 806 811 rc = RTCritSectEnter(&pThis->CritSect); 807 812 if (RT_SUCCESS(rc)) 808 813 { 809 AudioTestSetTestDone(pTst->pEntry);814 drvHostValKiUnregisterPlayTest(pThis, pTst); 810 815 811 816 pThis->pTestCur = NULL; 812 817 pTst = NULL; 813 814 if (pThis->fTestSetEnded)815 rc = RTSemEventSignal(pThis->EventSemEnded);816 818 817 819 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 820 822 } 821 823 } 822 #endif823 824 cbWritten = cbBuf;825 }824 } 825 826 /* Always report everything as being played. */ 827 cbWritten = cbBuf; 826 828 } 827 829 … … 848 850 RT_NOREF(pStream); 849 851 852 if (cbBuf == 0) 853 { 854 /* Fend off draining calls. */ 855 *pcbRead = 0; 856 return VINF_SUCCESS; 857 } 858 850 859 PDRVHOSTVALKITAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTVALKITAUDIO, IHostAudio); 851 860 … … 854 863 { 855 864 if (pThis->pTestCur == NULL) 865 { 856 866 pThis->pTestCur = RTListGetFirst(&pThis->lstTestsRec, VALKITTESTDATA, Node); 867 if (pThis->pTestCur) 868 LogRel(("ValKit: Next guest recording test in queue is test #%RU32\n", pThis->pTestCur->idxTest)); 869 } 857 870 858 871 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 862 875 if (pThis->pTestCur == NULL) /* Empty list? */ 863 876 { 864 LogRelMax(64, ("ValKit: Warning: Guest is recordingaudio data when no recording test is active\n"));877 LogRelMax(64, ("ValKit: Warning: Guest is trying to record audio data when no recording test is active\n")); 865 878 866 879 *pcbRead = 0; … … 870 883 PVALKITTESTDATA pTst = pThis->pTestCur; 871 884 872 if (pTst-> t.TestTone.u.Rec.cbWritten == 0)885 if (pTst->pEntry == NULL) 873 886 { 874 887 AUDIOTESTPARMS Parms; … … 878 891 Parms.TestTone = pTst->t.TestTone.Parms; 879 892 880 Assert(pTst->pEntry == NULL);881 893 rc = AudioTestSetTestBegin(&pThis->Set, "Injecting audio input data to guest", 882 894 &Parms, &pTst->pEntry); … … 909 921 Assert(pTst->t.TestTone.u.Rec.cbWritten <= pTst->t.TestTone.u.Rec.cbToWrite); 910 922 911 const bool fComplete = pTst->t.TestTone.u.Rec.cbToWrite == pTst->t.TestTone.u.Rec.cbWritten; 912 923 const bool fComplete = pTst->t.TestTone.u.Rec.cbToWrite >= pTst->t.TestTone.u.Rec.cbWritten; 913 924 if (fComplete) 914 925 { 915 926 LogRel(("ValKit: Injecting audio input data done (took %RU32ms)\n", 916 927 RTTimeMilliTS() - pTst->msStartedTS)); 928 929 AudioTestSetTestDone(pTst->pEntry); 917 930 918 931 rc = RTCritSectEnter(&pThis->CritSect); -
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.