VirtualBox

Changeset 87944 in vbox


Ignore:
Timestamp:
Mar 4, 2021 9:14:58 AM (4 years ago)
Author:
vboxsync
Message:

Audio/HDA: When starting / resuming (via saved state) stream transfers, call hdaR3StreamTimerMain() directly to avoid going through the timer to speed up startup time. ticketoem2ref:36

Location:
trunk/src/VBox/Devices/Audio
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DevHDA.cpp

    r87926 r87944  
    14381438                    AssertRC(rc2);
    14391439
    1440                     uint64_t const tsNow = PDMDevHlpTimerGet(pDevIns, pStreamShared->hTimer);
    1441                     rc2 = hdaR3TimerSet(pDevIns, pStreamShared, tsNow + pStreamShared->State.cTransferTicks, true /* fForce */, tsNow);
    1442                     AssertRC(rc2);
     1440                    /* Avoid going through the timer here by calling the stream's timer function directly.
     1441                     * Should speed up starting the stream transfers. */
     1442                    hdaR3StreamTimerMain(pDevIns, pThis, pThisCC, pStreamShared, pStreamR3);
    14431443                }
    14441444                else
     
    26492649    Assert(PDMDevHlpTimerIsLockOwner(pDevIns, hTimer));
    26502650
    2651     hdaR3StreamUpdate(pDevIns, pThis, pThisCC, pStreamShared, pStreamR3, true /* fInTimer */);
    2652 
    2653     /* Flag indicating whether to kick the timer again for a new data processing round. */
    2654     bool fSinkActive = false;
    2655     if (pStreamR3->pMixSink)
    2656         fSinkActive = AudioMixerSinkIsActive(pStreamR3->pMixSink->pMixSink);
    2657 
    2658 #ifdef LOG_ENABLED
    2659     const uint8_t uSD = pStreamShared->u8SD;
    2660 #endif
    2661 
    2662     if (fSinkActive)
    2663     {
    2664         const uint64_t tsNow           = PDMDevHlpTimerGet(pDevIns, hTimer); /* (For virtual sync this remains the same for the whole callout IIRC) */
    2665         const bool     fTimerScheduled = hdaR3StreamTransferIsScheduled(pStreamShared, tsNow);
    2666 
    2667         uint64_t tsTransferNext  = 0;
    2668         if (fTimerScheduled)
    2669         {
    2670             Assert(pStreamShared->State.tsTransferNext); /* Make sure that a new transfer timestamp is set. */
    2671             tsTransferNext = pStreamShared->State.tsTransferNext;
    2672         }
    2673         else /* Schedule at the precalculated rate. */
    2674             tsTransferNext = tsNow + pStreamShared->State.cTransferTicks;
    2675 
    2676         Log3Func(("[SD%RU8] fSinksActive=%RTbool, fTimerScheduled=%RTbool, tsTransferNext=%RU64 (in %RU64)\n",
    2677                   uSD, fSinkActive, fTimerScheduled, tsTransferNext, tsTransferNext - tsNow));
    2678 
    2679         hdaR3TimerSet(pDevIns, pStreamShared, tsTransferNext,
    2680                       true /*fForce*/, tsNow);
    2681     }
    2682     else
    2683         Log3Func(("[SD%RU8] fSinksActive=%RTbool\n", uSD, fSinkActive));
     2651    hdaR3StreamTimerMain(pDevIns, pThis, pThisCC, pStreamShared, pStreamR3);
    26842652}
    26852653
     
    35323500#endif
    35333501            if (hdaR3StreamTransferIsScheduled(pStreamShared, PDMDevHlpTimerGet(pDevIns, pStreamShared->hTimer)))
    3534                 hdaR3TimerSet(pDevIns, pStreamShared, hdaR3StreamTransferGetNext(pStreamShared), true /*fForce*/, 0 /*tsNow*/);
     3502            {
     3503                /* Avoid going through the timer here by calling the stream's timer function directly.
     3504                 * Should speed up starting the stream transfers. */
     3505                hdaR3StreamTimerMain(pDevIns, pThis, pThisCC, pStreamShared, pStreamR3);
     3506            }
    35353507
    35363508            /* Also keep track of the currently active streams. */
  • trunk/src/VBox/Devices/Audio/HDAStream.cpp

    r87942 r87944  
    16171617
    16181618/**
     1619 * The stream's main function when called by the timer.
     1620 *
     1621 * Note: This function also will be called without timer invocation
     1622 *       when starting (enabling) the stream to minimize startup latency.
     1623 *
     1624 * @param   pDevIns         The device instance.
     1625 * @param   pThis           The shared HDA device state.
     1626 * @param   pThisCC         The ring-3 HDA device state.
     1627 * @param   pStreamShared   HDA stream to update (shared bits).
     1628 * @param   pStreamR3       HDA stream to update (ring-3 bits).
     1629 */
     1630void hdaR3StreamTimerMain(PPDMDEVINS pDevIns, PHDASTATE pThis, PHDASTATER3 pThisCC,
     1631                          PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3)
     1632{
     1633    Assert(PDMDevHlpCritSectIsOwner(pDevIns, &pThis->CritSect));
     1634    Assert(PDMDevHlpTimerIsLockOwner(pDevIns, pStreamShared->hTimer));
     1635
     1636    hdaR3StreamUpdate(pDevIns, pThis, pThisCC, pStreamShared, pStreamR3, true /* fInTimer */);
     1637
     1638    /* Flag indicating whether to kick the timer again for a new data processing round. */
     1639    bool fSinkActive = false;
     1640    if (pStreamR3->pMixSink)
     1641        fSinkActive = AudioMixerSinkIsActive(pStreamR3->pMixSink->pMixSink);
     1642
     1643#ifdef LOG_ENABLED
     1644    const uint8_t uSD = pStreamShared->u8SD;
     1645#endif
     1646
     1647    if (fSinkActive)
     1648    {
     1649        const uint64_t tsNow           = PDMDevHlpTimerGet(pDevIns, pStreamShared->hTimer); /* (For virtual sync this remains the same for the whole callout IIRC) */
     1650        const bool     fTimerScheduled = hdaR3StreamTransferIsScheduled(pStreamShared, tsNow);
     1651
     1652        uint64_t tsTransferNext  = 0;
     1653        if (fTimerScheduled)
     1654        {
     1655            Assert(pStreamShared->State.tsTransferNext); /* Make sure that a new transfer timestamp is set. */
     1656            tsTransferNext = pStreamShared->State.tsTransferNext;
     1657        }
     1658        else /* Schedule at the precalculated rate. */
     1659            tsTransferNext = tsNow + pStreamShared->State.cTransferTicks;
     1660
     1661        Log3Func(("[SD%RU8] fSinksActive=%RTbool, fTimerScheduled=%RTbool, tsTransferNext=%RU64 (in %RU64)\n",
     1662                  uSD, fSinkActive, fTimerScheduled, tsTransferNext, tsTransferNext - tsNow));
     1663
     1664        hdaR3TimerSet(pDevIns, pStreamShared, tsTransferNext,
     1665                      true /*fForce*/, tsNow);
     1666    }
     1667    else
     1668        Log3Func(("[SD%RU8] fSinksActive=%RTbool\n", uSD, fSinkActive));
     1669}
     1670
     1671/**
    16191672 * Updates a HDA stream by doing its required data transfers.
    16201673 *
  • trunk/src/VBox/Devices/Audio/HDAStream.h

    r87830 r87944  
    286286int                 hdaR3StreamEnable(PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3, bool fEnable);
    287287void                hdaR3StreamSetPositionAdd(PHDASTREAM pStreamShared, PPDMDEVINS pDevIns, PHDASTATE pThis, uint32_t uToAdd);
     288void                hdaR3StreamTimerMain(PPDMDEVINS pDevIns, PHDASTATE pThis, PHDASTATER3 pThisCC,
     289                                         PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3);
    288290bool                hdaR3StreamTransferIsScheduled(PHDASTREAM pStreamShared, uint64_t tsNow);
    289291uint64_t            hdaR3StreamTransferGetNext(PHDASTREAM pStreamShared);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette