VirtualBox

Changeset 71704 in vbox


Ignore:
Timestamp:
Apr 6, 2018 12:52:24 PM (7 years ago)
Author:
vboxsync
Message:

DevHDA: hdaTimer + hdaStreamTransferIsScheduled: Please don't make unnecessary calls getting results you might not need. Things like TMTimerGet() can be expensive.

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

Legend:

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

    r70975 r71704  
    27962796    /* Flag indicating whether to kick the timer again for a
    27972797     * new data processing round. */
    2798     const bool fSinkActive     = AudioMixerSinkIsActive(pStream->pMixSink->pMixSink);
    2799     const bool fTimerScheduled = hdaStreamTransferIsScheduled(pStream);
    2800 
    2801     Log3Func(("fSinksActive=%RTbool, fTimerScheduled=%RTbool\n", fSinkActive, fTimerScheduled));
    2802 
    2803     if (    fSinkActive
    2804         && !fTimerScheduled)
    2805     {
    2806         hdaTimerSet(pThis, pStream,
    2807                     TMTimerGet(pThis->pTimer[pStream->u8SD]) + TMTimerGetFreq(pThis->pTimer[pStream->u8SD]) / pStream->pHDAState->u16TimerHz,
    2808                     true /* fForce */);
    2809     }
     2798    const bool fSinkActive = AudioMixerSinkIsActive(pStream->pMixSink->pMixSink);
     2799    if (fSinkActive)
     2800    {
     2801        const bool fTimerScheduled = hdaStreamTransferIsScheduled(pStream);
     2802        Log3Func(("fSinksActive=%RTbool, fTimerScheduled=%RTbool\n", fSinkActive, fTimerScheduled));
     2803        if (!fTimerScheduled)
     2804            hdaTimerSet(pThis, pStream,
     2805                          TMTimerGet(pThis->pTimer[pStream->u8SD])
     2806                        + TMTimerGetFreq(pThis->pTimer[pStream->u8SD]) / pStream->pHDAState->u16TimerHz,
     2807                        true /* fForce */);
     2808    }
     2809    else
     2810        Log3Func(("fSinksActive=%RTbool\n", fSinkActive));
    28102811
    28112812    DEVHDA_UNLOCK_BOTH(pThis, pStream->u8SD);
  • trunk/src/VBox/Devices/Audio/HDAStream.cpp

    r70975 r71704  
    619619bool hdaStreamTransferIsScheduled(PHDASTREAM pStream)
    620620{
    621     if (!pStream)
    622         return false;
    623 
    624     AssertPtrReturn(pStream->pHDAState, false);
    625 
    626     const uint64_t tsNow = TMTimerGet(pStream->pTimer);
    627 
    628     const bool fScheduled =    pStream->State.fRunning
    629                             && (   pStream->State.cTransferPendingInterrupts
    630                                 || pStream->State.tsTransferNext > tsNow);
    631 
    632 #ifdef LOG_ENABLED
    633     if (fScheduled)
    634     {
    635         if (pStream->State.cTransferPendingInterrupts)
    636             Log3Func(("[SD%RU8] Scheduled (%RU8 IRQs pending)\n",
    637                       pStream->u8SD, pStream->State.cTransferPendingInterrupts));
    638         else
    639             Log3Func(("[SD%RU8] Scheduled in %RU64\n",
    640                       pStream->u8SD, pStream->State.tsTransferNext - tsNow));
    641     }
    642 #endif
    643 
    644     return fScheduled;
     621    if (pStream)
     622    {
     623        AssertPtrReturn(pStream->pHDAState, false);
     624
     625        if (pStream->State.fRunning)
     626        {
     627            if (pStream->State.cTransferPendingInterrupts)
     628            {
     629                Log3Func(("[SD%RU8] Scheduled (%RU8 IRQs pending)\n", pStream->u8SD, pStream->State.cTransferPendingInterrupts));
     630                return true;
     631            }
     632
     633            const uint64_t tsNow = TMTimerGet(pStream->pTimer);
     634            if (pStream->State.tsTransferNext > tsNow)
     635            {
     636                Log3Func(("[SD%RU8] Scheduled in %RU64\n", pStream->u8SD, pStream->State.tsTransferNext - tsNow));
     637                return true;
     638            }
     639        }
     640    }
     641    return false;
    645642}
    646643
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