Changeset 89844 in vbox
- Timestamp:
- Jun 23, 2021 8:23:40 AM (4 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHda.cpp
r89822 r89844 1333 1333 1334 1334 STAM_REL_PROFILE_START_NS(&pStreamR3->State.StatReset, a); 1335 hdaStreamLock(pStreamShared);1335 Assert(PDMCritSectIsOwner(&pThis->CritSect)); 1336 1336 PAUDMIXSINK const pMixSink = pStreamR3->pMixSink ? pStreamR3->pMixSink->pMixSink : NULL; 1337 1337 if (pMixSink) … … 1350 1350 if (pMixSink) /* (FYI. pMixSink might not be what pStreamR3->pMixSink->pMixSink points at any longer) */ 1351 1351 AudioMixerSinkUnlock(pMixSink); 1352 hdaStreamUnlock(pStreamShared);1353 1352 STAM_REL_PROFILE_STOP_NS(&pStreamR3->State.StatReset, a); 1354 1353 } … … 1364 1363 LogFunc(("[SD%RU8] State changed (fRun=%RTbool)\n", uSD, fRun)); 1365 1364 1366 hdaStreamLock(pStreamShared);1365 Assert(PDMCritSectIsOwner(&pThis->CritSect)); 1367 1366 /** @todo bird: It's not clear to me when the pMixSink is actually 1368 1367 * assigned to the stream, so being paranoid till I find out... */ … … 1462 1461 if (pMixSink) 1463 1462 AudioMixerSinkUnlock(pMixSink); 1464 hdaStreamUnlock(pStreamShared);1465 1463 STAM_REL_PROFILE_STOP_NS((fRun ? &pStreamR3->State.StatStart : &pStreamR3->State.StatStop), r); 1466 1464 } … … 2520 2518 LogFunc(("Sink '%s' was assigned to stream #%RU8 (channel %RU8) before\n", 2521 2519 pSink->pMixSink->pszName, pOldStreamShared->u8SD, pOldStreamShared->u8Channel)); 2522 2523 hdaStreamLock(pOldStreamShared); 2520 Assert(PDMCritSectIsOwner(&pThis->CritSect)); 2524 2521 2525 2522 /* Only disable the stream if the stream descriptor # has changed. */ … … 2535 2532 pOldStreamR3->pMixSink = NULL; 2536 2533 2537 hdaStreamUnlock(pOldStreamShared);2538 2534 2539 2535 pSink->pStreamShared = NULL; … … 2550 2546 PHDASTREAMR3 pStreamR3 = &pThisCC->aStreams[uSD]; 2551 2547 PHDASTREAM pStreamShared = &pThis->aStreams[uSD]; 2552 hdaStreamLock(pStreamShared);2548 Assert(PDMCritSectIsOwner(&pThis->CritSect)); 2553 2549 2554 2550 pSink->pStreamR3 = pStreamR3; … … 2558 2554 pStreamR3->pMixSink = pSink; 2559 2555 2560 hdaStreamUnlock(pStreamShared);2561 2556 rc = VINF_SUCCESS; 2562 2557 } … … 2765 2760 { 2766 2761 LogFlowFuncEnter(); 2762 Assert(PDMCritSectIsOwner(&pThis->CritSect)); 2767 2763 2768 2764 /* … … 2774 2770 PHDASTREAM const pStreamShared = &pThis->aStreams[idxStream]; 2775 2771 PHDASTREAMR3 const pStreamR3 = &pThisCC->aStreams[idxStream]; 2776 hdaStreamLock(pStreamShared);2777 2772 PAUDMIXSINK const pMixSink = pStreamR3->pMixSink ? pStreamR3->pMixSink->pMixSink : NULL; 2778 2773 if (pMixSink) … … 2789 2784 if (pMixSink) /* (FYI. pMixSink might not be what pStreamR3->pMixSink->pMixSink points at any longer) */ 2790 2785 AudioMixerSinkUnlock(pMixSink); 2791 hdaStreamUnlock(pStreamShared);2792 2786 } 2793 2787 … … 4592 4586 4593 4587 for (uint8_t i = 0; i < HDA_MAX_STREAMS; i++) 4594 hdaR3StreamDestroy(&pThis ->aStreams[i], &pThisCC->aStreams[i]);4588 hdaR3StreamDestroy(&pThisCC->aStreams[i]); 4595 4589 4596 4590 /* We don't always go via PowerOff, so make sure the mixer is destroyed. */ -
trunk/src/VBox/Devices/Audio/DevHdaStream.cpp
r89826 r89844 64 64 int hdaR3StreamConstruct(PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3, PHDASTATE pThis, PHDASTATER3 pThisCC, uint8_t uSD) 65 65 { 66 int rc;67 68 66 pStreamR3->u8SD = uSD; 69 67 pStreamShared->u8SD = uSD; … … 81 79 AssertPtr(pStreamR3->pHDAStateR3); 82 80 AssertPtr(pStreamR3->pHDAStateR3->pDevIns); 83 rc = PDMDevHlpCritSectInit(pStreamR3->pHDAStateR3->pDevIns, &pStreamShared->CritSect,84 RT_SRC_POS, "hda_sd#%RU8", pStreamShared->u8SD);85 AssertRCReturn(rc, rc);86 81 87 82 #ifdef DEBUG 88 rc = RTCritSectInit(&pStreamR3->Dbg.CritSect);83 int rc = RTCritSectInit(&pStreamR3->Dbg.CritSect); 89 84 AssertRCReturn(rc, rc); 90 85 #endif … … 155 150 } 156 151 157 return rc;152 return VINF_SUCCESS; 158 153 } 159 154 … … 164 159 * @param pStreamR3 The HDA stream to destroy - ring-3 bits. 165 160 */ 166 void hdaR3StreamDestroy(PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3)167 { 168 LogFlowFunc(("[SD%RU8] Destroying ...\n", pStream Shared->u8SD));161 void hdaR3StreamDestroy(PHDASTREAMR3 pStreamR3) 162 { 163 LogFlowFunc(("[SD%RU8] Destroying ...\n", pStreamR3->u8SD)); 169 164 int rc2; 170 165 … … 174 169 AssertRC(rc2); 175 170 pStreamR3->State.pAioRegSink = NULL; 176 }177 178 if (PDMCritSectIsInitialized(&pStreamShared->CritSect))179 {180 rc2 = PDMR3CritSectDelete(&pStreamShared->CritSect);181 AssertRC(rc2);182 171 } 183 172 … … 1991 1980 * Do the DMA transfer. 1992 1981 */ 1993 rc2 = PDMDevHlpCritSectEnter(pDevIns, &pStreamShared->CritSect, VERR_IGNORED);1994 AssertRC(rc2);1995 1996 1982 uint64_t const offWriteBefore = pStreamR3->State.offWrite; 1997 1983 hdaR3StreamDoDmaOutput(pDevIns, pThis, pStreamShared, pStreamR3, RT_MIN(cbStreamFree, cbPeriod), tsNowNs); 1998 1999 rc2 = PDMDevHlpCritSectLeave(pDevIns, &pStreamShared->CritSect);2000 AssertRC(rc2);2001 1984 2002 1985 /* … … 2154 2137 */ 2155 2138 if (cbStreamUsed) 2156 {2157 rc2 = PDMDevHlpCritSectEnter(pDevIns, &pStreamShared->CritSect, VERR_IGNORED);2158 AssertRC(rc2);2159 2160 2139 hdaR3StreamDoDmaInput(pDevIns, pThis, pStreamShared, pStreamR3, 2161 2140 RT_MIN(cbStreamUsed, cbPeriod), fWriteSilence, tsNowNs); 2162 2163 rc2 = PDMDevHlpCritSectLeave(pDevIns, &pStreamShared->CritSect);2164 AssertRC(rc2);2165 }2166 2141 2167 2142 /* … … 2222 2197 } 2223 2198 2224 #endif /* IN_RING3 */2225 2226 /**2227 * Locks an HDA stream for serialized access.2228 *2229 * @returns VBox status code.2230 * @param pStreamShared HDA stream to lock (shared bits).2231 */2232 void hdaStreamLock(PHDASTREAM pStreamShared)2233 {2234 AssertPtrReturnVoid(pStreamShared);2235 int rc2 = PDMCritSectEnter(&pStreamShared->CritSect, VINF_SUCCESS);2236 AssertRC(rc2);2237 }2238 2239 /**2240 * Unlocks a formerly locked HDA stream.2241 *2242 * @returns VBox status code.2243 * @param pStreamShared HDA stream to unlock (shared bits).2244 */2245 void hdaStreamUnlock(PHDASTREAM pStreamShared)2246 {2247 AssertPtrReturnVoid(pStreamShared);2248 int rc2 = PDMCritSectLeave(&pStreamShared->CritSect);2249 AssertRC(rc2);2250 }2251 2252 #ifdef IN_RING32253 2199 2254 2200 #if 0 /* unused - no prototype even */ -
trunk/src/VBox/Devices/Audio/DevHdaStream.h
r89821 r89844 238 238 /** Pad the structure size to a 64 byte alignment. */ 239 239 uint64_t au64Padding1[2]; 240 /** Critical section for serialize access to the stream state between the async241 * I/O thread and (basically) the guest. */242 PDMCRITSECT CritSect;243 240 } HDASTREAM; 244 241 AssertCompileMemberAlignment(HDASTREAM, State.aBdl, 16); … … 307 304 typedef HDASTREAMR3 *PHDASTREAMR3; 308 305 309 /** @name Stream functions (shared).310 * @{311 */312 void hdaStreamLock(PHDASTREAM pStreamShared);313 void hdaStreamUnlock(PHDASTREAM pStreamShared);314 /** @} */315 316 306 #ifdef IN_RING3 317 307 … … 321 311 int hdaR3StreamConstruct(PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3, PHDASTATE pThis, 322 312 PHDASTATER3 pThisCC, uint8_t uSD); 323 void hdaR3StreamDestroy(PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3);313 void hdaR3StreamDestroy(PHDASTREAMR3 pStreamR3); 324 314 int hdaR3StreamSetUp(PPDMDEVINS pDevIns, PHDASTATE pThis, PHDASTREAM pStreamShared, 325 315 PHDASTREAMR3 pStreamR3, uint8_t uSD);
Note:
See TracChangeset
for help on using the changeset viewer.