Changeset 89291 in vbox for trunk/src/VBox
- Timestamp:
- May 26, 2021 10:04:32 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp
r89280 r89291 81 81 typedef struct VALKITTESTTONEDATA 82 82 { 83 /** How many ns to write. */84 uint64_t nsToWrite;85 /** How many ns already written. */86 uint64_t nsWritten;83 /** How many bytes to write. */ 84 uint64_t cbToWrite; 85 /** How many bytes already written. */ 86 uint64_t cbWritten; 87 87 /** The test tone instance to use. */ 88 88 AUDIOTESTTONE Tone; 89 89 /** The test tone parameters to use. */ 90 AUDIOTESTTONEPARMS ToneParms;90 AUDIOTESTTONEPARMS Parms; 91 91 } VALKITTESTTONEDATA; 92 92 … … 105 105 VALKITTESTTONEDATA TestTone; 106 106 } t; 107 /** Time stamp (real, in ms) when test started. */ 108 uint64_t msStartedTS; 107 109 } VALKITTESTDATA; 108 110 /** Pointer to Validation Kit test data. */ … … 144 146 AssertPtrReturn(pTestData, VERR_NO_MEMORY); 145 147 146 memcpy(&pTestData->StreamCfg, pStreamCfg, sizeof(PDMAUDIOSTREAMCFG)); 147 memcpy(&pTestData->t.TestTone.ToneParms, pToneParms, sizeof(AUDIOTESTTONEPARMS)); 148 148 memcpy(&pTestData->StreamCfg, pStreamCfg, sizeof(PDMAUDIOSTREAMCFG)); 149 memcpy(&pTestData->t.TestTone.Parms, pToneParms, sizeof(AUDIOTESTTONEPARMS)); 150 151 AudioTestToneInit(&pTestData->t.TestTone.Tone, &pStreamCfg->Props, 8000 /* Hz */); /** @todo BUGBUG Fix this! */ 152 153 pTestData->t.TestTone.cbToWrite = PDMAudioPropsMilliToBytes(&pStreamCfg->Props, 154 pTestData->t.TestTone.Parms.msDuration); 149 155 int rc = RTCritSectEnter(&pThis->CritSect); 150 156 if (RT_SUCCESS(rc)) 151 157 { 152 158 RTListAppend(&pThis->lstTestsRec, &pTestData->Node); 159 160 pThis->cTestsRec++; 153 161 154 162 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 467 475 PDRVHOSTVALKITAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTVALKITAUDIO, IHostAudio); 468 476 469 int rc = VINF_SUCCESS; 470 471 if (pThis->pTestRecCur == NULL) 472 { 477 int rc = RTCritSectEnter(&pThis->CritSect); 478 if (RT_SUCCESS(rc)) 479 { 480 pThis->pTestRecCur = RTListGetFirst(&pThis->lstTestsRec, VALKITTESTDATA, Node); 481 482 int rc2 = RTCritSectLeave(&pThis->CritSect); 483 AssertRC(rc2); 484 } 485 486 if (pThis->pTestRecCur == NULL) /* Empty list? */ 487 { 488 *pcbRead = 0; 489 return VINF_SUCCESS; 490 } 491 492 PVALKITTESTDATA pTst = pThis->pTestRecCur; 493 494 if (pTst->t.TestTone.cbWritten == 0) 495 { 496 pTst->msStartedTS = RTTimeMilliTS(); 497 498 LogRel(("Audio: Validation Kit: Injecting input tone (%RU16Hz, %RU32ms)\n", 499 (uint16_t)pTst->t.TestTone.Tone.rdFreqHz, 500 pTst->t.TestTone.Parms.msDuration)); 501 } 502 503 uint32_t cbToWrite = pTst->t.TestTone.cbToWrite - pTst->t.TestTone.cbWritten; 504 uint32_t cbRead = 0; 505 if (cbToWrite) 506 rc = AudioTestToneGenerate(&pTst->t.TestTone.Tone, pvBuf, RT_MIN(cbToWrite, cbBuf), &cbRead); 507 508 pTst->t.TestTone.cbWritten += cbRead; 509 Assert(pTst->t.TestTone.cbWritten <= pTst->t.TestTone.cbToWrite); 510 511 const bool fComplete = pTst->t.TestTone.cbToWrite == pTst->t.TestTone.cbWritten; 512 513 if (fComplete) 514 { 515 LogRel(("Audio: Validation Kit: Injection done (took %RU32ms)\n", 516 RTTimeMilliTS() - pTst->msStartedTS)); 517 473 518 rc = RTCritSectEnter(&pThis->CritSect); 474 519 if (RT_SUCCESS(rc)) 475 520 { 476 pThis->pTestRecCur = RTListGetFirst(&pThis->lstTestsRec, VALKITTESTDATA, Node); 521 RTListNodeRemove(&pTst->Node); 522 523 RTMemFree(pTst); 524 pTst = NULL; 525 526 Assert(pThis->cTestsRec); 527 pThis->cTestsRec--; 477 528 478 529 int rc2 = RTCritSectLeave(&pThis->CritSect); 479 530 AssertRC(rc2); 480 531 } 481 }482 483 if (pThis->pTestRecCur == NULL) /* Empty list? */484 {485 *pcbRead = 0;486 return VINF_SUCCESS;487 }488 489 PVALKITTESTDATA pTst = pThis->pTestRecCur;490 491 uint32_t cbToWrite = PDMAudioPropsNanoToBytes(&pTst->StreamCfg.Props,492 (pTst->t.TestTone.nsToWrite - pTst->t.TestTone.nsWritten));493 uint32_t cbRead = 0;494 if (cbToWrite)495 rc = AudioTestToneGenerate(&pTst->t.TestTone.Tone, pvBuf, RT_MIN(cbToWrite, cbBuf), &cbRead);496 497 const uint32_t nsWritten = PDMAudioPropsBytesToNano(&pTst->StreamCfg.Props, cbRead);498 pTst->t.TestTone.nsWritten += nsWritten;499 Assert(pTst->t.TestTone.nsWritten <= pTst->t.TestTone.nsToWrite);500 501 const bool fComplete = pTst->t.TestTone.nsToWrite == pTst->t.TestTone.nsWritten;502 503 if (fComplete)504 {505 RTListNodeRemove(&pTst->Node);506 507 RTMemFree(pTst);508 pTst = NULL;509 510 Assert(pThis->cTestsRec);511 pThis->cTestsRec--;512 532 } 513 533
Note:
See TracChangeset
for help on using the changeset viewer.