- Timestamp:
- Aug 14, 2018 11:22:28 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r73582 r73645 1709 1709 size_t cbChunk; 1710 1710 1711 uint32_t cbWritten = 0;1712 uint32_t cbToWrite = RT_MIN(cbBuf, (uint32_t)RTCircBufFree(pCircBuf));1713 while (cbToWrite )1714 { 1715 RTCircBufAcquireWriteBlock(pCircBuf, cbToWrite , &pvChunk, &cbChunk);1711 uint32_t cbWrittenBuf = 0; 1712 uint32_t cbToWriteBuf = RT_MIN(cbBuf, (uint32_t)RTCircBufFree(pCircBuf)); 1713 while (cbToWriteBuf) 1714 { 1715 RTCircBufAcquireWriteBlock(pCircBuf, cbToWriteBuf, &pvChunk, &cbChunk); 1716 1716 1717 1717 if (cbChunk) 1718 memcpy(pvChunk, (uint8_t *)pvBuf + cbWritten , cbChunk);1718 memcpy(pvChunk, (uint8_t *)pvBuf + cbWrittenBuf, cbChunk); 1719 1719 1720 1720 RTCircBufReleaseWriteBlock(pCircBuf, cbChunk); 1721 1721 1722 cbWritten += (uint32_t)cbChunk; 1723 Assert(cbWritten <= cbBuf); 1724 1725 Assert(cbToWrite >= cbChunk); 1726 cbToWrite -= (uint32_t)cbChunk; 1727 } 1728 1729 if (cbWritten < cbBuf) 1722 cbWrittenBuf += (uint32_t)cbChunk; 1723 Assert(cbWrittenBuf <= cbBuf); 1724 1725 Assert(cbToWriteBuf >= cbChunk); 1726 cbToWriteBuf -= (uint32_t)cbChunk; 1727 } 1728 1729 cbWrittenMin = RT_MIN(cbWrittenMin, cbWrittenBuf); 1730 1731 if (cbWrittenBuf) /* Update the mixer stream's last written time stamp. */ 1732 pMixStream->tsLastReadWrittenNs = RTTimeNanoTS(); 1733 1734 uint32_t cbToWriteStream = DrvAudioHlpBytesAlign(cbWrittenBuf, &pSink->PCMProps); 1735 uint32_t cbWrittenStream = 0; 1736 1737 int rc2 = VINF_SUCCESS; 1738 1739 while (cbToWriteStream) 1740 { 1741 RTCircBufAcquireReadBlock(pCircBuf, cbToWriteStream, &pvChunk, &cbChunk); 1742 1743 uint32_t cbChunkWritten = 0; 1744 if (cbChunk) 1745 { 1746 rc2 = pMixStream->pConn->pfnStreamWrite(pMixStream->pConn, pMixStream->pStream, pvChunk, (uint32_t)cbChunk, 1747 &cbChunkWritten); 1748 if (RT_FAILURE(rc2)) 1749 LogFunc(("[%s] Failed writing to stream '%s': %Rrc\n", pSink->pszName, pMixStream->pszName, rc2)); 1750 #ifdef DEBUG_andy 1751 AssertRC(rc2); 1752 #endif 1753 } 1754 1755 RTCircBufReleaseReadBlock(pCircBuf, cbChunkWritten); 1756 1757 if (RT_FAILURE(rc2)) 1758 break; 1759 1760 Assert(cbToWriteStream >= cbChunk); 1761 cbToWriteStream -= (uint32_t)cbChunk; 1762 1763 cbWrittenStream += cbChunk; 1764 Assert(cbWrittenStream <= cbBuf); 1765 } 1766 1767 Log3Func(("[%s] cbBuf=%RU32, cbWrittenBuf=%RU32, cbWrittenStream=%RU32\n", 1768 pMixStream->pszName, cbBuf, cbWrittenBuf, cbWrittenStream)); 1769 1770 if (cbWrittenBuf < cbBuf) 1730 1771 { 1731 1772 LogFunc(("[%s] Warning: Only written %RU32/%RU32 bytes for stream '%s'\n", 1732 pSink->pszName, cbWritten , cbBuf, pMixStream->pszName));1773 pSink->pszName, cbWrittenBuf, cbBuf, pMixStream->pszName)); 1733 1774 LogRel2(("Mixer: Buffer overrun for mixer stream '%s' (sink '%s')\n", pMixStream->pszName, pSink->pszName)); 1734 1775 #ifdef DEBUG_andy 1735 1776 AssertFailed(); 1736 1777 #endif 1737 }1738 1739 cbWrittenMin = RT_MIN(cbWrittenMin, cbWritten);1740 1741 if (cbWritten) /* Update the mixer stream's last written time stamp. */1742 pMixStream->tsLastReadWrittenNs = RTTimeNanoTS();1743 1744 cbToWrite = RT_MIN(pMixStream->pConn->pfnStreamGetWritable(pMixStream->pConn, pMixStream->pStream),1745 (uint32_t)RTCircBufUsed(pCircBuf));1746 cbToWrite = DrvAudioHlpBytesAlign(cbToWrite, &pSink->PCMProps);1747 1748 int rc2 = VINF_SUCCESS;1749 1750 while (cbToWrite)1751 {1752 RTCircBufAcquireReadBlock(pCircBuf, cbToWrite, &pvChunk, &cbChunk);1753 1754 if (cbChunk)1755 {1756 rc2 = pMixStream->pConn->pfnStreamWrite(pMixStream->pConn, pMixStream->pStream, pvChunk, (uint32_t)cbChunk,1757 &cbWritten);1758 if (RT_FAILURE(rc2))1759 LogFunc(("[%s] Failed writing to stream '%s': %Rrc\n", pSink->pszName, pMixStream->pszName, rc2));1760 }1761 1762 RTCircBufReleaseReadBlock(pCircBuf, cbWritten);1763 1764 if ( !cbWritten1765 || cbWritten < cbChunk)1766 {1767 #ifdef DEBUG_andy1768 AssertFailed();1769 #endif1770 break;1771 }1772 1773 if (RT_FAILURE(rc2))1774 break;1775 1776 Assert(cbToWrite >= cbChunk);1777 cbToWrite -= (uint32_t)cbChunk;1778 1778 } 1779 1779 }
Note:
See TracChangeset
for help on using the changeset viewer.