Changeset 70926 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Feb 9, 2018 9:56:43 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 120754
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp
r70925 r70926 120 120 /** Whether this stream is in an enable state on the DirectSound side. */ 121 121 bool fEnabled; 122 /** The stream's critical section for synchronizing access. */ 122 123 RTCRITSECT CritSect; 124 /** The internal playback / capturing buffer. */ 123 125 PRTCIRCBUF pCircBuf; 126 /** Size (in bytes) of the DirectSound buffer. 127 * Note: This in *not* the size of the circular buffer above! */ 128 DWORD cbBufSize; 124 129 union 125 130 { … … 131 136 /** Current read offset (in bytes) within the DSB. */ 132 137 DWORD offReadPos; 133 /** Size (in bytes) of the DirectSound buffer. */134 DWORD cbBufSize;135 138 } In; 136 139 struct … … 147 150 /** Total amount (in bytes) written. */ 148 151 uint64_t cbWritten; 149 /** Size (in bytes) of the DirectSound buffer. */150 DWORD cbBufSize;151 152 /** Flag indicating whether playback was (re)started. */ 152 153 bool fFirstPlayback; 153 uint64_t tsLastPlayMs; 154 bool fPendingPlayback; 155 bool fPendingClose; 154 /** Timestamp (in ms) of When the last playback has happened. */ 155 uint64_t tsLastPlayMs; 156 156 } Out; 157 157 }; … … 308 308 int32_t cbDiff = cbWriteCursor - cbPlayCursor; 309 309 if (cbDiff < 0) 310 cbDiff += pStreamDS-> Out.cbBufSize;310 cbDiff += pStreamDS->cbBufSize; 311 311 312 312 int32_t cbFree = cbPlayCursor - pStreamDS->Out.offWritePos; 313 313 if (cbFree < 0) 314 cbFree += pStreamDS-> Out.cbBufSize;315 316 if (cbFree > (int32_t)pStreamDS-> Out.cbBufSize - cbDiff)314 cbFree += pStreamDS->cbBufSize; 315 316 if (cbFree > (int32_t)pStreamDS->cbBufSize - cbDiff) 317 317 { 318 318 pStreamDS->Out.offWritePos = cbWriteCursor; 319 cbFree = pStreamDS-> Out.cbBufSize - cbDiff;319 cbFree = pStreamDS->cbBufSize - cbDiff; 320 320 } 321 321 … … 326 326 * So use our per-stream written indicator to see if we just started a stream. */ 327 327 if (pStreamDS->Out.cbWritten == 0) 328 cbFree = pStreamDS-> Out.cbBufSize;328 cbFree = pStreamDS->cbBufSize; 329 329 330 330 DSLOGREL(("DSound: cbPlayCursor=%RU32, cbWriteCursor=%RU32, offWritePos=%RU32 -> cbFree=%RI32\n", … … 761 761 * playback buffer position. 762 762 */ 763 pStreamDS-> Out.cbBufSize = bc.dwBufferBytes;763 pStreamDS->cbBufSize = bc.dwBufferBytes; 764 764 765 765 RTCritSectEnter(&pThis->CritSect); 766 766 767 rc = RTCircBufCreate(&pStreamDS->pCircBuf, pStreamDS-> Out.cbBufSize);767 rc = RTCircBufCreate(&pStreamDS->pCircBuf, pStreamDS->cbBufSize); 768 768 AssertRC(rc); 769 769 … … 781 781 dsPosNotify[0].hEventNotify = pThis->aEvents[DSOUNDEVENT_OUTPUT]; 782 782 783 dsPosNotify[1].dwOffset = float(pStreamDS-> Out.cbBufSize * 0.3);783 dsPosNotify[1].dwOffset = float(pStreamDS->cbBufSize * 0.3); 784 784 dsPosNotify[1].hEventNotify = pThis->aEvents[DSOUNDEVENT_OUTPUT]; 785 785 786 dsPosNotify[2].dwOffset = float(pStreamDS-> Out.cbBufSize * 0.6);786 dsPosNotify[2].dwOffset = float(pStreamDS->cbBufSize * 0.6); 787 787 dsPosNotify[2].hEventNotify = pThis->aEvents[DSOUNDEVENT_OUTPUT]; 788 788 … … 800 800 RTCritSectLeave(&pThis->CritSect); 801 801 802 pCfgAcq->cFrameBufferHint = PDMAUDIOSTREAMCFG_B2F(pCfgAcq, pStreamDS-> Out.cbBufSize);802 pCfgAcq->cFrameBufferHint = PDMAUDIOSTREAMCFG_B2F(pCfgAcq, pStreamDS->cbBufSize); 803 803 804 804 } while (0); … … 824 824 PVOID pv1; 825 825 hr = directSoundPlayLock(pThis, pStreamDS, 826 0 /* dwOffset */, pStreamDS-> Out.cbBufSize,826 0 /* dwOffset */, pStreamDS->cbBufSize, 827 827 &pv1, NULL, 0, 0, DSBLOCK_ENTIREBUFFER); 828 828 if (SUCCEEDED(hr)) 829 829 { 830 DrvAudioHlpClearBuf(pProps, pv1, pStreamDS-> Out.cbBufSize, PDMAUDIOPCMPROPS_B2F(pProps, pStreamDS->Out.cbBufSize));830 DrvAudioHlpClearBuf(pProps, pv1, pStreamDS->cbBufSize, PDMAUDIOPCMPROPS_B2F(pProps, pStreamDS->cbBufSize)); 831 831 832 832 directSoundPlayUnlock(pThis, pStreamDS->Out.pDSB, pv1, NULL, 0, 0); … … 1208 1208 1209 1209 /* Initial state: reading at the initial capture position, no error. */ 1210 pStreamDS->In.offReadPos 1211 pStreamDS-> In.cbBufSize = bc.dwBufferBytes;1212 1213 rc = RTCircBufCreate(&pStreamDS->pCircBuf, pStreamDS-> In.cbBufSize);1210 pStreamDS->In.offReadPos = 0; 1211 pStreamDS->cbBufSize = bc.dwBufferBytes; 1212 1213 rc = RTCircBufCreate(&pStreamDS->pCircBuf, pStreamDS->cbBufSize); 1214 1214 AssertRC(rc); 1215 1215 … … 1227 1227 dsPosNotify[0].hEventNotify = pThis->aEvents[DSOUNDEVENT_INPUT]; 1228 1228 1229 dsPosNotify[1].dwOffset = float(pStreamDS-> In.cbBufSize * 0.3);1229 dsPosNotify[1].dwOffset = float(pStreamDS->cbBufSize * 0.3); 1230 1230 dsPosNotify[1].hEventNotify = pThis->aEvents[DSOUNDEVENT_INPUT]; 1231 1231 1232 dsPosNotify[2].dwOffset = float(pStreamDS-> In.cbBufSize * 0.6);1232 dsPosNotify[2].dwOffset = float(pStreamDS->cbBufSize * 0.6); 1233 1233 dsPosNotify[2].hEventNotify = pThis->aEvents[DSOUNDEVENT_INPUT]; 1234 1234 … … 1242 1242 } 1243 1243 1244 pCfgAcq->cFrameBufferHint = PDMAUDIOSTREAMCFG_B2F(pCfgAcq, pStreamDS-> In.cbBufSize);1244 pCfgAcq->cFrameBufferHint = PDMAUDIOSTREAMCFG_B2F(pCfgAcq, pStreamDS->cbBufSize); 1245 1245 1246 1246 } while (0); … … 1556 1556 pStreamDS->Out.cbWritten = 0; 1557 1557 pStreamDS->Out.fFirstPlayback = true; 1558 pStreamDS->Out.fPendingPlayback = false;1559 1558 pStreamDS->Out.tsLastPlayMs = 0; 1560 pStreamDS-> Out.cbBufSize = 0;1559 pStreamDS->cbBufSize = 0; 1561 1560 1562 1561 int rc = VINF_SUCCESS; … … 1715 1714 1716 1715 /* Init the stream structure and save relevant information to it. */ 1717 pStreamDS->In.offReadPos 1718 pStreamDS-> In.cbBufSize = 0;1719 pStreamDS->In.pDSCB 1716 pStreamDS->In.offReadPos = 0; 1717 pStreamDS->cbBufSize = 0; 1718 pStreamDS->In.pDSCB = NULL; 1720 1719 1721 1720 int rc = VINF_SUCCESS; … … 1963 1962 break; 1964 1963 1965 DWORD cbUsed = dsoundRingDistance(offCaptureCursor, pStreamDS->In.offReadPos, pStreamDS-> In.cbBufSize);1964 DWORD cbUsed = dsoundRingDistance(offCaptureCursor, pStreamDS->In.offReadPos, pStreamDS->cbBufSize); 1966 1965 1967 1966 PRTCIRCBUF pCircBuf = pStreamDS->pCircBuf; … … 2001 2000 directSoundCaptureUnlock(pDSCB, pv1, pv2, cb1, cb2); 2002 2001 2003 pStreamDS->In.offReadPos = (pStreamDS->In.offReadPos + cb1 + cb2) % pStreamDS-> In.cbBufSize;2002 pStreamDS->In.offReadPos = (pStreamDS->In.offReadPos + cb1 + cb2) % pStreamDS->cbBufSize; 2004 2003 2005 2004 Assert(cbToCapture >= cbBuf); … … 2049 2048 pStreamDS->Out.offWritePos = offWriteCursor; 2050 2049 2051 cbFree = pStreamDS-> Out.cbBufSize;2052 cbRemaining = pStreamDS-> Out.cbBufSize;2050 cbFree = pStreamDS->cbBufSize; 2051 cbRemaining = pStreamDS->cbBufSize; 2053 2052 } 2054 2053 else … … 2059 2058 break; 2060 2059 2061 cbFree = dsoundRingDistance(offPlayCursor, pStreamDS->Out.offWritePos, pStreamDS-> Out.cbBufSize);2062 cbRemaining = dsoundRingDistance(pStreamDS->Out.offWritePos, offPlayCursor, pStreamDS-> Out.cbBufSize);2060 cbFree = dsoundRingDistance(offPlayCursor, pStreamDS->Out.offWritePos, pStreamDS->cbBufSize); 2061 cbRemaining = dsoundRingDistance(pStreamDS->Out.offWritePos, offPlayCursor, pStreamDS->cbBufSize); 2063 2062 } 2064 2063 … … 2099 2098 directSoundPlayUnlock(pThis, pDSB, pv1, pv2, cb1, cb2); 2100 2099 2101 pStreamDS->Out.offWritePos = (pStreamDS->Out.offWritePos + cb1 + cb2) % pStreamDS-> Out.cbBufSize;2100 pStreamDS->Out.offWritePos = (pStreamDS->Out.offWritePos + cb1 + cb2) % pStreamDS->cbBufSize; 2102 2101 2103 2102 Assert(cbToPlay >= cbBuf); … … 2131 2130 DSLOG(("DSound: Started playing output\n")); 2132 2131 pStreamDS->Out.fFirstPlayback = false; 2133 pStreamDS->Out.fPendingPlayback = true;2134 2132 } 2135 2133 }
Note:
See TracChangeset
for help on using the changeset viewer.