Changeset 89736 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jun 16, 2021 8:31:29 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145187
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r89733 r89736 1997 1997 { 1998 1998 /* 1999 * Assemble the stream config and get the associate mixer sink.1999 * Assemble the stream config and get the associated mixer sink. 2000 2000 */ 2001 2001 PDMAUDIOPCMPROPS PropsTmp; 2002 2002 PDMAUDIOSTREAMCFG Cfg; 2003 2003 PDMAudioStrmCfgInitWithProps(&Cfg, ichach97R3CalcStreamProps(pThis, pStream->u8SD, &PropsTmp)); 2004 Assert(Cfg.enmDir != PDMAUDIODIR_UNKNOWN); 2004 2005 2005 2006 PAUDMIXSINK pMixSink; … … 2156 2157 uint32_t const cbCircBuf = PDMAudioPropsMilliToBytes(&Cfg.Props, cMsCircBuf); 2157 2158 2159 LogFlowFunc(("Stream %u: uTimerHz: %u -> %u; cMsSchedulingHint: %u -> %u; cbCircBuf: %#zx -> %#x (%u ms, cMsDmaMinBuf=%u)%s\n", 2160 pStreamCC->State.uTimerHz, uTimerHz, Cfg.Device.cMsSchedulingHint, cMsSchedulingHint, 2161 pStreamCC->State.pCircBuf ? RTCircBufSize(pStreamCC->State.pCircBuf) : 0, cbCircBuf, cMsCircBuf, cMsDmaMinBuf, 2162 !pStreamCC->State.pCircBuf || RTCircBufSize(pStreamCC->State.pCircBuf) != cbCircBuf ? " - re-creating DMA buffer" : "")); 2163 2164 /* 2165 * Set the stream's timer rate and scheduling hint. 2166 */ 2167 pStreamCC->State.uTimerHz = uTimerHz; 2168 Cfg.Device.cMsSchedulingHint = cMsSchedulingHint; 2169 2170 /* 2171 * Re-create the circular buffer if necessary, resetting if not. 2172 */ 2173 if ( pStreamCC->State.pCircBuf 2174 && RTCircBufSize(pStreamCC->State.pCircBuf) == cbCircBuf) 2175 RTCircBufReset(pStreamCC->State.pCircBuf); 2176 else 2177 { 2178 if (pStreamCC->State.pCircBuf) 2179 RTCircBufDestroy(pStreamCC->State.pCircBuf); 2180 2181 int rc = RTCircBufCreate(&pStreamCC->State.pCircBuf, cbCircBuf); 2182 AssertRCReturnStmt(rc, pStreamCC->State.pCircBuf = NULL, rc); 2183 2184 pStreamCC->State.StatDmaBufSize = (uint32_t)RTCircBufSize(pStreamCC->State.pCircBuf); 2185 } 2186 Assert(pStreamCC->State.StatDmaBufSize == cbCircBuf); 2187 2158 2188 /* 2159 2189 * Only (re-)create the stream (and driver chain) if we really have to. 2160 2190 * Otherwise avoid this and just reuse it, as this costs performance. 2161 2191 */ 2192 char szTmp[PDMAUDIOSTRMCFGTOSTRING_MAX]; 2162 2193 int rc = VINF_SUCCESS; 2163 2194 if ( fForce 2164 || !PDMAudioStrmCfgMatchesProps(&Cfg, &pStreamCC->State.Cfg.Props) 2165 || !pStreamCC->State.pCircBuf 2166 || cbCircBuf != RTCircBufSize(pStreamCC->State.pCircBuf)) 2167 { 2168 LogRel2(("AC97: (Re-)Opening stream '%s' (%RU32Hz, %RU8 channels, %s%RU8)\n", Cfg.szName, Cfg.Props.uHz, 2169 PDMAudioPropsChannels(&Cfg.Props), Cfg.Props.fSigned ? "S" : "U", PDMAudioPropsSampleBits(&Cfg.Props))); 2170 2171 LogFlowFunc(("[SD%RU8] uHz=%RU32\n", pStream->u8SD, Cfg.Props.uHz)); 2172 2173 Assert(Cfg.enmDir != PDMAUDIODIR_UNKNOWN); 2174 2175 /* 2176 * Set the stream's timer rate and scheduling hint. 2177 */ 2178 pStreamCC->State.uTimerHz = uTimerHz; 2179 Cfg.Device.cMsSchedulingHint = cMsSchedulingHint; 2180 2181 /* 2182 * Re-create the circular buffer if necessary. 2183 */ 2184 if (pStreamCC->State.pCircBuf && RTCircBufSize(pStreamCC->State.pCircBuf) == cbCircBuf) 2185 RTCircBufReset(pStreamCC->State.pCircBuf); 2186 else 2187 { 2188 LogFlowFunc(("Re-creating circular buffer with size %u ms / %#x bytes (was %#x); cMsSchedulingHint=%u cMsDmaMinBuf=%u cMsCircBufXxx=%u\n", 2189 cMsCircBuf, cbCircBuf, pStreamCC->State.StatDmaBufSize, Cfg.Device.cMsSchedulingHint, cMsDmaMinBuf, 2190 Cfg.enmDir == PDMAUDIODIR_IN ? pThis->cMsCircBufIn : pThis->cMsCircBufOut)); 2191 if (pStreamCC->State.pCircBuf) 2192 RTCircBufDestroy(pStreamCC->State.pCircBuf); 2193 2194 rc = RTCircBufCreate(&pStreamCC->State.pCircBuf, cbCircBuf); 2195 AssertRCReturnStmt(rc, pStreamCC->State.pCircBuf = NULL, rc); 2196 2197 pStreamCC->State.StatDmaBufSize = (uint32_t)RTCircBufSize(pStreamCC->State.pCircBuf); 2198 } 2199 Assert(pStreamCC->State.StatDmaBufSize == cbCircBuf); 2200 2201 /* 2202 * <there should be a comment here> 2203 */ 2195 || !PDMAudioStrmCfgMatchesProps(&Cfg, &pStreamCC->State.Cfg.Props)) 2196 { 2197 LogRel2(("AC97: Setting up stream #%u: %s\n", pStreamCC->u8SD, PDMAudioStrmCfgToString(&Cfg, szTmp, sizeof(szTmp)) )); 2198 2204 2199 ichac97R3MixerRemoveDrvStreams(pDevIns, pThisCC, pMixSink, Cfg.enmDir, Cfg.enmPath); 2205 2200 rc = ichac97R3MixerAddDrvStreams(pDevIns, pThisCC, pMixSink, &Cfg); 2206 2201 if (RT_SUCCESS(rc)) 2207 rc = PDMAudioStrmCfgCopy(&pStreamCC->State.Cfg, &Cfg); 2208 2209 LogFlowFunc(("[SD%RU8] rc=%Rrc\n", pStream->u8SD, rc)); 2202 { 2203 PDMAudioStrmCfgCopy(&pStreamCC->State.Cfg, &Cfg); 2204 LogFlowFunc(("[SD%RU8] success (uHz=%u)\n", pStreamCC->u8SD, rc, PDMAudioPropsHz(&Cfg.Props))); 2205 } 2206 else 2207 { 2208 LogFunc(("[SD%RU8] ichac97R3MixerAddDrvStreams failed: %Rrc (uHz=%u)\n", 2209 pStreamCC->u8SD, rc, PDMAudioPropsHz(&Cfg.Props))); 2210 /** @todo r=bird: we should remember this somehow and prevent things from 2211 * working and ensure that we redo setup the next time the guest 2212 * tries to play/record something with this stream... */ 2213 } 2210 2214 } 2211 2215 else 2212 LogFlowFunc(("[SD%RU8] Skipping (re-)creation\n", pStream->u8SD)); 2216 LogFlowFunc(("[SD%RU8] Skipping set-up (unchanged: %s)\n", 2217 pStreamCC->u8SD, PDMAudioStrmCfgToString(&Cfg, szTmp, sizeof(szTmp)))); 2213 2218 return rc; 2214 2219 } … … 2278 2283 if (fEnable) 2279 2284 { 2280 /* Reset some of thestate. */2285 /* Reset the input pre-buffering state. */ 2281 2286 pStreamCC->State.fInputPreBuffered = false; 2282 if (pStreamCC->State.pCircBuf)2283 RTCircBufReset(pStreamCC->State.pCircBuf);2284 2287 2285 2288 /* (Re-)Open the stream if necessary. */ … … 2430 2433 { 2431 2434 char szFile[64]; 2432 2433 2435 if (ichac97R3GetDirFromSD(pStream->u8SD) == PDMAUDIODIR_IN) 2434 2436 RTStrPrintf(szFile, sizeof(szFile), "ac97StreamWriteSD%RU8", pStream->u8SD);
Note:
See TracChangeset
for help on using the changeset viewer.