Changeset 89010 in vbox for trunk/src/VBox/ValidationKit/utils/audio
- Timestamp:
- May 12, 2021 12:52:13 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkat.cpp
r88997 r89010 112 112 typedef FNAUDIOTESTDESTROY *PFNAUDIOTESTDESTROY; 113 113 114 /** Maximum audio streams a test environment can handle. */ 115 #define AUDIOTESTENV_MAX_STREAMS 8 116 114 117 /** 115 118 * Audio test environment parameters. … … 119 122 { 120 123 /** The host (backend) driver to use. */ 121 PPDMIHOSTAUDIO pDrvAudio;124 PPDMIHOSTAUDIO pDrvAudio; 122 125 /** The current (last) audio device enumeration to use. */ 123 PDMAUDIOHOSTENUM DevEnm; 126 PDMAUDIOHOSTENUM DevEnm; 127 PDMAUDIOBACKENDSTREAM aStreams[AUDIOTESTENV_MAX_STREAMS]; 124 128 /** The audio test set to use. */ 125 AUDIOTESTSET Set;129 AUDIOTESTSET Set; 126 130 } AUDIOTESTENV; 127 131 /** Pointer a audio test environment. */ … … 152 156 *********************************************************************************************************************************/ 153 157 static int audioTestCombineParms(PAUDIOTESTPARMS pBaseParms, PAUDIOTESTPARMS pOverrideParms); 158 static int audioTestPlayTone(PAUDIOTESTENV pTstEnv, PPDMAUDIOBACKENDSTREAM pStream, PAUDIOTESTTONEPARMS pParms); 154 159 155 160 … … 239 244 static DECLCALLBACK(int) audioTestPlayToneSetup(PAUDIOTESTENV pTstEnv, PAUDIOTESTDESC pTstDesc, PAUDIOTESTPARMS pTstParmsAcq, void **ppvCtx) 240 245 { 241 RT_NOREF(pTstEnv, pTstDesc, p TstParmsAcq, ppvCtx);242 243 // PDMAudioPropsInit(&Props, 16 /* bit */ / 8, true /* fSigned */, 2 /* Channels */, 44100 /* Hz */);244 245 //AudioTestToneParamsInitRandom(&pTstParms->ToneParms, &pTstParms->ToneParms.Props);246 RT_NOREF(pTstEnv, pTstDesc, ppvCtx); 247 248 PDMAudioPropsInit(&pTstParmsAcq->ToneParms.Props, 16 /* bit */ / 8, true /* fSigned */, 2 /* Channels */, 44100 /* Hz */); 249 250 AudioTestToneParamsInitRandom(&pTstParmsAcq->ToneParms, &pTstParmsAcq->ToneParms.Props); 246 251 247 252 return VINF_SUCCESS; … … 250 255 static DECLCALLBACK(int) audioTestPlayToneExec(PAUDIOTESTENV pTstEnv, void *pvCtx, PAUDIOTESTPARMS pTstParms) 251 256 { 252 RT_NOREF(p TstEnv, pvCtx, pTstParms);253 254 return VINF_SUCCESS;257 RT_NOREF(pvCtx); 258 259 return audioTestPlayTone(pTstEnv, &pTstEnv->aStreams[0], &pTstParms->ToneParms); 255 260 } 256 261 … … 543 548 544 549 return rc; 550 } 551 552 static int audioTestPlayTone(PAUDIOTESTENV pTstEnv, PPDMAUDIOBACKENDSTREAM pStream, PAUDIOTESTTONEPARMS pParms) 553 { 554 PDMAUDIOSTREAMCFG CfgReq; 555 PDMAUDIOSTREAMCFG CfgAcq; 556 557 int rc = PDMAudioStrmCfgInitWithProps(&CfgReq, &pParms->Props); 558 AssertRC(rc); /* Cannot fail. */ 559 560 CfgReq.enmDir = PDMAUDIODIR_OUT; 561 CfgReq.u.enmDst = PDMAUDIOPLAYBACKDST_FRONT; 562 CfgReq.enmLayout = PDMAUDIOSTREAMLAYOUT_NON_INTERLEAVED; 563 564 rc = PDMAudioStrmCfgCopy(&CfgAcq, &CfgReq); 565 AssertRC(rc); /* Ditto. */ 566 567 rc = pTstEnv->pDrvAudio->pfnStreamCreate(pTstEnv->pDrvAudio, pStream, &CfgReq, &CfgAcq); 568 if (RT_FAILURE(rc)) 569 return rc; 570 571 /* Do the async init in a synchronous way for now here. */ 572 if (rc == VINF_AUDIO_STREAM_ASYNC_INIT_NEEDED) 573 rc = pTstEnv->pDrvAudio->pfnStreamInitAsync(pTstEnv->pDrvAudio, pStream, false /* fDestroyed */); 574 575 AUDIOTESTTONE TstTone; 576 AudioTestToneInitRandom(&TstTone, &pParms->Props); 577 578 PDMHOSTAUDIOSTREAMSTATE enmState = pTstEnv->pDrvAudio->pfnStreamGetState(pTstEnv->pDrvAudio, pStream); 579 if (enmState == PDMHOSTAUDIOSTREAMSTATE_OKAY) 580 { 581 uint32_t cbBuf; 582 uint8_t abBuf[_4K]; 583 584 const uint64_t tsStartMs = RTTimeMilliTS(); 585 const unsigned cSchedulingMs = 10; 586 const uint32_t cbPerMs = PDMAudioPropsMilliToBytes(&CfgAcq.Props, cSchedulingMs); 587 588 do 589 { 590 rc = AudioTestToneWrite(&TstTone, abBuf, RT_MIN(cbPerMs, sizeof(abBuf)), &cbBuf); 591 if (RT_SUCCESS(rc)) 592 { 593 uint32_t cbWritten; 594 rc = pTstEnv->pDrvAudio->pfnStreamPlay(pTstEnv->pDrvAudio, pStream, abBuf, cbBuf, &cbWritten); 595 } 596 597 if (RTTimeMilliTS() - tsStartMs >= pParms->msDuration) 598 break; 599 600 RTThreadSleep(cSchedulingMs); 601 602 } while (RT_SUCCESS(rc)); 603 } 604 605 int rc2 = pTstEnv->pDrvAudio->pfnStreamDestroy(pTstEnv->pDrvAudio, pStream); 606 if (RT_SUCCESS(rc)) 607 rc = rc2; 608 609 return VINF_SUCCESS; 545 610 } 546 611
Note:
See TracChangeset
for help on using the changeset viewer.