VirtualBox

Changeset 82328 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Dec 2, 2019 5:05:58 PM (5 years ago)
Author:
vboxsync
Message:

DevIchAc97: Simplified ichac97R3TimerSet, avoiding an unnecessary TMTimerGet call. bugref:9218

File:
1 edited

Legend:

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

    r82325 r82328  
    651651static void               ichac97R3BDLEDumpAll(PAC97STATE pThis, uint64_t u64BDLBase, uint16_t cBDLE);
    652652# endif
    653 static bool               ichac97R3TimerSet(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint64_t tsExpire, bool fForce);
     653DECLINLINE(void)          ichac97R3TimerSet(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint64_t cTicksToDeadline);
    654654#endif /* IN_RING3 */
    655655
     
    26062606    {
    26072607        ichac97R3StreamTransferUpdate(pDevIns, pThis, pStream, pStream->Regs.picb << 1); /** @todo r=andy Assumes 16-bit samples. */
    2608 
    2609         ichac97R3TimerSet(pDevIns, pThis, pStream,
    2610                           PDMDevHlpTimerGet(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD))
    2611                         + pStream->State.cTransferTicks,
    2612                         false /* fForce */);
     2608        ichac97R3TimerSet(pDevIns, pThis, pStream, pStream->State.cTransferTicks);
    26132609    }
    26142610
     
    26202616 * Sets the virtual device timer to a new expiration time.
    26212617 *
    2622  * @returns Whether the new expiration time was set or not.
    26232618 * @param   pDevIns             The device instance.
    26242619 * @param   pThis               AC'97 state.
    26252620 * @param   pStream             AC'97 stream to set timer for.
    2626  * @param   tsExpire            New (virtual) expiration time to set.
    2627  * @param   fForce              Whether to force setting the expiration time or not.
    2628  *
    2629  * @remark  This function takes all active AC'97 streams and their
    2630  *          current timing into account. This is needed to make sure
    2631  *          that all streams can match their needed timing.
    2632  *
    2633  *          To achieve this, the earliest (lowest) timestamp of all
    2634  *          active streams found will be used for the next scheduling slot.
    2635  *
    2636  *          Forcing a new expiration time will override the above mechanism.
    2637  */
    2638 static bool ichac97R3TimerSet(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint64_t tsExpire, bool fForce)
    2639 {
    2640     AssertPtrReturn(pThis, false);
    2641     AssertPtrReturn(pStream, false);
    2642 
    2643     RT_NOREF(fForce);
    2644 
    2645     uint64_t tsExpireMin = tsExpire;
    2646 
    2647     TMTIMERHANDLE const hTimer = RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD);
    2648     /** @todo r=bird: This is rather silly given that all three callers just did
    2649      *        TimerGet + interval. */
    2650     const uint64_t tsNow = PDMDevHlpTimerGet(pDevIns, hTimer);
    2651 
    2652     /* Make sure to not go backwards in time, as this will assert in TMTimerSet(). */
    2653     if (tsExpireMin < tsNow)
    2654         tsExpireMin = tsNow;
    2655 
    2656     int rc = PDMDevHlpTimerSet(pDevIns, hTimer, tsExpireMin);
    2657     AssertRCReturn(rc, false);
    2658 
    2659     return true;
     2621 * @param   cTicksToDeadline    The number of ticks to the new deadline.
     2622 *
     2623 * @remarks This used to be more complicated a long time ago...
     2624 */
     2625DECLINLINE(void) ichac97R3TimerSet(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STREAM pStream, uint64_t cTicksToDeadline)
     2626{
     2627    int rc = PDMDevHlpTimerSetRelative(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD),
     2628                                       cTicksToDeadline, NULL /*pu64Now*/);
     2629    AssertRC(rc);
    26602630}
    26612631
     
    31473117                            /* Arm the timer for this stream. */
    31483118                            /** @todo r=bird: This function returns bool, not VBox status! */
    3149                             int rc2 = ichac97R3TimerSet(pDevIns, pThis, pStream,
    3150                                                         PDMDevHlpTimerGet(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers,
    3151                                                                                                       pStream->u8SD))
    3152                                                       + pStream->State.cTransferTicks,
    3153                                                       false /* fForce */);
    3154                             AssertRC(rc2);
     3119                            ichac97R3TimerSet(pDevIns, pThis, pStream, pStream->State.cTransferTicks);
    31553120                        }
    31563121                    }
     
    36403605
    36413606        rc2 = ichac97R3StreamEnable(pThis, pStream, fEnable);
     3607        AssertRC(rc2);
    36423608        if (   fEnable
    36433609            && RT_SUCCESS(rc2))
     
    36453611            /* Re-arm the timer for this stream. */
    36463612            /** @todo r=bird: This function returns bool, not VBox status! */
    3647             rc2 = ichac97R3TimerSet(pDevIns, pThis, pStream,
    3648                                     PDMDevHlpTimerGet(pDevIns, RT_SAFE_SUBSCRIPT8(pThis->ahTimers, pStream->u8SD))
    3649                                   + pStream->State.cTransferTicks,
    3650                                   false /* fForce */);
    3651         }
    3652 
    3653         AssertRC(rc2);
     3613            ichac97R3TimerSet(pDevIns, pThis, pStream, pStream->State.cTransferTicks);
     3614        }
     3615
    36543616        /* Keep going. */
    36553617    }
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