VirtualBox

Ignore:
Timestamp:
Dec 18, 2015 1:24:53 PM (9 years ago)
Author:
vboxsync
Message:

DevIchHda.cpp: Use the time at the start of the hdaTimer callback when rescheduling it. Use the TMTimerGet* functions instead of the PDMDevHlp variants. Some documentation amendments.

File:
1 edited

Legend:

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

    r59174 r59182  
    737737    bool                               fRCEnabled;
    738738#ifndef VBOX_WITH_AUDIO_CALLBACKS
    739     /** The emulation timer for handling the attached
    740      *  LUN drivers. */
     739    /** The timer for pumping data thru the attached LUN drivers. */
    741740    PTMTIMERR3                         pTimer;
    742     /** Timer ticks for handling the LUN drivers. */
    743     uint64_t                           uTimerTicks;
    744     /** Timestamp (delta) since last timer call. */
     741    /** The timer interval for pumping data thru the LUN drivers in timer ticks. */
     742    uint64_t                           cTimerTicks;
     743    /** Timestamp of the last timer callback (hdaTimer).
     744     * Used to calculate the time actually elapsed between two timer callbacks. */
    745745    uint64_t                           uTimerTS;
    746746#endif
     
    756756    union
    757757    {
    758         /** List of associated LUN drivers. */
     758        /** List of associated LUN drivers (HDADRIVER). */
    759759        RTLISTANCHOR                   lstDrv;
    760760        /** Padding for alignment. */
     
    30283028static DECLCALLBACK(void) hdaTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    30293029{
    3030     PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
    3031     AssertPtrReturnVoid(pThis);
     3030    PHDASTATE pThis = (PHDASTATE)pvUser;
     3031    Assert(pThis == PDMINS_2_DATA(pDevIns, PHDASTATE));
     3032    AssertPtr(pThis);
    30323033
    30333034    STAM_PROFILE_START(&pThis->StatTimer, a);
    3034 
    3035     int rc = VINF_SUCCESS;
    30363035
    30373036    uint32_t cbInMax  = 0;
     
    30403039    PHDADRIVER pDrv;
    30413040
    3042     uint32_t cbIn, cbOut;
    3043 
    3044     uint64_t uTicksNow     = PDMDevHlpTMTimeVirtGet(pDevIns);
    3045     uint64_t uTicksElapsed = uTicksNow  - pThis->uTimerTS;
    3046     uint64_t uTicksPerSec  = PDMDevHlpTMTimeVirtGetFreq(pDevIns);
     3041    uint64_t uTicksNow     = TMTimerGet(pTimer);
     3042    uint64_t cTicksElapsed = uTicksNow  - pThis->uTimerTS;
     3043    uint64_t cTicksPerSec  = TMTimerGetFreq(pTimer);
    30473044
    30483045    pThis->uTimerTS = uTicksNow;
     
    30503047    RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node)
    30513048    {
    3052         cbIn = cbOut = 0;
    3053         rc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector,
    3054                                               &cbIn, &cbOut, NULL /* cSamplesLive */);
     3049        uint32_t cbIn = 0;
     3050        uint32_t cbOut = 0;
     3051
     3052        int rc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector, &cbIn, &cbOut, NULL /* pcSamplesLive */);
    30553053        if (RT_SUCCESS(rc))
    3056             rc = pDrv->pConnector->pfnPlayOut(pDrv->pConnector, NULL /* cSamplesPlayed */);
     3054            rc = pDrv->pConnector->pfnPlayOut(pDrv->pConnector, NULL /* pcSamplesPlayed */);
    30573055
    30583056#ifdef DEBUG_TIMER
     
    30703068            || !fIsActiveOut)
    30713069        {
    3072             uint32_t cSamplesMin  = (int)((2 * uTicksElapsed * pDrv->Out.pStrmOut->Props.uHz + uTicksPerSec) / uTicksPerSec / 2);
     3070            uint32_t cSamplesMin  = (int)((2 * cTicksElapsed * pDrv->Out.pStrmOut->Props.uHz + cTicksPerSec) / cTicksPerSec / 2);
    30733071            uint32_t cbSamplesMin = AUDIOMIXBUF_S2B(&pDrv->Out.pStrmOut->MixBuf, cSamplesMin);
    30743072
     
    30953093
    30963094    /* Kick the timer again. */
    3097     TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->uTimerTicks);
     3095    uint64_t cTicks = pThis->cTimerTicks;
     3096    /** @todo adjust cTicks down by now much cbOutMin represents. */
     3097    TMTimerSet(pThis->pTimer, uTicksNow + cTicks);
    30983098
    30993099    STAM_PROFILE_STOP(&pThis->StatTimer, a);
     
    41744174    if (pThis->pTimer)
    41754175    {
    4176         rc2 = TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->uTimerTicks);
     4176        rc2 = TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->cTimerTicks);
    41774177        AssertRC(rc2);
    41784178    }
     
    46324632        {
    46334633            /** @todo Investigate why sounds is getting corrupted if the "ticks" value is too
    4634              *        low, e.g. "PDMDevHlpTMTimeVirtGetFreq / 200". */
    4635             pThis->uTimerTicks = PDMDevHlpTMTimeVirtGetFreq(pDevIns) / 500; /** @todo Make this configurable! */
    4636             pThis->uTimerTS    = PDMDevHlpTMTimeVirtGet(pDevIns);
    4637             if (pThis->uTimerTicks < 100)
    4638                 pThis->uTimerTicks = 100;
    4639             LogFunc(("Timer ticks=%RU64\n", pThis->uTimerTicks));
     4634             *        low, e.g. "PDMDevHlpTMTimeVirtGetFreq / 200".
     4635             *  Update: Because the guest doesn't prepare enough data at a time. */
     4636            pThis->cTimerTicks = TMTimerGetFreq(pThis->pTimer) / 500; /** @todo Make this configurable! */
     4637            pThis->uTimerTS    = TMTimerGet(pThis->pTimer);
     4638            LogFunc(("Timer ticks=%RU64\n", pThis->cTimerTicks));
    46404639
    46414640            /* Fire off timer. */
    4642             TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->uTimerTicks);
     4641            TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->cTimerTicks);
    46434642        }
    46444643    }
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