Changeset 89890 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Jun 24, 2021 3:56:05 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145348
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioTest.cpp
r89889 r89890 128 128 129 129 /** 130 * Returns a random test tone frequency.131 */132 DECLINLINE(double) audioTestToneGetRandomFreq(void)133 {134 return s_aAudioTestToneFreqsHz[RTRandU32Ex(0, RT_ELEMENTS(s_aAudioTestToneFreqsHz) - 1)];135 }136 137 /**138 130 * Initializes a test tone with a specific frequency (in Hz). 139 131 * … … 147 139 { 148 140 if (dbFreq == 0.0) 149 dbFreq = audioTestToneGetRandomFreq();141 dbFreq = AudioTestToneGetRandomFreq(); 150 142 151 143 pTone->rdFreqHz = dbFreq; … … 290 282 291 283 /** 292 * Initializes an audio test tone parameters struct with random values. 293 * @param pToneParams Test tone parameters to initialize. 294 * @param pProps PCM properties to use for the test tone. 295 */ 296 int AudioTestToneParamsInitRandom(PAUDIOTESTTONEPARMS pToneParams, PPDMAUDIOPCMPROPS pProps) 297 { 298 AssertReturn(PDMAudioPropsAreValid(pProps), VERR_INVALID_PARAMETER); 299 300 memcpy(&pToneParams->Props, pProps, sizeof(PDMAUDIOPCMPROPS)); 301 302 /** @todo Make this a bit more sophisticated later, e.g. muting and prequel/sequel are not very balanced. */ 303 304 pToneParams->dbFreqHz = audioTestToneGetRandomFreq(); 305 pToneParams->msPrequel = RTRandU32Ex(0, RT_MS_5SEC); 306 #ifdef DEBUG_andy 307 pToneParams->msDuration = RTRandU32Ex(0, RT_MS_1SEC); 308 #else 309 pToneParams->msDuration = RTRandU32Ex(0, RT_MS_10SEC); /** @todo Probably a bit too long, but let's see. */ 310 #endif 311 pToneParams->msSequel = RTRandU32Ex(0, RT_MS_5SEC); 312 pToneParams->uVolumePercent = RTRandU32Ex(0, 100); 313 314 return VINF_SUCCESS; 284 * Returns a random test tone frequency. 285 */ 286 double AudioTestToneGetRandomFreq(void) 287 { 288 return s_aAudioTestToneFreqsHz[RTRandU32Ex(0, RT_ELEMENTS(s_aAudioTestToneFreqsHz) - 1)]; 315 289 } 316 290 … … 1411 1385 1412 1386 /** 1387 * Returns whether a test set has running (active) tests or not. 1388 * 1389 * @returns \c true if it has running tests, or \c false if not. 1390 * @param pSet Test set to return status for. 1391 */ 1392 bool AudioTestSetIsRunning(PAUDIOTESTSET pSet) 1393 { 1394 return (pSet->cTestsRunning > 0); 1395 } 1396 1397 /** 1413 1398 * Unpacks a formerly packed audio test set. 1414 1399 * … … 1713 1698 rc = RTFileQuerySize(pObjB->File.hFile, &cbSizeB); 1714 1699 AssertRCReturn(rc, rc); 1715 if ( cbSizeA != cbSizeB 1716 || !audioTestFilesCompareBinary(pObjA->File.hFile, pObjB->File.hFile, cbSizeA)) 1700 1701 if (!cbSizeA) 1702 { 1703 int rc2 = audioTestErrorDescAdd(pVerJob->pErr, pVerJob->idxTest, "File '%s' is empty\n", pObjA->szName); 1704 AssertRC(rc2); 1705 } 1706 1707 if (!cbSizeB) 1708 { 1709 int rc2 = audioTestErrorDescAdd(pVerJob->pErr, pVerJob->idxTest, "File '%s' is empty\n", pObjB->szName); 1710 AssertRC(rc2); 1711 } 1712 1713 if (cbSizeA != cbSizeB) 1714 { 1715 int rc2 = audioTestErrorDescAdd(pVerJob->pErr, pVerJob->idxTest, "File '%s' is %zu bytes %s than '%s'\n", 1716 pObjA->szName, 1717 cbSizeA > cbSizeB ? cbSizeA - cbSizeB : cbSizeB - cbSizeA, 1718 cbSizeA > cbSizeB ? "bigger" : "smaller", 1719 pObjB->szName); 1720 AssertRC(rc2); 1721 } 1722 else if (audioTestFilesCompareBinary(pObjA->File.hFile, pObjB->File.hFile, cbSizeA)) 1717 1723 { 1718 1724 /** @todo Add more sophisticated stuff here. */ 1719 1725 1720 int rc2 = audioTestErrorDescAdd(pVerJob->pErr, pVerJob->idxTest, "Files '%s' and '%s' don't match\n", szObjA, szObjB); 1726 int rc2 = audioTestErrorDescAdd(pVerJob->pErr, pVerJob->idxTest, "Files '%s' and '%s' have different content\n", 1727 pObjA->szName, pObjB->szName); 1721 1728 AssertRC(rc2); 1722 1729 } -
trunk/src/VBox/Devices/Audio/AudioTest.h
r89889 r89890 340 340 double AudioTestToneInit(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps, double dbFreq); 341 341 double AudioTestToneInitRandom(PAUDIOTESTTONE pTone, PPDMAUDIOPCMPROPS pProps); 342 double AudioTestToneGetRandomFreq(void); 342 343 int AudioTestToneGenerate(PAUDIOTESTTONE pTone, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten); 343 344 int AudioTestToneParamsInitRandom(PAUDIOTESTTONEPARMS pToneParams, PPDMAUDIOPCMPROPS pProps);345 344 346 345 int AudioTestGenTag(char *pszTag, size_t cbTag); … … 367 366 const char *AudioTestSetGetTag(PAUDIOTESTSET pSet); 368 367 bool AudioTestSetIsPacked(const char *pszPath); 368 bool AudioTestSetIsRunning(PAUDIOTESTSET pSet); 369 369 int AudioTestSetPack(PAUDIOTESTSET pSet, const char *pszOutDir, char *pszFileName, size_t cbFileName); 370 370 int AudioTestSetUnpack(const char *pszFile, const char *pszOutDir); -
trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp
r89838 r89890 25 25 #include <iprt/mem.h> 26 26 #include <iprt/path.h> 27 #include <iprt/semaphore.h> 27 28 #include <iprt/stream.h> 28 29 #include <iprt/uuid.h> /* For PDMIBASE_2_PDMDRV. */ … … 138 139 /** Critical section for serializing access across threads. */ 139 140 RTCRITSECT CritSect; 141 bool fTestSetEnded; 142 RTSEMEVENT EventSemEnded; 140 143 /** The Audio Test Service (ATS) instance. */ 141 144 ATSSERVER Srv; … … 173 176 { 174 177 AssertPtrReturnVoid(pTst->pEntry); 175 AudioTestSetTestDone(pTst->pEntry);176 178 pTst->pEntry = NULL; 177 179 } … … 218 220 static void drvHostValKitCleanup(PDRVHOSTVALKITAUDIO pThis) 219 221 { 220 LogRel((" Audio: ValidationKit: Cleaning up ...\n"));222 LogRel(("ValKit: Cleaning up ...\n")); 221 223 222 224 if (pThis->cTestsRec) 223 LogRel((" Audio: ValidationKit: Warning: %RU32 guest recording tests still outstanding:\n", pThis->cTestsRec));225 LogRel(("ValKit: Warning: %RU32 guest recording tests still outstanding:\n", pThis->cTestsRec)); 224 226 225 227 PVALKITTESTDATA pTst, pTstNext; … … 228 230 size_t const cbOutstanding = pTst->t.TestTone.u.Rec.cbToWrite - pTst->t.TestTone.u.Rec.cbWritten; 229 231 if (cbOutstanding) 230 LogRel((" Audio: ValidationKit: \tRecording test #%RU32 has %RU64 bytes (%RU32ms) outstanding\n",232 LogRel(("ValKit: \tRecording test #%RU32 has %RU64 bytes (%RU32ms) outstanding\n", 231 233 pTst->idxTest, cbOutstanding, PDMAudioPropsBytesToMilli(&pTst->t.TestTone.Parms.Props, (uint32_t)cbOutstanding))); 232 234 drvHostValKiUnregisterRecTest(pThis, pTst); … … 234 236 235 237 if (pThis->cTestsPlay) 236 LogRel((" Audio: ValidationKit: Warning: %RU32 guest playback tests still outstanding:\n", pThis->cTestsPlay));238 LogRel(("ValKit: Warning: %RU32 guest playback tests still outstanding:\n", pThis->cTestsPlay)); 237 239 238 240 RTListForEachSafe(&pThis->lstTestsPlay, pTst, pTstNext, VALKITTESTDATA, Node) … … 240 242 size_t const cbOutstanding = pTst->t.TestTone.u.Play.cbToRead - pTst->t.TestTone.u.Play.cbRead; 241 243 if (cbOutstanding) 242 LogRel((" Audio: ValidationKit: \tPlayback test #%RU32 has %RU64 bytes (%RU32ms) outstanding\n",244 LogRel(("ValKit: \tPlayback test #%RU32 has %RU64 bytes (%RU32ms) outstanding\n", 243 245 pTst->idxTest, cbOutstanding, PDMAudioPropsBytesToMilli(&pTst->t.TestTone.Parms.Props, (uint32_t)cbOutstanding))); 244 246 drvHostValKiUnregisterPlayTest(pThis, pTst); … … 259 261 PDRVHOSTVALKITAUDIO pThis = (PDRVHOSTVALKITAUDIO)pvUser; 260 262 261 LogRel(("Audio: Validation Kit: Beginning test set '%s'\n", pszTag)); 262 return AudioTestSetCreate(&pThis->Set, pThis->szPathTemp, pszTag); 263 int rc = RTCritSectEnter(&pThis->CritSect); 264 if (RT_SUCCESS(rc)) 265 { 266 267 LogRel(("ValKit: Beginning test set '%s'\n", pszTag)); 268 rc = AudioTestSetCreate(&pThis->Set, pThis->szPathTemp, pszTag); 269 270 int rc2 = RTCritSectLeave(&pThis->CritSect); 271 if (RT_SUCCESS(rc)) 272 rc = rc2; 273 } 274 275 if (RT_FAILURE(rc)) 276 LogRel(("ValKit: Beginning test set failed with %Rrc\n", rc)); 277 278 return rc; 263 279 } 264 280 … … 268 284 PDRVHOSTVALKITAUDIO pThis = (PDRVHOSTVALKITAUDIO)pvUser; 269 285 270 const PAUDIOTESTSET pSet = &pThis->Set; 271 272 LogRel(("Audio: Validation Kit: Ending test set '%s'\n", pszTag)); 273 274 /* Close the test set first. */ 275 AudioTestSetClose(pSet); 276 277 /* Before destroying the test environment, pack up the test set so 278 * that it's ready for transmission. */ 279 int rc = AudioTestSetPack(pSet, pThis->szPathOut, pThis->szTestSetArchive, sizeof(pThis->szTestSetArchive)); 280 if (RT_SUCCESS(rc)) 281 LogRel(("Audio: Validation Kit: Packed up to '%s'\n", pThis->szTestSetArchive)); 282 283 /* Do some internal housekeeping. */ 284 drvHostValKitCleanup(pThis); 285 286 int rc2 = AudioTestSetWipe(pSet); 287 if (RT_SUCCESS(rc)) 288 rc = rc2; 289 290 AudioTestSetDestroy(pSet); 286 int rc = RTCritSectEnter(&pThis->CritSect); 287 if (RT_SUCCESS(rc)) 288 { 289 const PAUDIOTESTSET pSet = &pThis->Set; 290 291 if (AudioTestSetIsRunning(pSet)) 292 { 293 pThis->fTestSetEnded = true; 294 295 rc = RTCritSectLeave(&pThis->CritSect); 296 if (RT_SUCCESS(rc)) 297 { 298 LogRel(("ValKit: Waiting for runnig test set '%s' to end ...\n", pszTag)); 299 rc = RTSemEventWait(pThis->EventSemEnded, RT_MS_30SEC); 300 301 int rc2 = RTCritSectEnter(&pThis->CritSect); 302 if (RT_SUCCESS(rc)) 303 rc = rc2; 304 } 305 } 306 307 if (RT_SUCCESS(rc)) 308 { 309 LogRel(("ValKit: Ending test set '%s'\n", pszTag)); 310 311 /* Close the test set first. */ 312 rc = AudioTestSetClose(pSet); 313 if (RT_SUCCESS(rc)) 314 { 315 /* Before destroying the test environment, pack up the test set so 316 * that it's ready for transmission. */ 317 rc = AudioTestSetPack(pSet, pThis->szPathOut, pThis->szTestSetArchive, sizeof(pThis->szTestSetArchive)); 318 if (RT_SUCCESS(rc)) 319 LogRel(("ValKit: Packed up to '%s'\n", pThis->szTestSetArchive)); 320 321 /* Do some internal housekeeping. */ 322 drvHostValKitCleanup(pThis); 323 324 #ifndef DEBUG_andy 325 int rc2 = AudioTestSetWipe(pSet); 326 if (RT_SUCCESS(rc)) 327 rc = rc2; 328 #endif 329 } 330 331 AudioTestSetDestroy(pSet); 332 } 333 334 int rc2 = RTCritSectLeave(&pThis->CritSect); 335 if (RT_SUCCESS(rc)) 336 rc = rc2; 337 } 291 338 292 339 if (RT_FAILURE(rc)) 293 LogRel((" Audio: ValidationKit: Ending test set failed with %Rrc\n", rc));340 LogRel(("ValKit: Ending test set failed with %Rrc\n", rc)); 294 341 295 342 return rc; … … 310 357 memcpy(&pTestData->t.TestTone.Parms, pToneParms, sizeof(AUDIOTESTTONEPARMS)); 311 358 312 AudioTestToneInit(&pTestData->t.TestTone.Tone, &pToneParms->Props, pTestData->t.TestTone.Parms.dbFreqHz); 313 314 pTestData->t.TestTone.u.Rec.cbToWrite = PDMAudioPropsMilliToBytes(&pToneParms->Props, 359 AssertReturn(pTestData->t.TestTone.Parms.msDuration, VERR_INVALID_PARAMETER); 360 AssertReturn(PDMAudioPropsAreValid(&pTestData->t.TestTone.Parms.Props), VERR_INVALID_PARAMETER); 361 362 AudioTestToneInit(&pTestData->t.TestTone.Tone, &pTestData->t.TestTone.Parms.Props, pTestData->t.TestTone.Parms.dbFreqHz); 363 364 pTestData->t.TestTone.u.Rec.cbToWrite = PDMAudioPropsMilliToBytes(&pTestData->t.TestTone.Parms.Props, 315 365 pTestData->t.TestTone.Parms.msDuration); 316 366 int rc = RTCritSectEnter(&pThis->CritSect); 317 367 if (RT_SUCCESS(rc)) 318 368 { 319 LogRel((" Audio: ValidationKit: Registered guest recording test #%RU32 (%RU32ms, %RU64 bytes)\n",369 LogRel(("ValKit: Registered guest recording test #%RU32 (%RU32ms, %RU64 bytes)\n", 320 370 pThis->cTestsTotal, pTestData->t.TestTone.Parms.msDuration, pTestData->t.TestTone.u.Rec.cbToWrite)); 321 371 … … 347 397 memcpy(&pTestData->t.TestTone.Parms, pToneParms, sizeof(AUDIOTESTTONEPARMS)); 348 398 349 pTestData->t.TestTone.u.Play.cbToRead = PDMAudioPropsMilliToBytes(&pToneParms->Props, 399 AssertReturn(pTestData->t.TestTone.Parms.msDuration, VERR_INVALID_PARAMETER); 400 AssertReturn(PDMAudioPropsAreValid(&pTestData->t.TestTone.Parms.Props), VERR_INVALID_PARAMETER); 401 402 pTestData->t.TestTone.u.Play.cbToRead = PDMAudioPropsMilliToBytes(&pTestData->t.TestTone.Parms.Props, 350 403 pTestData->t.TestTone.Parms.msDuration); 351 404 int rc = RTCritSectEnter(&pThis->CritSect); 352 405 if (RT_SUCCESS(rc)) 353 406 { 354 LogRel((" Audio: ValidationKit: Registered guest playback test #%RU32 (%RU32ms, %RU64 bytes)\n",407 LogRel(("ValKit: Registered guest playback test #%RU32 (%RU32ms, %RU64 bytes)\n", 355 408 pThis->cTestsTotal, pTestData->t.TestTone.Parms.msDuration, pTestData->t.TestTone.u.Play.cbToRead)); 356 409 … … 375 428 PDRVHOSTVALKITAUDIO pThis = (PDRVHOSTVALKITAUDIO)pvUser; 376 429 377 if (!RTFileExists(pThis->szTestSetArchive)) /* Has the archive successfully been created yet? */ 378 return VERR_WRONG_ORDER; 379 380 int rc = RTFileOpen(&pThis->hTestSetArchive, pThis->szTestSetArchive, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 381 if (RT_SUCCESS(rc)) 382 { 383 uint64_t uSize; 384 rc = RTFileQuerySize(pThis->hTestSetArchive, &uSize); 385 if (RT_SUCCESS(rc)) 386 LogRel(("Audio: Validation Kit: Sending test set '%s' (%zu bytes)\n", pThis->szTestSetArchive, uSize)); 387 } 430 int rc = RTCritSectEnter(&pThis->CritSect); 431 if (RT_SUCCESS(rc)) 432 { 433 if (RTFileExists(pThis->szTestSetArchive)) /* Has the archive successfully been created yet? */ 434 { 435 rc = RTFileOpen(&pThis->hTestSetArchive, pThis->szTestSetArchive, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 436 if (RT_SUCCESS(rc)) 437 { 438 uint64_t uSize; 439 rc = RTFileQuerySize(pThis->hTestSetArchive, &uSize); 440 if (RT_SUCCESS(rc)) 441 LogRel(("ValKit: Sending test set '%s' (%zu bytes)\n", pThis->szTestSetArchive, uSize)); 442 } 443 } 444 else 445 rc = VERR_FILE_NOT_FOUND; 446 447 int rc2 = RTCritSectLeave(&pThis->CritSect); 448 if (RT_SUCCESS(rc)) 449 rc = rc2; 450 } 451 452 if (RT_FAILURE(rc)) 453 LogRel(("ValKit: Beginning to send test set failed with %Rrc\n", rc)); 388 454 389 455 return rc; … … 398 464 PDRVHOSTVALKITAUDIO pThis = (PDRVHOSTVALKITAUDIO)pvUser; 399 465 400 return RTFileRead(pThis->hTestSetArchive, pvBuf, cbBuf, pcbRead); 466 int rc = RTCritSectEnter(&pThis->CritSect); 467 if (RT_SUCCESS(rc)) 468 { 469 if (RTFileIsValid(pThis->hTestSetArchive)) 470 { 471 rc = RTFileRead(pThis->hTestSetArchive, pvBuf, cbBuf, pcbRead); 472 } 473 else 474 rc = VERR_WRONG_ORDER; 475 476 int rc2 = RTCritSectLeave(&pThis->CritSect); 477 if (RT_SUCCESS(rc)) 478 rc = rc2; 479 } 480 481 if (RT_FAILURE(rc)) 482 LogRel(("ValKit: Reading from test set failed with %Rrc\n", rc)); 483 484 return rc; 401 485 } 402 486 … … 408 492 PDRVHOSTVALKITAUDIO pThis = (PDRVHOSTVALKITAUDIO)pvUser; 409 493 410 int rc = RTFileClose(pThis->hTestSetArchive); 411 if (RT_SUCCESS(rc)) 412 { 413 pThis->hTestSetArchive = NIL_RTFILE; 414 } 494 int rc = RTCritSectEnter(&pThis->CritSect); 495 if (RT_SUCCESS(rc)) 496 { 497 if (RTFileIsValid(pThis->hTestSetArchive)) 498 { 499 rc = RTFileClose(pThis->hTestSetArchive); 500 if (RT_SUCCESS(rc)) 501 pThis->hTestSetArchive = NIL_RTFILE; 502 } 503 504 int rc2 = RTCritSectLeave(&pThis->CritSect); 505 if (RT_SUCCESS(rc)) 506 rc = rc2; 507 } 508 509 if (RT_FAILURE(rc)) 510 LogRel(("ValKit: Ending to send test set failed with %Rrc\n", rc)); 415 511 416 512 return rc; … … 532 628 static DECLCALLBACK(int) drvHostValKitAudioHA_StreamDrain(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream) 533 629 { 534 RT_NOREF(pInterface, pStream); 630 RT_NOREF(pStream); 631 632 PDRVHOSTVALKITAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTVALKITAUDIO, IHostAudio); 633 634 int rc = RTCritSectEnter(&pThis->CritSect); 635 if (RT_SUCCESS(rc)) 636 { 637 PVALKITTESTDATA pTst = pThis->pTestCur; 638 639 if (pTst) 640 { 641 LogRel(("ValKit: Test #%RU32: Recording audio data ended (took %RU32ms)\n", 642 pTst->idxTest, RTTimeMilliTS() - pTst->msStartedTS)); 643 644 if (pTst->t.TestTone.u.Play.cbRead > pTst->t.TestTone.u.Play.cbToRead) 645 LogRel(("ValKit: Warning: Test #%RU32 read %RU32 bytes more than announced\n", 646 pTst->idxTest, pTst->t.TestTone.u.Play.cbRead - pTst->t.TestTone.u.Play.cbToRead)); 647 648 AudioTestSetTestDone(pTst->pEntry); 649 650 pThis->pTestCur = NULL; 651 pTst = NULL; 652 653 if (pThis->fTestSetEnded) 654 rc = RTSemEventSignal(pThis->EventSemEnded); 655 } 656 657 int rc2 = RTCritSectLeave(&pThis->CritSect); 658 AssertRC(rc2); 659 } 660 535 661 return VINF_SUCCESS; 536 662 } … … 595 721 RT_NOREF(pStream); 596 722 723 if (cbBuf == 0) 724 { 725 /* Fend off draining calls. */ 726 *pcbWritten = 0; 727 return VINF_SUCCESS; 728 } 729 597 730 PDRVHOSTVALKITAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVHOSTVALKITAUDIO, IHostAudio); 598 731 732 PVALKITTESTDATA pTst = NULL; 733 599 734 int rc = RTCritSectEnter(&pThis->CritSect); 600 735 if (RT_SUCCESS(rc)) 601 736 { 602 pThis->pTestCur = RTListGetFirst(&pThis->lstTestsPlay, VALKITTESTDATA, Node); 737 if (pThis->pTestCur == NULL) 738 pThis->pTestCur = RTListGetFirst(&pThis->lstTestsPlay, VALKITTESTDATA, Node); 739 740 pTst = pThis->pTestCur; 603 741 604 742 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 606 744 } 607 745 608 if (pT his->pTestCur== NULL) /* Empty list? */609 { 610 LogRel Max(64, ("Audio: ValidationKit: Warning: Guest is playing back data when no playback test is active\n"));746 if (pTst == NULL) /* Empty list? */ 747 { 748 LogRel(("ValKit: Warning: Guest is playing back data when no playback test is active\n")); 611 749 612 750 *pcbWritten = cbBuf; … … 614 752 } 615 753 616 PVALKITTESTDATA pTst = pThis->pTestCur; 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 } 762 #endif 617 763 618 764 if (pTst->t.TestTone.u.Play.cbRead == 0) … … 633 779 { 634 780 pTst->msStartedTS = RTTimeMilliTS(); 635 LogRel((" Audio: Validation Kit: Recording audio data (%RU16Hz, %RU32ms) started\n",636 (uint16_t)Parms.TestTone.dbFreqHz, Parms.TestTone.msDuration));781 LogRel(("ValKit: Test #%RU32: Recording audio data (%RU16Hz, %RU32ms) started\n", 782 pTst->idxTest, (uint16_t)Parms.TestTone.dbFreqHz, Parms.TestTone.msDuration)); 637 783 } 638 784 } … … 642 788 if (RT_SUCCESS(rc)) 643 789 { 644 uint32_t cbToRead = RT_MIN(cbBuf, 645 pTst->t.TestTone.u.Play.cbToRead - pTst->t.TestTone.u.Play.cbRead); 646 647 rc = AudioTestSetObjWrite(pTst->pObj, pvBuf, cbToRead); 648 if (RT_SUCCESS(rc)) 649 { 650 pTst->t.TestTone.u.Play.cbRead += cbToRead; 651 Assert(pTst->t.TestTone.u.Play.cbRead <= pTst->t.TestTone.u.Play.cbToRead); 652 653 const bool fComplete = pTst->t.TestTone.u.Play.cbToRead == pTst->t.TestTone.u.Play.cbRead; 654 790 rc = AudioTestSetObjWrite(pTst->pObj, pvBuf, cbBuf); 791 if (RT_SUCCESS(rc)) 792 { 793 pTst->t.TestTone.u.Play.cbRead += cbBuf; 794 795 #if 0 796 const bool fComplete = pTst->t.TestTone.u.Play.cbRead >= pTst->t.TestTone.u.Play.cbToRead; 655 797 if (fComplete) 656 798 { 657 LogRel(("Audio: Validation Kit: Recording audio data done (took %RU32ms)\n", 658 RTTimeMilliTS() - pTst->msStartedTS)); 799 LogRel(("ValKit: Test #%RU32: Recording audio data ended (took %RU32ms)\n", 800 pTst->idxTest, RTTimeMilliTS() - pTst->msStartedTS)); 801 802 if (pTst->t.TestTone.u.Play.cbRead > pTst->t.TestTone.u.Play.cbToRead) 803 LogRel(("ValKit: Warning: Test #%RU32 read %RU32 bytes more than announced\n", 804 pTst->idxTest, pTst->t.TestTone.u.Play.cbRead - pTst->t.TestTone.u.Play.cbToRead)); 659 805 660 806 rc = RTCritSectEnter(&pThis->CritSect); 661 807 if (RT_SUCCESS(rc)) 662 808 { 663 drvHostValKiUnregisterPlayTest(pThis, pTst);809 AudioTestSetTestDone(pTst->pEntry); 664 810 665 811 pThis->pTestCur = NULL; 812 pTst = NULL; 813 814 if (pThis->fTestSetEnded) 815 rc = RTSemEventSignal(pThis->EventSemEnded); 666 816 667 817 int rc2 = RTCritSectLeave(&pThis->CritSect); 668 AssertRC(rc2); 818 if (RT_SUCCESS(rc)) 819 rc = rc2; 669 820 } 670 821 } 671 672 cbWritten = cbToRead; 822 #endif 823 824 cbWritten = cbBuf; 673 825 } 674 826 } … … 676 828 if (RT_FAILURE(rc)) 677 829 { 678 if (pTst->pEntry) 830 if ( pTst 831 && pTst->pEntry) 679 832 AudioTestSetTestFailed(pTst->pEntry, rc, "Recording audio data failed"); 680 LogRel((" Audio: ValidationKit: Recording audio data failed with %Rrc\n", rc));833 LogRel(("ValKit: Recording audio data failed with %Rrc\n", rc)); 681 834 } 682 835 … … 700 853 if (RT_SUCCESS(rc)) 701 854 { 702 pThis->pTestCur = RTListGetFirst(&pThis->lstTestsRec, VALKITTESTDATA, Node); 855 if (pThis->pTestCur == NULL) 856 pThis->pTestCur = RTListGetFirst(&pThis->lstTestsRec, VALKITTESTDATA, Node); 703 857 704 858 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 708 862 if (pThis->pTestCur == NULL) /* Empty list? */ 709 863 { 710 LogRelMax(64, (" Audio: ValidationKit: Warning: Guest is recording audio data when no recording test is active\n"));864 LogRelMax(64, ("ValKit: Warning: Guest is recording audio data when no recording test is active\n")); 711 865 712 866 *pcbRead = 0; … … 733 887 { 734 888 pTst->msStartedTS = RTTimeMilliTS(); 735 LogRel((" Audio: ValidationKit: Injecting audio input data (%RU16Hz, %RU32ms) started\n",889 LogRel(("ValKit: Injecting audio input data (%RU16Hz, %RU32ms) started\n", 736 890 (uint16_t)pTst->t.TestTone.Tone.rdFreqHz, 737 891 pTst->t.TestTone.Parms.msDuration)); … … 759 913 if (fComplete) 760 914 { 761 LogRel((" Audio: ValidationKit: Injecting audio input data done (took %RU32ms)\n",915 LogRel(("ValKit: Injecting audio input data done (took %RU32ms)\n", 762 916 RTTimeMilliTS() - pTst->msStartedTS)); 763 917 … … 768 922 769 923 pThis->pTestCur = NULL; 924 pTst = NULL; 770 925 771 926 int rc2 = RTCritSectLeave(&pThis->CritSect); … … 779 934 if (RT_FAILURE(rc)) 780 935 { 781 if (pTst->pEntry) 936 if ( pTst 937 && pTst->pEntry) 782 938 AudioTestSetTestFailed(pTst->pEntry, rc, "Injecting audio input data failed"); 783 LogRel((" Audio: ValidationKit: Injecting audio input data failed with %Rrc\n", rc));939 LogRel(("ValKit: Injecting audio input data failed with %Rrc\n", rc)); 784 940 } 785 941 … … 844 1000 pThis->IHostAudio.pfnStreamCapture = drvHostValKitAudioHA_StreamCapture; 845 1001 1002 int rc = RTCritSectInit(&pThis->CritSect); 1003 AssertRCReturn(rc, rc); 1004 rc = RTSemEventCreate(&pThis->EventSemEnded); 1005 AssertRCReturn(rc, rc); 1006 1007 pThis->fTestSetEnded = false; 1008 846 1009 RTListInit(&pThis->lstTestsRec); 847 1010 pThis->cTestsRec = 0; … … 864 1027 uint32_t uTcpPort = ATS_TCP_HOST_DEFAULT_PORT; 865 1028 866 LogRel((" Audio: ValidationKit: Starting Audio Test Service (ATS) at %s:%RU32...\n",1029 LogRel(("ValKit: Starting Audio Test Service (ATS) at %s:%RU32...\n", 867 1030 pszTcpAddr, uTcpPort)); 868 1031 869 intrc = AudioTestSvcInit(&pThis->Srv,870 871 1032 rc = AudioTestSvcInit(&pThis->Srv, 1033 /* We only allow connections from localhost for now. */ 1034 pszTcpAddr, uTcpPort, &Callbacks); 872 1035 if (RT_SUCCESS(rc)) 873 1036 rc = AudioTestSvcStart(&pThis->Srv); … … 875 1038 if (RT_SUCCESS(rc)) 876 1039 { 877 LogRel((" Audio: ValidationKit: Audio Test Service (ATS) running\n"));1040 LogRel(("ValKit: Audio Test Service (ATS) running\n")); 878 1041 879 1042 /** @todo Let the following be customizable by CFGM later. */ … … 881 1044 if (RT_SUCCESS(rc)) 882 1045 { 883 LogRel((" Audio: ValidationKit: Using temp dir '%s'\n", pThis->szPathTemp));1046 LogRel(("ValKit: Using temp dir '%s'\n", pThis->szPathTemp)); 884 1047 rc = AudioTestPathGetTemp(pThis->szPathOut, sizeof(pThis->szPathOut)); 885 1048 if (RT_SUCCESS(rc)) 886 LogRel((" Audio: ValidationKit: Using output dir '%s'\n", pThis->szPathOut));1049 LogRel(("ValKit: Using output dir '%s'\n", pThis->szPathOut)); 887 1050 } 888 1051 } 889 1052 890 if (RT_SUCCESS(rc))891 rc = RTCritSectInit(&pThis->CritSect);892 893 1053 if (RT_FAILURE(rc)) 894 LogRel((" Audio: ValidationKit: Initialization failed, rc=%Rrc\n", rc));1054 LogRel(("ValKit: Initialization failed, rc=%Rrc\n", rc)); 895 1055 896 1056 return rc; … … 902 1062 PDRVHOSTVALKITAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTVALKITAUDIO); 903 1063 904 LogRel((" Audio: ValidationKit: Shutting down Audio Test Service (ATS) ...\n"));1064 LogRel(("ValKit: Shutting down Audio Test Service (ATS) ...\n")); 905 1065 906 1066 int rc = AudioTestSvcShutdown(&pThis->Srv); … … 910 1070 if (RT_SUCCESS(rc)) 911 1071 { 912 LogRel((" Audio: ValidationKit: Shutdown of Audio Test Service (ATS) complete\n"));1072 LogRel(("ValKit: Shutdown of Audio Test Service (ATS) complete\n")); 913 1073 drvHostValKitCleanup(pThis); 914 1074 } 915 1075 else 916 LogRel((" Audio: ValidationKit: Shutdown of Audio Test Service (ATS) failed, rc=%Rrc\n", rc));1076 LogRel(("ValKit: Shutdown of Audio Test Service (ATS) failed, rc=%Rrc\n", rc)); 917 1077 918 1078 /* Try cleaning up a bit. */ … … 920 1080 RTDirRemove(pThis->szPathOut); 921 1081 1082 RTSemEventDestroy(pThis->EventSemEnded); 1083 922 1084 if (RTCritSectIsInitialized(&pThis->CritSect)) 923 1085 { … … 928 1090 929 1091 if (RT_FAILURE(rc)) 930 LogRel((" Audio: ValidationKit: Destruction failed, rc=%Rrc\n", rc));1092 LogRel(("ValKit: Destruction failed, rc=%Rrc\n", rc)); 931 1093 } 932 1094
Note:
See TracChangeset
for help on using the changeset viewer.