VirtualBox

Ignore:
Timestamp:
Dec 3, 2019 12:30:11 AM (5 years ago)
Author:
vboxsync
Message:

DevHDA: Reduce the number of PDMDevHlpTimerGet calls. bugref:9218

File:
1 edited

Legend:

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

    r82331 r82332  
    665665 * @returns Whether the new expiration time was set or not.
    666666 * @param   pDevIns     The device instance.
    667  * @param   pThis       HDA state.
    668667 * @param   pStream     HDA stream to set timer for.
    669668 * @param   tsExpire    New (virtual) expiration time to set.
    670669 * @param   fForce      Whether to force setting the expiration time or not.
     670 * @param   tsNow       The current clock timestamp if available, 0 if not.
    671671 *
    672672 * @remark  This function takes all active HDA streams and their
     
    679679 *          Forcing a new expiration time will override the above mechanism.
    680680 */
    681 bool hdaR3TimerSet(PPDMDEVINS pDevIns, PHDASTATE pThis, PHDASTREAM pStream, uint64_t tsExpire, bool fForce)
    682 {
    683     AssertPtr(pThis);
     681bool hdaR3TimerSet(PPDMDEVINS pDevIns, PHDASTREAM pStream, uint64_t tsExpire, bool fForce, uint64_t tsNow)
     682{
    684683    AssertPtr(pStream);
    685684
    686     uint64_t tsExpireMin = tsExpire;
     685    if (!tsNow)
     686        tsNow = PDMDevHlpTimerGet(pDevIns, pStream->hTimer);
    687687
    688688    if (!fForce)
     
    691691         * PDMDevHlpTimerGet(), so, some callers does one, this does, and then we do
    692692         * right afterwards == very inefficient! */
    693         if (hdaR3StreamTransferIsScheduled(pDevIns, pStream))
     693        if (hdaR3StreamTransferIsScheduled(pStream, tsNow))
    694694        {
    695695            uint64_t const tsNext = hdaR3StreamTransferGetNext(pStream);
    696             if (tsExpireMin > tsNext)
    697                 tsExpireMin = tsNext;
     696            if (tsExpire > tsNext)
     697                tsExpire = tsNext;
    698698        }
    699699    }
    700 
    701     const uint64_t tsNow = PDMDevHlpTimerGet(pDevIns, pStream->hTimer);
    702700
    703701    /*
     
    705703     * This in theory could happen in hdaR3StreamTransferGetNext() from above.
    706704     */
    707     if (tsExpireMin < tsNow)
    708         tsExpireMin = tsNow;
    709 
    710     int rc = PDMDevHlpTimerSet(pDevIns, pStream->hTimer, tsExpireMin);
     705    if (tsExpire < tsNow)
     706        tsExpire = tsNow;
     707
     708    int rc = PDMDevHlpTimerSet(pDevIns, pStream->hTimer, tsExpire);
    711709    AssertRCReturn(rc, false);
    712710
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