Changeset 87270 in vbox
- Timestamp:
- Jan 15, 2021 1:06:46 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142229
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r87173 r87270 847 847 pSink->VolumeCombined.uLeft = PDMAUDIO_VOLUME_MAX; 848 848 pSink->VolumeCombined.uRight = PDMAUDIO_VOLUME_MAX; 849 850 const size_t cbScratchBuf = _1K; /** @todo Make this configurable? */ 851 852 pSink->pabScratchBuf = (uint8_t *)RTMemAlloc(cbScratchBuf); 853 AssertPtrReturn(pSink->pabScratchBuf, VERR_NO_MEMORY); 854 pSink->cbScratchBuf = cbScratchBuf; 849 855 } 850 856 … … 916 922 RTStrFree(pSink->pszName); 917 923 pSink->pszName = NULL; 924 } 925 926 if (pSink->pabScratchBuf) 927 { 928 Assert(pSink->cbScratchBuf); 929 930 RTMemFree(pSink->pabScratchBuf); 931 pSink->pabScratchBuf = NULL; 932 933 pSink->cbScratchBuf = 0; 918 934 } 919 935 … … 1675 1691 return rc; 1676 1692 1693 /* Sanity. */ 1694 AssertPtr(pSink->pabScratchBuf); 1695 Assert(pSink->cbScratchBuf); 1696 1677 1697 /* Update each mixing sink stream's status. */ 1678 1698 PAUDMIXSTREAM pMixStream; … … 1689 1709 uint32_t cbToWriteToStreams = AudioMixBufUsedBytes(&pSink->MixBuf); 1690 1710 1691 uint8_t arrChunkBuf[_1K]; /** @todo Hm ... some zero copy / shared buffers would be nice! */1692 1711 while (cbToWriteToStreams) 1693 1712 { 1694 1713 uint32_t cfChunk; 1695 rc = AudioMixBufAcquireReadBlock(&pSink->MixBuf, arrChunkBuf, RT_MIN(cbToWriteToStreams, sizeof(arrChunkBuf)), &cfChunk); 1714 rc = AudioMixBufAcquireReadBlock(&pSink->MixBuf, pSink->pabScratchBuf, RT_MIN(cbToWriteToStreams, pSink->cbScratchBuf), 1715 &cfChunk); 1696 1716 if (RT_FAILURE(rc)) 1697 1717 break; 1698 1718 1699 1719 const uint32_t cbChunk = DrvAudioHlpFramesToBytes(cfChunk, &pSink->PCMProps); 1700 Assert(cbChunk <= sizeof(arrChunkBuf));1720 Assert(cbChunk <= pSink->cbScratchBuf); 1701 1721 1702 1722 /* Multiplex the current chunk in a synchronized fashion to all connected streams. */ 1703 1723 uint32_t cbChunkWrittenMin = 0; 1704 rc = audioMixerSinkMultiplexSync(pSink, AUDMIXOP_COPY, arrChunkBuf, cbChunk, &cbChunkWrittenMin);1724 rc = audioMixerSinkMultiplexSync(pSink, AUDMIXOP_COPY, pSink->pabScratchBuf, cbChunk, &cbChunkWrittenMin); 1705 1725 if (RT_SUCCESS(rc)) 1706 1726 { -
trunk/src/VBox/Devices/Audio/AudioMixer.h
r82968 r87270 194 194 * a parent buffer for all streams this sink owns. */ 195 195 PDMAUDIOMIXBUF MixBuf; 196 /** Scratch buffer for multiplexing / mixing. Might be NULL if not needed. */ 197 uint8_t *pabScratchBuf; 198 /** Size (in bytes) of pabScratchBuf. Might be 0 if not needed. */ 199 size_t cbScratchBuf; 196 200 /** Union for input/output specifics. */ 197 201 union
Note:
See TracChangeset
for help on using the changeset viewer.