VirtualBox

Changeset 59186 in vbox


Ignore:
Timestamp:
Dec 18, 2015 2:11:44 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
104804
Message:

DevIchAc97.cpp: Use the time at the start of the ac97Timer callback when rescheduling it. Use the TMTimerGet* functions instead of the PDMDevHlp variants. Some documentation amendments. Use newly introduced RTLISTNODER3 to avoid padding unions in cross context code.

File:
1 edited

Legend:

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

    r59171 r59186  
    304304typedef struct AC97DRIVER
    305305{
    306     union
    307     {
    308         /** Node for storing this driver in our device driver
    309          *  list of AC97STATE. */
    310         RTLISTNODE                     Node;
    311         struct
    312         {
    313             R3PTRTYPE(void *)          dummy1;
    314             R3PTRTYPE(void *)          dummy2;
    315         } dummy;
    316     };
    317 
     306    /** Node for storing this driver in our device driver list of AC97STATE. */
     307    RTLISTNODER3                       Node;
    318308    /** Pointer to AC97 controller (state). */
    319309    R3PTRTYPE(PAC97STATE)              pAC97State;
     
    356346    AC97STREAM              StrmStOut;
    357347#ifndef VBOX_WITH_AUDIO_CALLBACKS
    358     /** The emulation timer for handling the attached
    359      *  LUN drivers. */
     348    /** The timer for pumping data thru the attached LUN drivers. */
    360349    PTMTIMERR3              pTimer;
    361     /** Timer ticks for handling the LUN drivers. */
    362     uint64_t                uTimerTicks;
    363     /** Timestamp (delta) since last timer call. */
     350    /** The timer interval for pumping data thru the LUN drivers in timer ticks. */
     351    uint64_t                cTimerTicks;
     352    /** Timestamp of the last timer callback (ac97Timer).
     353     * Used to calculate the time actually elapsed between two timer callbacks. */
    364354    uint64_t                uTimerTS;
    365355#endif
     
    369359    STAMCOUNTER             StatBytesWritten;
    370360#endif
    371     /** List of associated LUN drivers. */
     361    /** List of associated LUN drivers (AC97DRIVER). */
    372362    RTLISTANCHOR            lstDrv;
    373363    /** The device' software mixer. */
     
    11771167static DECLCALLBACK(void) ichac97Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
    11781168{
    1179     PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE);
    1180     AssertPtrReturnVoid(pThis);
     1169    PAC97STATE pThis = (PAC97STATE)pvUser;
     1170    Assert(pThis == PDMINS_2_DATA(pDevIns, PAC97STATE));
     1171    AssertPtr(pThis);
    11811172
    11821173    STAM_PROFILE_START(&pThis->StatTimer, a);
     
    11911182    uint32_t cbIn, cbOut;
    11921183
    1193     uint64_t uTicksNow     = PDMDevHlpTMTimeVirtGet(pDevIns);
    1194     uint64_t uTicksElapsed = uTicksNow  - pThis->uTimerTS;
    1195     uint64_t uTicksPerSec  = PDMDevHlpTMTimeVirtGetFreq(pDevIns);
    1196 
    1197     pThis->uTimerTS = uTicksNow;
     1184    uint64_t cTicksNow     = TMTimerGet(pTimer);
     1185    uint64_t cTicksElapsed = cTicksNow  - pThis->uTimerTS;
     1186    uint64_t cTicksPerSec  = TMTimerGetFreq(pTimer);
     1187
     1188    pThis->uTimerTS = cTicksNow;
    11981189
    11991190    RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    12001191    {
    1201         cbIn = cbOut = 0;
     1192        uint32_t cbIn = 0;
     1193        uint32_t cbOut = 0;
     1194
    12021195        rc = pDrv->pConnector->pfnQueryStatus(pDrv->pConnector,
    12031196                                              &cbIn, &cbOut, NULL /* cSamplesLive */);
     
    12191212            || !fIsActiveOut)
    12201213        {
    1221             uint32_t cSamplesMin  = (int)((2 * uTicksElapsed * pDrv->Out.pStrmOut->Props.uHz + uTicksPerSec) / uTicksPerSec / 2);
     1214            uint32_t cSamplesMin  = (int)((2 * cTicksElapsed * pDrv->Out.pStrmOut->Props.uHz + cTicksPerSec) / cTicksPerSec / 2);
    12221215            uint32_t cbSamplesMin = AUDIOMIXBUF_S2B(&pDrv->Out.pStrmOut->MixBuf, cSamplesMin);
    12231216
     
    12541247        ichac97TransferAudio(pThis, PI_INDEX, cbInMax); /** @todo Add rc! */
    12551248
    1256     TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->uTimerTicks);
     1249    /* Kick the timer again. */
     1250    uint64_t cTicks = pThis->cTimerTicks;
     1251    /** @todo adjust cTicks down by now much cbOutMin represents. */
     1252    TMTimerSet(pThis->pTimer, cTicksNow + cTicks);
    12571253
    12581254    STAM_PROFILE_STOP(&pThis->StatTimer, a);
     
    24852481        if (RT_SUCCESS(rc))
    24862482        {
    2487             pThis->uTimerTicks = PDMDevHlpTMTimeVirtGetFreq(pDevIns) / 200; /** Hz. @todo Make this configurable! */
    2488             pThis->uTimerTS    = PDMDevHlpTMTimeVirtGet(pDevIns);
    2489             if (pThis->uTimerTicks < 100)
    2490                 pThis->uTimerTicks = 100;
    2491             LogFunc(("Timer ticks=%RU64\n", pThis->uTimerTicks));
     2483            pThis->cTimerTicks = TMTimerGetFreq(pThis->pTimer) / 200; /** @todo Make this configurable! */
     2484            pThis->uTimerTS    = TMTimerGet(pThis->pTimer);
     2485            LogFunc(("Timer ticks=%RU64\n", pThis->cTimerTicks));
    24922486
    24932487            /* Fire off timer. */
    2494             TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->uTimerTicks);
     2488            TMTimerSet(pThis->pTimer, TMTimerGet(pThis->pTimer) + pThis->cTimerTicks);
    24952489        }
    24962490    }
Note: See TracChangeset for help on using the changeset viewer.

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