Changeset 88884 in vbox for trunk/src/VBox/Devices
- Timestamp:
- May 5, 2021 6:27:18 PM (4 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/AudioMixer.cpp
r88724 r88884 1213 1213 Log3Func(("[%s] No recording source specified, skipping ...\n", pSink->pszName)); 1214 1214 } 1215 else if (!(pStreamRecSource->fStatus & AUDMIXSTREAM_STATUS_ENABLED)) 1215 else if (!(pStreamRecSource->fStatus & AUDMIXSTREAM_STATUS_ENABLED)) /** @todo r=bird: AUDMIXSTREAM_STATUS_CAN_READ ?*/ 1216 1216 { 1217 1217 Log3Func(("[%s] Stream '%s' disabled, skipping ...\n", pSink->pszName, pStreamRecSource->pszName)); … … 1692 1692 if (RT_SUCCESS(rc2)) 1693 1693 { 1694 /** @todo r=bird: Check for AUDMIXSTREAM_STATUS_CAN_READ? */ 1694 1695 rc2 = pMixStream->pConn->pfnStreamCapture(pMixStream->pConn, pMixStream->pStream, &cFramesCaptured); 1695 1696 if (RT_SUCCESS(rc2)) … … 1734 1735 if (pMixStream->fStatus & AUDMIXSTREAM_STATUS_ENABLED) 1735 1736 { 1736 uint32_t const fSts = pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream);1737 if ( fSts & (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_PENDING_DISABLE))1737 PDMAUDIOSTREAMSTATE const enmState = pMixStream->pConn->pfnStreamGetState(pMixStream->pConn, pMixStream->pStream); 1738 if (enmState >= PDMAUDIOSTREAMSTATE_ENABLED) 1738 1739 cStreamsDisabled--; 1739 1740 } … … 1777 1778 AssertRC(rc2); 1778 1779 1779 if (pMixStream->fStatus & AUDMIXSTREAM_STATUS_ ENABLED)1780 if (pMixStream->fStatus & AUDMIXSTREAM_STATUS_CAN_WRITE) 1780 1781 { 1781 1782 uint32_t const cbWritable = pMixStream->pConn->pfnStreamGetWritable(pMixStream->pConn, pMixStream->pStream); … … 1810 1811 RTListForEach(&pSink->lstStreams, pMixStream, AUDMIXSTREAM, Node) 1811 1812 { 1812 if (pMixStream->fStatus & AUDMIXSTREAM_STATUS_ ENABLED)1813 if (pMixStream->fStatus & AUDMIXSTREAM_STATUS_CAN_WRITE) 1813 1814 { 1814 1815 uint32_t offSrcFrame = 0; … … 1899 1900 if (pMixStream->fStatus & AUDMIXSTREAM_STATUS_ENABLED) 1900 1901 { 1901 uint32_t const fSts = pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream);1902 if ( fSts & (PDMAUDIOSTREAM_STS_ENABLED | PDMAUDIOSTREAM_STS_PENDING_DISABLE))1902 PDMAUDIOSTREAMSTATE const enmState = pMixStream->pConn->pfnStreamGetState(pMixStream->pConn, pMixStream->pStream); 1903 if (enmState >= PDMAUDIOSTREAMSTATE_ENABLED) 1903 1904 cStreamsDisabled--; 1904 1905 } … … 2081 2082 * Updates a mixer stream's internal status. 2082 2083 * 2084 * This may perform a stream re-init if the driver requests it, in which case 2085 * this may take a little while longer than usual... 2086 * 2083 2087 * @returns VBox status code. 2084 2088 * @param pMixStream Mixer stream to to update internal status for. … … 2095 2099 { 2096 2100 PPDMAUDIOSTREAM const pStream = pMixStream->pStream; 2097 PAUDMIXSINK const pSink = pMixStream->pSink;2098 AssertPtr(pSink);2099 2101 2100 2102 /* … … 2102 2104 * Do re-init if needed and fetch the status again afterwards. 2103 2105 */ 2104 uint32_t fStreamStatus = pConn->pfnStreamGetStatus(pConn, pStream);2105 if ( !(fStreamStatus & PDMAUDIOSTREAM_STS_NEED_REINIT))2106 PDMAUDIOSTREAMSTATE enmState = pConn->pfnStreamGetState(pConn, pStream); 2107 if (enmState != PDMAUDIOSTREAMSTATE_NEED_REINIT) 2106 2108 { /* likely */ } 2107 2109 else … … 2109 2111 LogFunc(("[%s] needs re-init...\n", pMixStream->pszName)); 2110 2112 int rc = pConn->pfnStreamReInit(pConn, pStream); 2111 fStreamStatus = pConn->pfnStreamGetStatus(pConn, pStream); 2112 LogFunc(("[%s] re-init returns %Rrc and %#x.\n", pMixStream->pszName, rc, fStreamStatus)); RT_NOREF(rc); 2113 enmState = pConn->pfnStreamGetState(pConn, pStream); 2114 LogFunc(("[%s] re-init returns %Rrc and %d.\n", pMixStream->pszName, rc, enmState)); 2115 2116 PAUDMIXSINK const pSink = pMixStream->pSink; 2117 AssertPtr(pSink); 2113 2118 if (pSink->enmDir == AUDMIXSINKDIR_OUTPUT) 2114 2119 { … … 2122 2127 * Translate the status to mixer speak. 2123 2128 */ 2124 if (PDMAudioStrmStatusIsReady(fStreamStatus)) 2125 pMixStream->fStatus |= AUDMIXSTREAM_STATUS_ENABLED; 2126 2127 switch (pSink->enmDir) 2128 { 2129 case AUDMIXSINKDIR_INPUT: 2130 if (PDMAudioStrmStatusCanRead(fStreamStatus)) 2131 pMixStream->fStatus |= AUDMIXSTREAM_STATUS_CAN_READ; 2129 AssertMsg(enmState > PDMAUDIOSTREAMSTATE_INVALID && enmState < PDMAUDIOSTREAMSTATE_END, ("%d\n", enmState)); 2130 switch (enmState) 2131 { 2132 case PDMAUDIOSTREAMSTATE_NOT_WORKING: 2133 case PDMAUDIOSTREAMSTATE_NEED_REINIT: 2134 case PDMAUDIOSTREAMSTATE_INACTIVE: 2135 pMixStream->fStatus = AUDMIXSTREAM_STATUS_NONE; 2132 2136 break; 2133 2134 case AUDMIXSINKDIR_OUTPUT: 2135 if (PDMAudioStrmStatusCanWrite(fStreamStatus)) 2136 pMixStream->fStatus |= AUDMIXSTREAM_STATUS_CAN_WRITE; 2137 case PDMAUDIOSTREAMSTATE_ENABLED: 2138 pMixStream->fStatus = AUDMIXSTREAM_STATUS_ENABLED; 2137 2139 break; 2138 2139 default: 2140 AssertFailedReturn(VERR_NOT_IMPLEMENTED); 2140 case PDMAUDIOSTREAMSTATE_ENABLED_READABLE: 2141 Assert(pMixStream->pSink->enmDir == AUDMIXSINKDIR_INPUT); 2142 pMixStream->fStatus = AUDMIXSTREAM_STATUS_ENABLED | AUDMIXSTREAM_STATUS_CAN_READ; 2143 break; 2144 case PDMAUDIOSTREAMSTATE_ENABLED_WRITABLE: 2145 Assert(pMixStream->pSink->enmDir == AUDMIXSINKDIR_OUTPUT); 2146 pMixStream->fStatus = AUDMIXSTREAM_STATUS_ENABLED | AUDMIXSTREAM_STATUS_CAN_WRITE; 2147 break; 2148 /* no default */ 2149 case PDMAUDIOSTREAMSTATE_INVALID: 2150 case PDMAUDIOSTREAMSTATE_END: 2151 case PDMAUDIOSTREAMSTATE_32BIT_HACK: 2141 2152 break; 2142 2153 } … … 2260 2271 } 2261 2272 2262 /**2263 * Returns whether a mixer stream currently is active (playing/recording) or not.2264 *2265 * @returns @c true if playing/recording, @c false if not.2266 * @param pMixStream Mixer stream to return status for.2267 */2268 bool AudioMixerStreamIsActive(PAUDMIXSTREAM pMixStream)2269 {2270 int rc2 = RTCritSectEnter(&pMixStream->CritSect);2271 if (RT_FAILURE(rc2))2272 return false;2273 2274 AssertPtr(pMixStream->pConn);2275 AssertPtr(pMixStream->pStream);2276 2277 bool fIsActive;2278 2279 if ( pMixStream->pConn2280 && pMixStream->pStream2281 && (pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream) & PDMAUDIOSTREAM_STS_ENABLED))2282 fIsActive = true;2283 else2284 fIsActive = false;2285 2286 rc2 = RTCritSectLeave(&pMixStream->CritSect);2287 AssertRC(rc2);2288 2289 return fIsActive;2290 }2291 2292 /**2293 * Returns whether a mixer stream is valid (e.g. initialized and in a working state) or not.2294 *2295 * @returns @c true if valid, @c false if not.2296 * @param pMixStream Mixer stream to return status for.2297 */2298 bool AudioMixerStreamIsValid(PAUDMIXSTREAM pMixStream)2299 {2300 if (!pMixStream)2301 return false;2302 2303 int rc2 = RTCritSectEnter(&pMixStream->CritSect);2304 if (RT_FAILURE(rc2))2305 return false;2306 2307 bool fIsValid;2308 2309 if ( pMixStream->pConn2310 && pMixStream->pStream2311 && (pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream) & PDMAUDIOSTREAM_STS_INITIALIZED))2312 fIsValid = true;2313 else2314 fIsValid = false;2315 2316 rc2 = RTCritSectLeave(&pMixStream->CritSect);2317 AssertRC(rc2);2318 2319 return fIsValid;2320 }2321 -
trunk/src/VBox/Devices/Audio/AudioMixer.h
r88452 r88884 70 70 #define AUDMIXSTREAMSTATUS uint32_t 71 71 72 /** @name AUDMIXSTREAM_STATUS_XXX - mixer stream status. 73 * (This is a destilled version of PDMAUDIOSTREAM_STS_XXX.) 74 * @{ */ 72 75 /** No status set. */ 73 76 #define AUDMIXSTREAM_STATUS_NONE 0 74 77 /** The mixing stream is enabled (active). */ 75 78 #define AUDMIXSTREAM_STATUS_ENABLED RT_BIT(0) 76 /** The mixing stream can be read from. */ 79 /** The mixing stream can be read from. 80 * Always set together with AUDMIXSTREAM_STATUS_ENABLED. */ 77 81 #define AUDMIXSTREAM_STATUS_CAN_READ RT_BIT(1) 78 /** The mixing stream can be written to. */ 82 /** The mixing stream can be written to. 83 * Always set together with AUDMIXSTREAM_STATUS_ENABLED. */ 79 84 #define AUDMIXSTREAM_STATUS_CAN_WRITE RT_BIT(2) 85 /** @} */ 80 86 81 87 … … 295 301 int AudioMixerStreamCtl(PAUDMIXSTREAM pStream, PDMAUDIOSTREAMCMD enmCmd, uint32_t fCtl); 296 302 void AudioMixerStreamDestroy(PAUDMIXSTREAM pStream, PPDMDEVINS pDevIns); 297 bool AudioMixerStreamIsActive(PAUDMIXSTREAM pStream);298 bool AudioMixerStreamIsValid(PAUDMIXSTREAM pStream);299 303 300 304 #endif /* !VBOX_INCLUDED_SRC_Audio_AudioMixer_h */ -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r88861 r88884 1989 1989 LogFunc(("[%s] Acquired host format: %s\n", 1990 1990 pStreamEx->Core.szName, PDMAudioStrmCfgToString(&CfgHostAcq, szTmp, sizeof(szTmp)) )); 1991 if (true) /** @todo Validate (re-)acquired configuration with pStreamEx->Core.Host.Cfg? */ 1991 /** @todo Validate (re-)acquired configuration with pStreamEx->Core.Host.Cfg? 1992 * drvAudioStreamInitInternal() does some setup and a bunch of 1993 * validations + adjustments of the stream config, so this surely is quite 1994 * optimistic. */ 1995 if (true) 1992 1996 { 1993 1997 /* … … 3081 3085 3082 3086 /** 3083 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamGetStatus} 3084 */ 3085 static DECLCALLBACK(uint32_t) drvAudioStreamGetStatus(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream) 3086 { 3087 PDRVAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVAUDIO, IAudioConnector); 3088 AssertPtr(pThis); 3089 3090 /** @todo r=bird: It is not documented that we ignore NULL streams... Why is 3091 * this necessary? */ 3092 if (!pStream) 3093 return PDMAUDIOSTREAM_STS_NONE; 3087 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamGetState} 3088 */ 3089 static DECLCALLBACK(PDMAUDIOSTREAMSTATE) drvAudioStreamGetState(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream) 3090 { 3091 PDRVAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVAUDIO, IAudioConnector); 3094 3092 PDRVAUDIOSTREAM pStreamEx = (PDRVAUDIOSTREAM)pStream; 3095 AssertPtrReturn(pStreamEx, PDMAUDIOSTREAM_STS_NONE); 3096 AssertReturn(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC, PDMAUDIOSTREAM_STS_NONE); 3097 AssertReturn(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, PDMAUDIOSTREAM_STS_NONE); 3098 3093 AssertPtrReturn(pStreamEx, PDMAUDIOSTREAMSTATE_INVALID); 3094 AssertReturn(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC, PDMAUDIOSTREAMSTATE_INVALID); 3095 AssertReturn(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, PDMAUDIOSTREAMSTATE_INVALID); 3096 3097 /* 3098 * Get the status mask. 3099 */ 3099 3100 int rc = RTCritSectEnter(&pThis->CritSect); 3100 AssertRCReturn(rc, PDMAUDIOSTREAM_STS_NONE); 3101 3102 uint32_t fStrmStatus = pStreamEx->fStatus; 3101 AssertRCReturn(rc, PDMAUDIOSTREAMSTATE_INVALID); 3102 3103 uint32_t const fStrmStatus = pStreamEx->fStatus; 3104 PDMAUDIODIR const enmDir = pStreamEx->Guest.Cfg.enmDir; 3103 3105 3104 3106 RTCritSectLeave(&pThis->CritSect); 3107 3108 /* 3109 * Translate it to state enum value. 3110 */ 3111 PDMAUDIOSTREAMSTATE enmState; 3112 if (!(fStrmStatus & PDMAUDIOSTREAM_STS_NEED_REINIT)) 3113 { 3114 if (fStrmStatus & PDMAUDIOSTREAM_STS_INITIALIZED) 3115 { 3116 if (fStrmStatus & PDMAUDIOSTREAM_STS_ENABLED) 3117 enmState = enmDir == PDMAUDIODIR_IN ? PDMAUDIOSTREAMSTATE_ENABLED_READABLE : PDMAUDIOSTREAMSTATE_ENABLED_WRITABLE; 3118 else 3119 enmState = PDMAUDIOSTREAMSTATE_INACTIVE; 3120 } 3121 else 3122 enmState = PDMAUDIOSTREAMSTATE_NOT_WORKING; 3123 } 3124 else 3125 enmState = PDMAUDIOSTREAMSTATE_NEED_REINIT; 3126 3105 3127 #ifdef LOG_ENABLED 3106 3128 char szStreamSts[DRVAUDIO_STATUS_STR_MAX]; 3107 3129 #endif 3108 Log3Func(("[%s] %s\n", pStreamEx->Core.szName, drvAudioStreamStatusToStr(szStreamSts, fStrmStatus)));3109 return fStrmStatus;3130 Log3Func(("[%s] returns %d (%s)\n", pStreamEx->Core.szName, enmState, drvAudioStreamStatusToStr(szStreamSts, fStrmStatus))); 3131 return enmState; 3110 3132 } 3111 3133 … … 4676 4698 pThis->IAudioConnector.pfnStreamGetReadable = drvAudioStreamGetReadable; 4677 4699 pThis->IAudioConnector.pfnStreamGetWritable = drvAudioStreamGetWritable; 4678 pThis->IAudioConnector.pfnStreamGetStat us = drvAudioStreamGetStatus;4700 pThis->IAudioConnector.pfnStreamGetState = drvAudioStreamGetState; 4679 4701 pThis->IAudioConnector.pfnStreamSetVolume = drvAudioStreamSetVolume; 4680 4702 pThis->IAudioConnector.pfnStreamPlay = drvAudioStreamPlay;
Note:
See TracChangeset
for help on using the changeset viewer.