Changeset 89531 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jun 7, 2021 12:12:46 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostAudioPulseAudio.cpp
r89528 r89531 154 154 * won't do any after-freed accesses.) */ 155 155 pa_operation *pTriggerOp; 156 /** Output: Current latency (in microsecs). */157 uint64_t cUsLatency;156 /** Internal byte offset. */ 157 uint64_t offInternal; 158 158 #ifdef LOG_ENABLED 159 159 /** Creation timestamp (in microsecs) of stream playback / recording. */ … … 1252 1252 LogRel2(("PulseAudio: Requesting: BufAttr: tlength=%#RX32 minReq=%#RX32 prebuf=%#RX32 maxLength=%#RX32\n", 1253 1253 pStreamPA->BufAttr.tlength, pStreamPA->BufAttr.minreq, pStreamPA->BufAttr.prebuf, pStreamPA->BufAttr.maxlength)); 1254 1255 /* This (cUsLatency) isn't used for anything. */1256 pStreamPA->cUsLatency = PDMAudioPropsFramesToMicro(&pCfgAcq->Props, pCfgReq->Backend.cFramesBufferSize);1257 LogRel2(("PulseAudio: Initial output latency is %RU64 us (%RU32 bytes)\n",1258 pStreamPA->cUsLatency, pStreamPA->BufAttr.tlength));1259 1254 } 1260 1255 … … 1292 1287 pCfgAcq->Backend.cFramesBufferSize = PDMAudioPropsBytesToFrames(&pCfgAcq->Props, pStreamPA->BufAttr.tlength); 1293 1288 pCfgAcq->Backend.cFramesPreBuffering = PDMAudioPropsBytesToFrames(&pCfgAcq->Props, pStreamPA->BufAttr.prebuf); 1289 1290 LogRel2(("PulseAudio: Initial output latency is %RU64 us (%RU32 bytes)\n", 1291 PDMAudioPropsBytesToMicro(&pCfgAcq->Props, pStreamPA->BufAttr.tlength), pStreamPA->BufAttr.tlength)); 1294 1292 } 1295 1293 … … 1436 1434 : drvHstAudPaError(pThis, "pa_stream_cork('%s', 0 /*uncork it*/,,) failed", pStreamPA->Cfg.szName); 1437 1435 1436 pStreamPA->offInternal = 0; 1438 1437 1439 1438 pa_threaded_mainloop_unlock(pThis->pMainLoop); … … 1612 1611 */ 1613 1612 int rc = VINF_SUCCESS; 1614 if (true /** @todo skip this if we're already playing or haven't written any data to the stream since xxxx. */) 1613 if ( pStreamPA->offInternal 1614 < PDMAudioPropsFramesToBytes(&pStreamPA->Cfg.Props, pStreamPA->Cfg.Backend.cFramesPreBuffering) * 2) 1615 1615 { 1616 1616 if (pStreamPA->pTriggerOp) … … 1781 1781 #ifdef LOG_ENABLED 1782 1782 const pa_usec_t tsNowUs = pa_rtclock_now(); 1783 Log3Func(("play delta: %'RI64 us; cbBuf=%#x \n",1784 pStreamPA->tsLastReadWrittenUs ? tsNowUs - pStreamPA->tsLastReadWrittenUs : -1, cbBuf ));1783 Log3Func(("play delta: %'RI64 us; cbBuf=%#x @%#RX64\n", 1784 pStreamPA->tsLastReadWrittenUs ? tsNowUs - pStreamPA->tsLastReadWrittenUs : -1, cbBuf, pStreamPA->offInternal)); 1785 1785 pStreamPA->tsLastReadWrittenUs = tsNowUs; 1786 1786 #endif … … 1802 1802 if (pa_stream_write(pStreamPA->pStream, pvBuf, cbToWrite, NULL /*pfnFree*/, 0 /*offset*/, PA_SEEK_RELATIVE) >= 0) 1803 1803 { 1804 cbTotalWritten += cbToWrite; 1805 cbBuf -= cbToWrite; 1804 cbTotalWritten += cbToWrite; 1805 cbBuf -= cbToWrite; 1806 pStreamPA->offInternal += cbToWrite; 1806 1807 if (!cbBuf) 1807 1808 break; … … 1833 1834 rc = VINF_SUCCESS; 1834 1835 } 1835 Log3Func(("returns %Rrc *pcbWritten=%#x iLoop=%u \n", rc, cbTotalWritten, iLoop));1836 Log3Func(("returns %Rrc *pcbWritten=%#x iLoop=%u @%#RX64\n", rc, cbTotalWritten, iLoop, pStreamPA->offInternal)); 1836 1837 return rc; 1837 1838 } … … 1893 1894 #ifdef LOG_ENABLED 1894 1895 const pa_usec_t tsNowUs = pa_rtclock_now(); 1895 Log3Func(("capture delta: %'RI64 us; cbBuf=%#x \n",1896 pStreamPA->tsLastReadWrittenUs ? tsNowUs - pStreamPA->tsLastReadWrittenUs : -1, cbBuf ));1896 Log3Func(("capture delta: %'RI64 us; cbBuf=%#x @%#RX64\n", 1897 pStreamPA->tsLastReadWrittenUs ? tsNowUs - pStreamPA->tsLastReadWrittenUs : -1, cbBuf, pStreamPA->offInternal)); 1897 1898 pStreamPA->tsLastReadWrittenUs = tsNowUs; 1898 1899 #endif … … 1910 1911 { 1911 1912 memcpy(pvBuf, &pStreamPA->pbPeekBuf[pStreamPA->offPeekBuf], cbBuf); 1912 pStreamPA->offPeekBuf += cbBuf; 1913 *pcbRead = cbBuf; 1913 pStreamPA->offPeekBuf += cbBuf; 1914 pStreamPA->offInternal += cbBuf; 1915 *pcbRead = cbBuf; 1916 1914 1917 if (cbToCopy == cbBuf) 1915 1918 { … … 1920 1923 pa_threaded_mainloop_unlock(pThis->pMainLoop); 1921 1924 } 1922 Log3Func(("returns *pcbRead=%#x from prev peek buf (%#x/%#x)\n", cbBuf, pStreamPA->offPeekBuf, pStreamPA->cbPeekBuf)); 1925 Log3Func(("returns *pcbRead=%#x from prev peek buf (%#x/%#x) @%#RX64\n", 1926 cbBuf, pStreamPA->offPeekBuf, pStreamPA->cbPeekBuf, pStreamPA->offInternal)); 1923 1927 return VINF_SUCCESS; 1924 1928 } … … 1970 1974 { 1971 1975 memcpy(pvBuf, pStreamPA->pbPeekBuf, cbBuf); 1972 cbTotalRead += cbBuf; 1973 pStreamPA->offPeekBuf = cbBuf; 1976 cbTotalRead += cbBuf; 1977 pStreamPA->offPeekBuf = cbBuf; 1978 pStreamPA->offInternal += cbBuf; 1974 1979 cbBuf = 0; 1975 1980 break; 1976 1981 } 1977 1982 memcpy(pvBuf, pStreamPA->pbPeekBuf, pStreamPA->cbPeekBuf); 1978 cbBuf -= pStreamPA->cbPeekBuf; 1979 pvBuf = (uint8_t *)pvBuf + pStreamPA->cbPeekBuf; 1980 cbTotalRead += pStreamPA->cbPeekBuf; 1981 1982 pStreamPA->pbPeekBuf = NULL; 1983 cbBuf -= pStreamPA->cbPeekBuf; 1984 pvBuf = (uint8_t *)pvBuf + pStreamPA->cbPeekBuf; 1985 cbTotalRead += pStreamPA->cbPeekBuf; 1986 pStreamPA->offInternal += cbBuf; 1987 1988 pStreamPA->pbPeekBuf = NULL; 1983 1989 } 1984 1990 else … … 2026 2032 rc = VINF_SUCCESS; 2027 2033 } 2028 Log3Func(("returns %Rrc *pcbRead=%#x (%#x left, peek %#x/%#x) \n",2029 rc, cbTotalRead, cbBuf, pStreamPA->offPeekBuf, pStreamPA->cbPeekBuf ));2034 Log3Func(("returns %Rrc *pcbRead=%#x (%#x left, peek %#x/%#x) @%#RX64\n", 2035 rc, cbTotalRead, cbBuf, pStreamPA->offPeekBuf, pStreamPA->cbPeekBuf, pStreamPA->offInternal)); 2030 2036 return rc; 2031 2037 }
Note:
See TracChangeset
for help on using the changeset viewer.