Changeset 77602 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Mar 7, 2019 3:10:01 PM (6 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r77184 r77602 105 105 int audioMixerStreamCtlInternal(PAUDMIXSTREAM pMixStream, PDMAUDIOSTREAMCMD enmCmd, uint32_t fCtl); 106 106 static void audioMixerStreamDestroyInternal(PAUDMIXSTREAM pStream); 107 static int audioMixerStreamUpdateStatus(PAUDMIXSTREAM pMixStream); 107 108 108 109 … … 1148 1149 Log3Func(("[%s] No recording source specified, skipping ...\n", pSink->pszName)); 1149 1150 } 1150 else if (!DrvAudioHlpStreamStatusCanRead( 1151 pStreamRecSource->pConn->pfnStreamGetStatus(pStreamRecSource->pConn, pStreamRecSource->pStream))) 1151 else if (!(pStreamRecSource->fStatus & AUDMIXSTREAM_STATUS_ENABLED)) 1152 1152 { 1153 1153 Log3Func(("[%s] Stream '%s' disabled, skipping ...\n", pSink->pszName, pStreamRecSource->pszName)); … … 1594 1594 return rc; 1595 1595 1596 /* Update each mixing sink stream's status. */ 1597 PAUDMIXSTREAM pMixStream; 1598 RTListForEach(&pSink->lstStreams, pMixStream, AUDMIXSTREAM, Node) 1599 { 1600 int rc2 = audioMixerStreamUpdateStatus(pMixStream); 1601 AssertRC(rc2); 1602 } 1603 1596 1604 /* Number of disabled streams of this sink. */ 1597 1605 uint8_t cStreamsDisabled = pSink->cStreams; … … 1616 1624 if (RT_SUCCESS(rc)) 1617 1625 { 1618 PAUDMIXSTREAM pMixStream;1619 1626 RTListForEach(&pSink->lstStreams, pMixStream, AUDMIXSTREAM, Node) 1620 1627 { … … 1643 1650 } 1644 1651 1645 PAUDMIXSTREAM pMixStream, pMixStreamNext; 1646 RTListForEachSafe(&pSink->lstStreams, pMixStream, pMixStreamNext, AUDMIXSTREAM, Node) 1652 RTListForEach(&pSink->lstStreams, pMixStream, AUDMIXSTREAM, Node) 1647 1653 { 1648 1654 /* Input sink and not the recording source? Skip. */ … … 1659 1665 uint32_t cfProc = 0; 1660 1666 1661 if (! DrvAudioHlpStreamStatusIsReady(pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream)))1667 if (!(pMixStream->fStatus & AUDMIXSTREAM_STATUS_ENABLED)) 1662 1668 continue; 1663 1669 … … 1693 1699 } 1694 1700 1695 PDMAUDIOSTREAMSTS strmSts= pConn->pfnStreamGetStatus(pConn, pStream);1701 const PDMAUDIOSTREAMSTS streamStatusNew = pConn->pfnStreamGetStatus(pConn, pStream); 1696 1702 1697 1703 /* Is the stream enabled or in pending disable state? 1698 1704 * Don't consider this stream as being disabled then. */ 1699 if ( (str mSts& PDMAUDIOSTREAMSTS_FLAG_ENABLED)1700 || (str mSts& PDMAUDIOSTREAMSTS_FLAG_PENDING_DISABLE))1705 if ( (streamStatusNew & PDMAUDIOSTREAMSTS_FLAG_ENABLED) 1706 || (streamStatusNew & PDMAUDIOSTREAMSTS_FLAG_PENDING_DISABLE)) 1701 1707 { 1702 1708 cStreamsDisabled--; 1703 1709 } 1710 /* Note: The mixer stream's internal status will be updated in the next iteration of this function. */ 1704 1711 1705 1712 Log3Func(("\t%s: cPlayed/cCaptured=%RU32, rc2=%Rrc\n", pStream->szName, cfProc, rc2)); … … 1814 1821 1815 1822 if ( !cbToWrite 1816 || ! DrvAudioHlpStreamStatusCanWrite(pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream)))1823 || !(pMixStream->fStatus & AUDMIXSTREAM_STATUS_ENABLED)) 1817 1824 { 1818 1825 if (pcbWritten) … … 1921 1928 RTListForEach(&pSink->lstStreams, pMixStream, AUDMIXSTREAM, Node) 1922 1929 { 1923 if (!DrvAudioHlpStreamStatusCanWrite(pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream))) 1930 if (!(pMixStream->fStatus & AUDMIXSTREAM_STATUS_ENABLED)) /* Mixing stream not enabled? Skip handling. */ 1931 { 1932 Log3Func(("[%s] Stream '%s' disabled, skipping ...\n", pSink->pszName, pMixStream->pszName)); 1924 1933 continue; 1934 } 1925 1935 1926 1936 cbToWriteMin = RT_MIN(cbBuf, RT_MIN(cbToWriteMin, (uint32_t)RTCircBufFree(pMixStream->pCircBuf))); … … 1934 1944 RTListForEach(&pSink->lstStreams, pMixStream, AUDMIXSTREAM, Node) 1935 1945 { 1946 if (!(pMixStream->fStatus & AUDMIXSTREAM_STATUS_ENABLED)) /* Mixing stream not enabled? Skip handling. */ 1947 continue; 1948 1936 1949 PRTCIRCBUF pCircBuf = pMixStream->pCircBuf; 1937 1950 void *pvChunk; … … 2060 2073 2061 2074 /** 2075 * Updates a mixer stream's internal status. 2076 * 2077 * @returns VBox status code. 2078 * @param pMixStream Mixer stream to to update internal status for. 2079 */ 2080 static int audioMixerStreamUpdateStatus(PAUDMIXSTREAM pMixStream) 2081 { 2082 pMixStream->fStatus = AUDMIXSTREAM_STATUS_NONE; 2083 2084 if (pMixStream->pConn) /* Audio connector available? */ 2085 { 2086 const uint32_t fStreamStatus = pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream); 2087 2088 if (DrvAudioHlpStreamStatusIsReady(fStreamStatus)) 2089 pMixStream->fStatus |= AUDMIXSTREAM_STATUS_ENABLED; 2090 2091 AssertPtr(pMixStream->pSink); 2092 switch (pMixStream->pSink->enmDir) 2093 { 2094 case AUDMIXSINKDIR_INPUT: 2095 if (DrvAudioHlpStreamStatusCanRead(fStreamStatus)) 2096 pMixStream->fStatus |= AUDMIXSTREAM_STATUS_CAN_READ; 2097 break; 2098 2099 case AUDMIXSINKDIR_OUTPUT: 2100 if (DrvAudioHlpStreamStatusCanWrite(fStreamStatus)) 2101 pMixStream->fStatus |= AUDMIXSTREAM_STATUS_CAN_WRITE; 2102 break; 2103 2104 default: 2105 AssertFailedReturn(VERR_NOT_IMPLEMENTED); 2106 break; 2107 } 2108 } 2109 2110 LogFlowFunc(("[%s] -> 0x%x\n", pMixStream->pszName, pMixStream->fStatus)); 2111 return VINF_SUCCESS; 2112 } 2113 2114 /** 2062 2115 * Controls a mixer stream. 2063 2116 * -
trunk/src/VBox/Devices/Audio/AudioMixer.h
r76777 r77602 52 52 /** No flags specified. */ 53 53 #define AUDMIXSTREAM_FLAG_NONE 0 54 /** The mixing stream is flagged as being enabled (active). */ 55 #define AUDMIXSTREAM_FLAG_ENABLED RT_BIT(0) 56 57 /** Defines an audio mixer stream's internal status. */ 58 #define AUDMIXSTREAMSTATUS uint32_t 59 60 /** No status set. */ 61 #define AUDMIXSTREAM_STATUS_NONE 0 62 /** The mixing stream is enabled (active). */ 63 #define AUDMIXSTREAM_STATUS_ENABLED RT_BIT(0) 64 /** The mixing stream can be read from. */ 65 #define AUDMIXSTREAM_STATUS_CAN_READ RT_BIT(1) 66 /** The mixing stream can be written to. */ 67 #define AUDMIXSTREAM_STATUS_CAN_WRITE RT_BIT(2) 68 54 69 55 70 /** Prototype needed for AUDMIXSTREAM struct definition. */ … … 71 86 /** Stream flags of type AUDMIXSTREAM_FLAG_. */ 72 87 uint32_t fFlags; 88 /** Stream status of type AUDMIXSTREAM_STATUS_. */ 89 uint32_t fStatus; 73 90 /** Pointer to audio connector being used. */ 74 91 PPDMIAUDIOCONNECTOR pConn;
Note:
See TracChangeset
for help on using the changeset viewer.