Changeset 89988 in vbox
- Timestamp:
- Jul 1, 2021 9:41:23 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/utils/audio/vkatCommon.cpp
r89962 r89988 281 281 AudioTestSetObjAddMetadataStr(pObj, "device_scheduling_hint_ms=%RU32\n", pStream->Cfg.Device.cMsSchedulingHint); 282 282 283 PAUDIOTESTDRVMIXSTREAM pMix = &pStream->Mix; 284 285 uint32_t const cbPreBuffer = PDMAudioPropsFramesToBytes(pMix->pProps, pStream->Cfg.Backend.cFramesPreBuffering); 286 uint64_t const nsStarted = RTTimeNanoTS(); 287 uint64_t nsDonePreBuffering = 0; 288 289 uint64_t offStream = 0; 290 283 291 while (cbToPlayTotal) 284 292 { 293 /* Pace ourselves a little. */ 294 if (offStream >= cbPreBuffer) 295 { 296 if (!nsDonePreBuffering) 297 nsDonePreBuffering = RTTimeNanoTS(); 298 uint64_t const cNsWritten = PDMAudioPropsBytesToNano64(pMix->pProps, offStream - cbPreBuffer); 299 uint64_t const cNsElapsed = RTTimeNanoTS() - nsStarted; 300 if (cNsWritten > cNsElapsed + RT_NS_10MS) 301 RTThreadSleep((cNsWritten - cNsElapsed - RT_NS_10MS / 2) / RT_NS_1MS); 302 } 303 285 304 uint32_t cbPlayed = 0; 286 305 uint32_t const cbCanWrite = AudioTestMixStreamGetWritable(&pStream->Mix); … … 292 311 if (RT_SUCCESS(rc)) 293 312 { 294 RTTestPrintf(g_hTest, RTTESTLVL_DEBUG, "Playing %RU32 bytes ...\n", cbToPlay);295 296 313 /* Write stuff to disk before trying to play it. Help analysis later. */ 297 314 rc = AudioTestSetObjWrite(pObj, abBuf, cbToPlay); 298 315 if (RT_SUCCESS(rc)) 316 { 299 317 rc = AudioTestMixStreamPlay(&pStream->Mix, abBuf, cbToPlay, &cbPlayed); 318 if (RT_SUCCESS(rc)) 319 { 320 offStream += cbPlayed; 321 } 322 } 300 323 } 301 324 … … 311 334 cbToPlayTotal -= cbPlayed; 312 335 } 336 337 if (RT_SUCCESS(rc)) 338 rc = AudioTestMixStreamDrain(&pStream->Mix, true /*fSync*/); 313 339 314 340 if (cbToPlayTotal != 0)
Note:
See TracChangeset
for help on using the changeset viewer.