Changeset 82345 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Dec 3, 2019 2:40:21 PM (5 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r82332 r82345 155 155 * Acquires the TM lock and HDA lock, returns on failure. 156 156 */ 157 #define DEVHDA_LOCK_BOTH_RETURN(a_pDevIns, a_pThis, a_ SD, a_rcBusy) \157 #define DEVHDA_LOCK_BOTH_RETURN(a_pDevIns, a_pThis, a_pStream, a_rcBusy) \ 158 158 do { \ 159 VBOXSTRICTRC rcLock = PDMDevHlpTimerLockClock2(pDevIns, (a_p This)->ahTimers[a_SD], &(a_pThis)->CritSect, (a_rcBusy)); \159 VBOXSTRICTRC rcLock = PDMDevHlpTimerLockClock2(pDevIns, (a_pStream)->hTimer, &(a_pThis)->CritSect, (a_rcBusy)); \ 160 160 if (RT_LIKELY(rcLock == VINF_SUCCESS)) \ 161 161 { /* likely */ } \ … … 167 167 * Releases the HDA lock and TM lock. 168 168 */ 169 #define DEVHDA_UNLOCK_BOTH(a_pDevIns, a_pThis, a_ SD) \170 PDMDevHlpTimerUnlockClock2(pDevIns, (a_p This)->ahTimers[a_SD], &(a_pThis)->CritSect)169 #define DEVHDA_UNLOCK_BOTH(a_pDevIns, a_pThis, a_pStream) \ 170 PDMDevHlpTimerUnlockClock2(pDevIns, (a_pStream)->hTimer, &(a_pThis)->CritSect) 171 171 172 172 … … 1302 1302 * clock lock here! 1303 1303 */ 1304 DEVHDA_LOCK_BOTH_RETURN(pDevIns, pThis, uSD, VINF_IOM_R3_MMIO_WRITE);1304 DEVHDA_LOCK_BOTH_RETURN(pDevIns, pThis, pStream, VINF_IOM_R3_MMIO_WRITE); 1305 1305 1306 1306 const bool fInRun = RT_BOOL(HDA_REG_IND(pThis, iReg) & HDA_SDCTL_RUN); … … 1457 1457 AssertRC(rc2); 1458 1458 1459 DEVHDA_UNLOCK_BOTH(pDevIns, pThis, uSD);1459 DEVHDA_UNLOCK_BOTH(pDevIns, pThis, pStream); 1460 1460 return VINF_SUCCESS; /* Always return success to the MMIO handler. */ 1461 1461 #else /* !IN_RING3 */ … … 1477 1477 * clock lock here! 1478 1478 */ 1479 DEVHDA_LOCK_BOTH_RETURN(pDevIns, pThis, uSD, VINF_IOM_R3_MMIO_WRITE);1479 DEVHDA_LOCK_BOTH_RETURN(pDevIns, pThis, pStream, VINF_IOM_R3_MMIO_WRITE); 1480 1480 1481 1481 hdaR3StreamLock(pStream); … … 1572 1572 hdaR3StreamUnlock(pStream); 1573 1573 1574 DEVHDA_UNLOCK_BOTH(pDevIns, pThis, uSD);1574 DEVHDA_UNLOCK_BOTH(pDevIns, pThis, pStream); 1575 1575 return VINF_SUCCESS; 1576 1576 #else /* !IN_RING3 */ … … 2842 2842 PHDASTATE pThis = PDMDEVINS_2_DATA(pDevIns, PHDASTATE); 2843 2843 PHDASTREAM pStream = (PHDASTREAM)pvUser; 2844 TMTIMERHANDLE hTimer = RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD);2844 TMTIMERHANDLE hTimer = pStream->hTimer; 2845 2845 RT_NOREF(pTimer); 2846 2846 … … 4967 4967 { 4968 4968 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, hdaR3Timer, &pThis->aStreams[i], 4969 TMTIMER_FLAGS_NO_CRIT_SECT, s_apszNames[i], &pThis->a hTimers[i]);4969 TMTIMER_FLAGS_NO_CRIT_SECT, s_apszNames[i], &pThis->aStreams[i].hTimer); 4970 4970 AssertRCReturn(rc, rc); 4971 4971 4972 rc = PDMDevHlpTimerSetCritSect(pDevIns, pThis->a hTimers[i], &pThis->CritSect);4972 rc = PDMDevHlpTimerSetCritSect(pDevIns, pThis->aStreams[i].hTimer, &pThis->CritSect); 4973 4973 AssertRCReturn(rc, rc); 4974 4974 } -
trunk/src/VBox/Devices/Audio/DevHDA.h
r82331 r82345 138 138 /** Number of active (running) SDn streams. */ 139 139 uint8_t cStreamsActive; 140 /** The stream timers for pumping data thru the attached LUN drivers.141 * Duplicated in HDASTREAM::hTimer. */142 TMTIMERHANDLE ahTimers[HDA_MAX_STREAMS];143 140 /** Pointer to HDA codec to use. */ 144 141 R3PTRTYPE(PHDACODEC) pCodec; -
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r82344 r82345 412 412 uint32_t Padding1; 413 413 #endif 414 /** The timer for pumping data thru the attached LUN drivers. */ 415 TMTIMERHANDLE hTimer; 414 416 /** Debug stuff. */ 415 417 AC97STREAMDEBUG Dbg; … … 501 503 /** R3 pointer to the device instance. */ 502 504 PPDMDEVINSR3 pDevInsR3; 503 // /** R0 pointer to the device instance. */504 // PPDMDEVINSR0 pDevInsR0;505 // /** RC pointer to the device instance. */506 // PPDMDEVINSRC pDevInsRC;507 // bool afPadding0[4];508 505 /** Global Control (Bus Master Control Register). */ 509 506 uint32_t glob_cnt; … … 519 516 uint16_t uTimerHz; 520 517 uint16_t au16Padding1[3]; 521 /** The timer for pumping data thru the attached LUN drivers. */522 TMTIMERHANDLE ahTimers[AC97_MAX_STREAMS];523 518 /** List of associated LUN drivers (AC97DRIVER). */ 524 519 RTLISTANCHORR3 lstDrv; … … 589 584 * Acquires the TM lock and AC'97 lock, returns on failure. 590 585 */ 591 #define DEVAC97_LOCK_BOTH_RETURN(a_pDevIns, a_pThis, a_ SD, a_rcBusy) \586 #define DEVAC97_LOCK_BOTH_RETURN(a_pDevIns, a_pThis, a_pStream, a_rcBusy) \ 592 587 do { \ 593 VBOXSTRICTRC rcLock = PDMDevHlpTimerLockClock2((a_pDevIns), RT_SAFE_SUBSCRIPT8((a_pThis)->ahTimers, (a_SD)), \ 594 &(a_pThis)->CritSect, (a_rcBusy)); \ 588 VBOXSTRICTRC rcLock = PDMDevHlpTimerLockClock2((a_pDevIns), (a_pStream)->hTimer, &(a_pThis)->CritSect, (a_rcBusy)); \ 595 589 if (RT_LIKELY(rcLock == VINF_SUCCESS)) \ 596 590 { /* likely */ } \ … … 605 599 * Releases the AC'97 lock and TM lock. 606 600 */ 607 #define DEVAC97_UNLOCK_BOTH(a_pDevIns, a_pThis, a_ SD) \608 PDMDevHlpTimerUnlockClock2((a_pDevIns), RT_SAFE_SUBSCRIPT8((a_pThis)->ahTimers, (a_SD)), &(a_pThis)->CritSect)601 #define DEVAC97_UNLOCK_BOTH(a_pDevIns, a_pThis, a_pStream) \ 602 PDMDevHlpTimerUnlockClock2((a_pDevIns), (a_pStream)->hTimer, &(a_pThis)->CritSect) 609 603 610 604 #ifdef VBOX_WITH_STATISTICS … … 659 653 static void ichac97R3BDLEDumpAll(PAC97STATE pThis, uint64_t u64BDLBase, uint16_t cBDLE); 660 654 # endif 661 DECLINLINE(void) ichac97R3TimerSet(PPDMDEVINS pDevIns, PAC97ST ATE pThis, PAC97STREAM pStream, uint64_t cTicksToDeadline);655 DECLINLINE(void) ichac97R3TimerSet(PPDMDEVINS pDevIns, PAC97STREAM pStream, uint64_t cTicksToDeadline); 662 656 #endif /* IN_RING3 */ 663 657 … … 953 947 954 948 int rc = RTCritSectInit(&pStream->State.CritSect); 949 AssertRCReturn(rc, rc); 955 950 956 951 pStream->Dbg.Runtime.fEnabled = pThis->Dbg.fEnabled; … … 1948 1943 * @returns Calculated ticks 1949 1944 * @param pDevIns The device instance. 1950 * @param pThis AC'97 device state.1951 1945 * @param pStream AC'97 stream to calculate ticks for. 1952 1946 * @param cbBytes Bytes to calculate ticks for. 1953 1947 */ 1954 static uint64_t ichac97R3StreamTransferCalcNext(PPDMDEVINS pDevIns, PAC97ST ATE pThis, PAC97STREAM pStream, uint32_t cbBytes)1948 static uint64_t ichac97R3StreamTransferCalcNext(PPDMDEVINS pDevIns, PAC97STREAM pStream, uint32_t cbBytes) 1955 1949 { 1956 1950 if (!cbBytes) … … 1958 1952 1959 1953 const uint64_t usBytes = DrvAudioHlpBytesToMicro(cbBytes, &pStream->State.Cfg.Props); 1960 const uint64_t cTransferTicks = PDMDevHlpTimerFromMicro(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD), usBytes);1954 const uint64_t cTransferTicks = PDMDevHlpTimerFromMicro(pDevIns, pStream->hTimer, usBytes); 1961 1955 1962 1956 Log3Func(("[SD%RU8] Timer %uHz, cbBytes=%RU32 -> usBytes=%RU64, cTransferTicks=%RU64\n", … … 1970 1964 * 1971 1965 * @param pDevIns The device instance. 1972 * @param pThis AC'97 device state.1973 1966 * @param pStream AC'97 stream to update. 1974 1967 * @param cbBytes Bytes to update next transfer for. 1975 1968 */ 1976 static void ichac97R3StreamTransferUpdate(PPDMDEVINS pDevIns, PAC97ST ATE pThis, PAC97STREAM pStream, uint32_t cbBytes)1969 static void ichac97R3StreamTransferUpdate(PPDMDEVINS pDevIns, PAC97STREAM pStream, uint32_t cbBytes) 1977 1970 { 1978 1971 if (!cbBytes) … … 1984 1977 1985 1978 /* Update the transfer ticks. */ 1986 pStream->State.cTransferTicks = ichac97R3StreamTransferCalcNext(pDevIns, p This, pStream, pStream->State.cbTransferChunk);1979 pStream->State.cTransferTicks = ichac97R3StreamTransferCalcNext(pDevIns, pStream, pStream->State.cbTransferChunk); 1987 1980 Assert(pStream->State.cTransferTicks); /* Paranoia. */ 1988 1981 } … … 2626 2619 AssertPtr(pStream); 2627 2620 Assert(PDMDevHlpCritSectIsOwner(pDevIns, &pThis->CritSect)); 2628 Assert(PDMDevHlpTimerIsLockOwner(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD)));2621 Assert(PDMDevHlpTimerIsLockOwner(pDevIns, pStream->hTimer)); 2629 2622 2630 2623 ichac97R3StreamUpdate(pDevIns, pThis, pStream, true /* fInTimer */); … … 2633 2626 if (pSink && AudioMixerSinkIsActive(pSink)) 2634 2627 { 2635 ichac97R3StreamTransferUpdate(pDevIns, p This, pStream, pStream->Regs.picb << 1); /** @todo r=andy Assumes 16-bit samples. */2636 ichac97R3TimerSet(pDevIns, p This, pStream, pStream->State.cTransferTicks);2628 ichac97R3StreamTransferUpdate(pDevIns, pStream, pStream->Regs.picb << 1); /** @todo r=andy Assumes 16-bit samples. */ 2629 ichac97R3TimerSet(pDevIns, pStream, pStream->State.cTransferTicks); 2637 2630 } 2638 2631 … … 2651 2644 * @remarks This used to be more complicated a long time ago... 2652 2645 */ 2653 DECLINLINE(void) ichac97R3TimerSet(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint64_t cTicksToDeadline) 2654 { 2655 int rc = PDMDevHlpTimerSetRelative(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD), 2656 cTicksToDeadline, NULL /*pu64Now*/); 2646 DECLINLINE(void) ichac97R3TimerSet(PPDMDEVINS pDevIns, PAC97STREAM pStream, uint64_t cTicksToDeadline) 2647 { 2648 int rc = PDMDevHlpTimerSetRelative(pDevIns, pStream->hTimer, cTicksToDeadline, NULL /*pu64Now*/); 2657 2649 AssertRC(rc); 2658 2650 } … … 3056 3048 pRegs = &pStream->Regs; 3057 3049 3058 DEVAC97_LOCK_BOTH_RETURN(pDevIns, pThis, pStream ->u8SD, VINF_IOM_R3_IOPORT_WRITE);3050 DEVAC97_LOCK_BOTH_RETURN(pDevIns, pThis, pStream, VINF_IOM_R3_IOPORT_WRITE); 3059 3051 } 3060 3052 … … 3144 3136 /* Arm the timer for this stream. */ 3145 3137 /** @todo r=bird: This function returns bool, not VBox status! */ 3146 ichac97R3TimerSet(pDevIns, p This, pStream, pStream->State.cTransferTicks);3138 ichac97R3TimerSet(pDevIns, pStream, pStream->State.cTransferTicks); 3147 3139 } 3148 3140 } … … 3229 3221 3230 3222 if (pStream) 3231 DEVAC97_UNLOCK_BOTH(pDevIns, pThis, pStream ->u8SD);3223 DEVAC97_UNLOCK_BOTH(pDevIns, pThis, pStream); 3232 3224 3233 3225 return rc; … … 3637 3629 { 3638 3630 /* Re-arm the timer for this stream. */ 3639 /** @todo r=bird: This function returns bool, not VBox status! */ 3640 ichac97R3TimerSet(pDevIns, pThis, pStream, pStream->State.cTransferTicks); 3631 ichac97R3TimerSet(pDevIns, pStream, pStream->State.cTransferTicks); 3641 3632 } 3642 3633 … … 4139 4130 * Create all hardware streams. 4140 4131 */ 4132 AssertCompile(RT_ELEMENTS(pThis->aStreams) == AC97_MAX_STREAMS); 4141 4133 for (unsigned i = 0; i < AC97_MAX_STREAMS; i++) 4142 4134 { 4143 int rc2 = ichac97R3StreamCreate(pThis, &pThis->aStreams[i], i /* SD# */); 4144 AssertRC(rc2); 4145 if (RT_SUCCESS(rc)) 4146 rc = rc2; 4147 } 4135 rc = ichac97R3StreamCreate(pThis, &pThis->aStreams[i], i /* SD# */); 4136 AssertRCReturn(rc, rc); 4137 } 4138 4139 /* 4140 * Create the emulation timers (one per stream). 4141 * 4142 * We must the critical section for the timers as the device has a 4143 * noop section associated with it. 4144 * 4145 * Note: Use TMCLOCK_VIRTUAL_SYNC here, as the guest's AC'97 driver 4146 * relies on exact (virtual) DMA timing and uses DMA Position Buffers 4147 * instead of the LPIB registers. 4148 */ 4149 static const char * const s_apszNames[] = { "AC97 PI", "AC97 PO", "AC97 MC" }; 4150 AssertCompile(RT_ELEMENTS(s_apszNames) == AC97_MAX_STREAMS); 4151 for (unsigned i = 0; i < AC97_MAX_STREAMS; i++) 4152 { 4153 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, ichac97R3Timer, &pThis->aStreams[i], 4154 TMTIMER_FLAGS_NO_CRIT_SECT, s_apszNames[i], &pThis->aStreams[i].hTimer); 4155 AssertRCReturn(rc, rc); 4156 4157 rc = PDMDevHlpTimerSetCritSect(pDevIns, pThis->aStreams[i].hTimer, &pThis->CritSect); 4158 AssertRCReturn(rc, rc); 4159 } 4160 4148 4161 4149 4162 # ifdef VBOX_WITH_AUDIO_AC97_ONETIME_INIT … … 4243 4256 4244 4257 ichac97R3Reset(pDevIns); 4245 4246 /*4247 * Create the emulation timers (one per stream).4248 *4249 * We must the critical section for the timers as the device has a4250 * noop section associated with it.4251 *4252 * Note: Use TMCLOCK_VIRTUAL_SYNC here, as the guest's AC'97 driver4253 * relies on exact (virtual) DMA timing and uses DMA Position Buffers4254 * instead of the LPIB registers.4255 */4256 static const char * const s_apszNames[] = { "AC97 PI", "AC97 PO", "AC97 MC" };4257 AssertCompile(RT_ELEMENTS(s_apszNames) == AC97_MAX_STREAMS);4258 AssertCompile(RT_ELEMENTS(pThis->ahTimers) == AC97_MAX_STREAMS);4259 for (unsigned i = 0; i < AC97_MAX_STREAMS; i++)4260 {4261 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL_SYNC, ichac97R3Timer, &pThis->aStreams[i],4262 TMTIMER_FLAGS_NO_CRIT_SECT, s_apszNames[i], &pThis->ahTimers[i]);4263 AssertRCReturn(rc, rc);4264 4265 rc = PDMDevHlpTimerSetCritSect(pDevIns, pThis->ahTimers[i], &pThis->CritSect);4266 AssertRCReturn(rc, rc);4267 }4268 4258 4269 4259 /* -
trunk/src/VBox/Devices/Audio/HDAStream.cpp
r82332 r82345 54 54 pStream->pMixSink = NULL; 55 55 pStream->pHDAState = pThis; 56 pStream->hTimer = pThis->ahTimers[u8SD];56 Assert(pStream->hTimer != NIL_TMTIMERHANDLE); /* hdaR3Construct initalized this one already. */ 57 57 58 58 pStream->State.fInReset = false; -
trunk/src/VBox/Devices/Audio/HDAStream.h
r82332 r82345 235 235 /** Pointer to HDA sink this stream is attached to. */ 236 236 R3PTRTYPE(PHDAMIXERSINK) pMixSink; 237 /** Stream's timer (copy of HDASTATE::ahTimers[u8SD]). */237 /** The timer for pumping data thru the attached LUN drivers. */ 238 238 TMTIMERHANDLE hTimer; 239 239 /** The stream'S critical section to serialize access. */
Note:
See TracChangeset
for help on using the changeset viewer.