Changeset 82332 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Dec 3, 2019 12:30:11 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevHDA.cpp
r82331 r82332 1427 1427 AssertRC(rc2); 1428 1428 1429 rc2 = hdaR3TimerSet(pDevIns, pThis, pStream, 1430 PDMDevHlpTimerGet(pDevIns, pThis->ahTimers[pStream->u8SD]) 1431 + pStream->State.cTransferTicks, 1432 false /* fForce */); 1429 uint64_t const tsNow = PDMDevHlpTimerGet(pDevIns, pStream->hTimer); 1430 rc2 = hdaR3TimerSet(pDevIns, pStream, tsNow + pStream->State.cTransferTicks, false /* fForce */, tsNow); 1433 1431 AssertRC(rc2); 1434 1432 } … … 1521 1519 HDA_PROCESS_INTERRUPT(pDevIns, pThis); 1522 1520 1523 const uint64_t tsNow = PDMDevHlpTimerGet(pDevIns, p This->ahTimers[uSD]);1521 const uint64_t tsNow = PDMDevHlpTimerGet(pDevIns, pStream->hTimer); 1524 1522 Assert(tsNow >= pStream->State.tsTransferLast); 1525 1523 … … 1547 1545 LogRelMax2(64, ("HDA: Stream #%RU8 interrupt lagging behind (expected %uus, got %uus), trying to catch up ...\n", 1548 1546 pStream->u8SD, 1549 (PDMDevHlpTimerGetFreq(pDevIns, p This->ahTimers[pStream->u8SD]) / pThis->uTimerHz) / 1000,1547 (PDMDevHlpTimerGetFreq(pDevIns, pStream->hTimer) / pThis->uTimerHz) / 1000, 1550 1548 (tsNow - pStream->State.tsTransferLast) / 1000)); 1551 1549 … … 1568 1566 /* Re-arm the timer. */ 1569 1567 LogFunc(("Timer set SD%RU8\n", pStream->u8SD)); 1570 hdaR3TimerSet(pDevIns, p This, pStream, tsNow + cTicksToNext, false /* fForce*/);1568 hdaR3TimerSet(pDevIns, pStream, tsNow + cTicksToNext, true /* fForce - we just set tsTransferNext*/, 0 /*tsNow*/); 1571 1569 } 1572 1570 } … … 2860 2858 if (fSinkActive) 2861 2859 { 2862 const bool fTimerScheduled = hdaR3StreamTransferIsScheduled(pDevIns, pStream); 2860 uint64_t const tsNow = PDMDevHlpTimerGet(pDevIns, hTimer); /* (For virtual sync this remains the same for the whole callout IIRC) */ 2861 const bool fTimerScheduled = hdaR3StreamTransferIsScheduled(pStream, tsNow); 2863 2862 Log3Func(("fSinksActive=%RTbool, fTimerScheduled=%RTbool\n", fSinkActive, fTimerScheduled)); 2864 2863 if (!fTimerScheduled) 2865 hdaR3TimerSet(pDevIns, pThis, pStream, 2866 PDMDevHlpTimerGet(pDevIns, hTimer) 2867 + PDMDevHlpTimerGetFreq(pDevIns, hTimer) / pStream->pHDAState->uTimerHz, 2868 true /* fForce */); 2864 hdaR3TimerSet(pDevIns, pStream, tsNow + PDMDevHlpTimerGetFreq(pDevIns, hTimer) / pThis->uTimerHz, 2865 true /*fForce*/, tsNow /*fixed*/ ); 2869 2866 } 2870 2867 else … … 2911 2908 } 2912 2909 2913 switch (enmAccessType)2910 switch (enmAccessType) 2914 2911 { 2915 2912 case PGMACCESSTYPE_WRITE: … … 3628 3625 hdaR3StreamRegisterDMAHandlers(pThis, pStream); 3629 3626 #endif 3630 if (hdaR3StreamTransferIsScheduled(p DevIns, pStream))3631 hdaR3TimerSet(pDevIns, p This, pStream, hdaR3StreamTransferGetNext(pStream), true /* fForce*/);3627 if (hdaR3StreamTransferIsScheduled(pStream, PDMDevHlpTimerGet(pDevIns, pStream->hTimer))) 3628 hdaR3TimerSet(pDevIns, pStream, hdaR3StreamTransferGetNext(pStream), true /*fForce*/, 0 /*tsNow*/); 3632 3629 3633 3630 /* Also keep track of the currently active streams. */ -
trunk/src/VBox/Devices/Audio/DevHDACommon.cpp
r82331 r82332 665 665 * @returns Whether the new expiration time was set or not. 666 666 * @param pDevIns The device instance. 667 * @param pThis HDA state.668 667 * @param pStream HDA stream to set timer for. 669 668 * @param tsExpire New (virtual) expiration time to set. 670 669 * @param fForce Whether to force setting the expiration time or not. 670 * @param tsNow The current clock timestamp if available, 0 if not. 671 671 * 672 672 * @remark This function takes all active HDA streams and their … … 679 679 * Forcing a new expiration time will override the above mechanism. 680 680 */ 681 bool hdaR3TimerSet(PPDMDEVINS pDevIns, PHDASTATE pThis, PHDASTREAM pStream, uint64_t tsExpire, bool fForce) 682 { 683 AssertPtr(pThis); 681 bool hdaR3TimerSet(PPDMDEVINS pDevIns, PHDASTREAM pStream, uint64_t tsExpire, bool fForce, uint64_t tsNow) 682 { 684 683 AssertPtr(pStream); 685 684 686 uint64_t tsExpireMin = tsExpire; 685 if (!tsNow) 686 tsNow = PDMDevHlpTimerGet(pDevIns, pStream->hTimer); 687 687 688 688 if (!fForce) … … 691 691 * PDMDevHlpTimerGet(), so, some callers does one, this does, and then we do 692 692 * right afterwards == very inefficient! */ 693 if (hdaR3StreamTransferIsScheduled(p DevIns, pStream))693 if (hdaR3StreamTransferIsScheduled(pStream, tsNow)) 694 694 { 695 695 uint64_t const tsNext = hdaR3StreamTransferGetNext(pStream); 696 if (tsExpire Min> tsNext)697 tsExpire Min= tsNext;696 if (tsExpire > tsNext) 697 tsExpire = tsNext; 698 698 } 699 699 } 700 701 const uint64_t tsNow = PDMDevHlpTimerGet(pDevIns, pStream->hTimer);702 700 703 701 /* … … 705 703 * This in theory could happen in hdaR3StreamTransferGetNext() from above. 706 704 */ 707 if (tsExpire Min< tsNow)708 tsExpire Min= tsNow;709 710 int rc = PDMDevHlpTimerSet(pDevIns, pStream->hTimer, tsExpire Min);705 if (tsExpire < tsNow) 706 tsExpire = tsNow; 707 708 int rc = PDMDevHlpTimerSet(pDevIns, pStream->hTimer, tsExpire); 711 709 AssertRCReturn(rc, false); 712 710 -
trunk/src/VBox/Devices/Audio/DevHDACommon.h
r82331 r82332 653 653 */ 654 654 #ifdef IN_RING3 655 bool hdaR3TimerSet(PPDMDEVINS pDevIns, PHDAST ATE pThis, PHDASTREAM pStream, uint64_t u64Expire, bool fForce);655 bool hdaR3TimerSet(PPDMDEVINS pDevIns, PHDASTREAM pStream, uint64_t u64Expire, bool fForce, uint64_t tsNow); 656 656 #endif 657 657 /** @} */ -
trunk/src/VBox/Devices/Audio/HDAStream.cpp
r82331 r82332 720 720 * 721 721 * @returns True if a next transfer is scheduled, false if not. 722 * @param pDevIns The device instance.723 722 * @param pStream HDA stream to retrieve schedule status for. 724 */ 725 bool hdaR3StreamTransferIsScheduled(PPDMDEVINS pDevIns, PHDASTREAM pStream) 723 * @param tsNow The current time. 724 */ 725 bool hdaR3StreamTransferIsScheduled(PHDASTREAM pStream, uint64_t tsNow) 726 726 { 727 727 if (pStream) … … 737 737 } 738 738 739 const uint64_t tsNow = PDMDevHlpTimerGet(pDevIns, pStream->hTimer);740 739 if (pStream->State.tsTransferNext > tsNow) 741 740 { … … 913 912 * @param pStream HDA stream to update. 914 913 * @param cbToProcessMax How much data (in bytes) to process as maximum. 915 */ 916 int hdaR3StreamTransfer(PPDMDEVINS pDevIns, PHDASTREAM pStream, uint32_t cbToProcessMax) 914 * @param fInTimer Set if we're in the timer callout. 915 */ 916 static int hdaR3StreamTransfer(PPDMDEVINS pDevIns, PHDASTREAM pStream, uint32_t cbToProcessMax, bool fInTimer) 917 917 { 918 918 AssertPtrReturn(pStream, VERR_INVALID_POINTER); … … 1379 1379 1380 1380 LogFunc(("Timer set SD%RU8\n", pStream->u8SD)); 1381 hdaR3TimerSet(pDevIns, pStream->pHDAState, pStream, tsTransferNext, false /* fForce */); 1381 Assert(!fInTimer || tsNow == PDMDevHlpTimerGet(pDevIns, pStream->hTimer)); 1382 hdaR3TimerSet(pDevIns, pStream, tsTransferNext, true /* fForce - skip tsTransferNext check */, fInTimer ? tsNow : 0); 1382 1383 1383 1384 pStream->State.tsTransferNext = tsTransferNext; … … 1450 1451 { 1451 1452 /* Do the DMA transfer. */ 1452 rc2 = hdaR3StreamTransfer(pDevIns, pStream, cbStreamFree );1453 rc2 = hdaR3StreamTransfer(pDevIns, pStream, cbStreamFree, fInTimer); 1453 1454 AssertRC(rc2); 1454 1455 } … … 1571 1572 if (cbStreamUsed) 1572 1573 { 1573 rc2 = hdaR3StreamTransfer(pDevIns, pStream, cbStreamUsed );1574 rc2 = hdaR3StreamTransfer(pDevIns, pStream, cbStreamUsed, fInTimer); 1574 1575 AssertRC(rc2); 1575 1576 } -
trunk/src/VBox/Devices/Audio/HDAStream.h
r82331 r82332 272 272 uint32_t hdaR3StreamGetFree(PHDASTREAM pStream); 273 273 uint32_t hdaR3StreamGetUsed(PHDASTREAM pStream); 274 bool hdaR3StreamTransferIsScheduled(P PDMDEVINS pDevIns, PHDASTREAM pStream);274 bool hdaR3StreamTransferIsScheduled(PHDASTREAM pStream, uint64_t tsNow); 275 275 uint64_t hdaR3StreamTransferGetNext(PHDASTREAM pStream); 276 int hdaR3StreamTransfer(PPDMDEVINS pDevIns, PHDASTREAM pStream, uint32_t cbToProcessMax);277 276 void hdaR3StreamLock(PHDASTREAM pStream); 278 277 void hdaR3StreamUnlock(PHDASTREAM pStream);
Note:
See TracChangeset
for help on using the changeset viewer.