Changeset 88443 in vbox
- Timestamp:
- Apr 9, 2021 5:21:32 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143695
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r88433 r88443 525 525 } 526 526 527 if (RT_SUCCESS(rc) )527 if (RT_SUCCESS(rc) && pSink->enmDir != AUDMIXSINKDIR_OUTPUT) 528 528 { 529 529 /* Apply the sink's combined volume to the stream. */ … … 1810 1810 AudioMixBufLive(&pSink->MixBuf), cFramesToRead, cWritableStreams)); 1811 1811 1812 if (cWritableStreams )1813 { 1814 /*1815 * For each of the enabled streams, convert cFramesToRead frames from1816 * the mixing buffer and write that to the downstream driver.1817 */1818 RTListForEach(&pSink->lstStreams, pMixStream, AUDMIXSTREAM, Node)1819 {1820 if (pMixStream->fStatus & AUDMIXSTREAM_STATUS_ENABLED)1812 if (cWritableStreams > 0) 1813 { 1814 if (cFramesToRead > 0) 1815 { 1816 /* 1817 * For each of the enabled streams, convert cFramesToRead frames from 1818 * the mixing buffer and write that to the downstream driver. 1819 */ 1820 RTListForEach(&pSink->lstStreams, pMixStream, AUDMIXSTREAM, Node) 1821 1821 { 1822 uint32_t offSrcFrame = 0; 1823 do 1822 if (pMixStream->fStatus & AUDMIXSTREAM_STATUS_ENABLED) 1824 1823 { 1825 /* Convert a chunk from the mixer buffer. */1826 union1824 uint32_t offSrcFrame = 0; 1825 do 1827 1826 { 1828 uint8_t ab[8192]; 1829 uint64_t au64[8192 / sizeof(uint64_t)]; /* Use uint64_t to ensure good alignment. */ 1830 } Buf; 1831 uint32_t cbDstPeeked = sizeof(Buf); 1832 uint32_t cSrcFramesPeeked = cFramesToRead - offSrcFrame; 1833 AudioMixBufPeek(&pSink->MixBuf, offSrcFrame, cSrcFramesPeeked, &cSrcFramesPeeked, 1834 &pMixStream->PeekState, &Buf, sizeof(Buf), &cbDstPeeked); 1835 offSrcFrame += cSrcFramesPeeked; 1836 1837 /* Write it to the backend. Since've checked that there is buffer 1838 space available, this should always write the whole buffer. */ 1839 uint32_t cbDstWritten = 0; 1840 int rc2 = pMixStream->pConn->pfnStreamWrite(pMixStream->pConn, pMixStream->pStream, 1841 &Buf, cbDstPeeked, &cbDstWritten); 1842 Log3Func(("%s: %#x L %#x => %#x bytes; wrote %#x rc2=%Rrc %s\n", pSink->pszName, offSrcFrame, 1843 cSrcFramesPeeked - cSrcFramesPeeked, cbDstPeeked, cbDstWritten, rc2, pMixStream->pszName)); 1844 if (RT_SUCCESS(rc2)) 1845 AssertLogRelMsg(cbDstWritten == cbDstPeeked, 1846 ("cbDstWritten=%#x cbDstPeeked=%#x - (sink '%s')\n", 1847 cbDstWritten, cbDstPeeked, pSink->pszName)); 1848 else if (rc2 == VERR_AUDIO_STREAM_NOT_READY) 1849 { 1850 LogRel2(("Audio Mixer: '%s' (sink '%s'): Stream not ready - skipping.\n", pMixStream->pszName, pSink->pszName)); 1851 break; /* must've changed status, stop processing */ 1852 } 1853 else 1854 { 1855 Assert(rc2 != VERR_BUFFER_OVERFLOW); 1856 LogRel2(("Audio Mixer: Writing to mixer stream '%s' (sink '%s') failed, rc=%Rrc\n", 1857 pMixStream->pszName, pSink->pszName, rc2)); 1858 break; 1859 } 1860 } while (offSrcFrame < cFramesToRead); 1861 Assert(offSrcFrame == cFramesToRead); 1827 /* Convert a chunk from the mixer buffer. */ 1828 union 1829 { 1830 uint8_t ab[8192]; 1831 uint64_t au64[8192 / sizeof(uint64_t)]; /* Use uint64_t to ensure good alignment. */ 1832 } Buf; 1833 uint32_t cbDstPeeked = sizeof(Buf); 1834 uint32_t cSrcFramesPeeked = cFramesToRead - offSrcFrame; 1835 AudioMixBufPeek(&pSink->MixBuf, offSrcFrame, cSrcFramesPeeked, &cSrcFramesPeeked, 1836 &pMixStream->PeekState, &Buf, sizeof(Buf), &cbDstPeeked); 1837 offSrcFrame += cSrcFramesPeeked; 1838 1839 /* Write it to the backend. Since've checked that there is buffer 1840 space available, this should always write the whole buffer. */ 1841 uint32_t cbDstWritten = 0; 1842 int rc2 = pMixStream->pConn->pfnStreamWrite(pMixStream->pConn, pMixStream->pStream, 1843 &Buf, cbDstPeeked, &cbDstWritten); 1844 Log3Func(("%s: %#x L %#x => %#x bytes; wrote %#x rc2=%Rrc %s\n", pSink->pszName, offSrcFrame, 1845 cSrcFramesPeeked - cSrcFramesPeeked, cbDstPeeked, cbDstWritten, rc2, pMixStream->pszName)); 1846 if (RT_SUCCESS(rc2)) 1847 AssertLogRelMsg(cbDstWritten == cbDstPeeked, 1848 ("cbDstWritten=%#x cbDstPeeked=%#x - (sink '%s')\n", 1849 cbDstWritten, cbDstPeeked, pSink->pszName)); 1850 else if (rc2 == VERR_AUDIO_STREAM_NOT_READY) 1851 { 1852 LogRel2(("Audio Mixer: '%s' (sink '%s'): Stream not ready - skipping.\n", 1853 pMixStream->pszName, pSink->pszName)); 1854 break; /* must've changed status, stop processing */ 1855 } 1856 else 1857 { 1858 Assert(rc2 != VERR_BUFFER_OVERFLOW); 1859 LogRel2(("Audio Mixer: Writing to mixer stream '%s' (sink '%s') failed, rc=%Rrc\n", 1860 pMixStream->pszName, pSink->pszName, rc2)); 1861 break; 1862 } 1863 } while (offSrcFrame < cFramesToRead); 1864 } 1862 1865 } 1863 } 1864 1865 AudioMixBufAdvance(&pSink->MixBuf, cFramesToRead);1866 1867 AudioMixBufAdvance(&pSink->MixBuf, cFramesToRead); 1868 } 1866 1869 1867 1870 /*
Note:
See TracChangeset
for help on using the changeset viewer.