Changeset 70841 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Jan 31, 2018 4:09:11 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120653
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r70840 r70841 325 325 for (unsigned i = 0; i < DRV_DSOUND_RESTORE_ATTEMPTS_MAX; i++) 326 326 { 327 DWORD cbPlayCursor ;328 hr = IDirectSoundBuffer8_GetCurrentPosition(pDSB, &cbPlayCursor, NULL /* cbWriteCursor */);327 DWORD cbPlayCursor, cbWriteCursor; 328 hr = IDirectSoundBuffer8_GetCurrentPosition(pDSB, &cbPlayCursor, &cbWriteCursor); 329 329 if (SUCCEEDED(hr)) 330 330 { 331 *pdwFree = pStreamDS->Out.cbBufSize 332 - dsoundRingDistance(pStreamDS->Out.offWritePos, cbPlayCursor, pStreamDS->Out.cbBufSize); 331 int32_t cbDiff = cbWriteCursor - cbPlayCursor; 332 if (cbDiff < 0) 333 cbDiff += pStreamDS->Out.cbBufSize; 334 335 int32_t cbFree = cbPlayCursor - pStreamDS->Out.offWritePos; 336 if (cbFree < 0) 337 cbFree += pStreamDS->Out.cbBufSize; 338 339 if (cbFree > (int32_t)pStreamDS->Out.cbBufSize - cbDiff) 340 { 341 pStreamDS->Out.offWritePos = cbWriteCursor; 342 cbFree = pStreamDS->Out.cbBufSize - cbDiff; 343 } 344 345 /* When starting to use a DirectSound buffer, cbPlayCursor and cbWriteCursor 346 * both point at position 0, so we won't be able to detect how many bytes 347 * are writable that way. 348 * 349 * So use our per-stream written indicator to see if we just started a stream. */ 350 if (pStreamDS->Out.cbWritten == 0) 351 cbFree = pStreamDS->Out.cbBufSize; 352 353 DSLOGREL(("DSound: cbPlayCursor=%RU32, cbWriteCursor=%RU32, offWritePos=%RU32 -> cbFree=%RI32\n", 354 cbPlayCursor, cbWriteCursor, pStreamDS->Out.offWritePos, cbFree)); 355 356 *pdwFree = cbFree; 333 357 334 358 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.