VirtualBox

Changeset 75606 in vbox


Ignore:
Timestamp:
Nov 20, 2018 10:26:04 AM (6 years ago)
Author:
vboxsync
Message:

Forward ported r126743 - r126749:

r126749 (5.2: Audio/CoreAudio: Resolved a todo: Use the stream backend's buffer size for initializing the internal ring buffer instead of some random value).
r126747 (5.2: Audio/AC97: Removed dead code (VBOX_WITH_AUDIO_AC97_CALLBACKS, never has been used and not needed anyway)).
r126746 (5.2: Build fix).
r126745 (5.2: Audio/HDA: Renaming nit).
r126744 (5.2: Audio/AC97: Fixed setting the stream's scheduling hint).
r126743 (5.2: Audio/AC97: Fix for ichac97R3StreamAsyncIOThread() when async I/O is enabled (currently disabled)).

Location:
trunk/src/VBox/Devices
Files:
6 edited

Legend:

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

    r75422 r75606  
    15511551            LogRelMax2(64, ("HDA: Stream #%RU8 interrupt lagging behind (expected %uus, got %uus), trying to catch up ...\n",
    15521552                            pStream->u8SD,
    1553                             (TMTimerGetFreq(pThis->pTimer[pStream->u8SD]) / pThis->u16TimerHz) / 1000,(tsNow - pStream->State.tsTransferLast) / 1000));
     1553                            (TMTimerGetFreq(pThis->pTimer[pStream->u8SD]) / pThis->uTimerHz) / 1000,(tsNow - pStream->State.tsTransferLast) / 1000));
    15541554
    15551555            cTicksToNext = 0;
     
    29272927            hdaR3TimerSet(pThis, pStream,
    29282928                            TMTimerGet(pThis->pTimer[pStream->u8SD])
    2929                           + TMTimerGetFreq(pThis->pTimer[pStream->u8SD]) / pStream->pHDAState->u16TimerHz,
     2929                          + TMTimerGetFreq(pThis->pTimer[pStream->u8SD]) / pStream->pHDAState->uTimerHz,
    29302930                          true /* fForce */);
    29312931    }
     
    49334933
    49344934
    4935     rc = CFGMR3QueryU16Def(pCfg, "TimerHz", &pThis->u16TimerHz, HDA_TIMER_HZ_DEFAULT /* Default value, if not set. */);
     4935    rc = CFGMR3QueryU16Def(pCfg, "TimerHz", &pThis->uTimerHz, HDA_TIMER_HZ_DEFAULT /* Default value, if not set. */);
    49364936    if (RT_FAILURE(rc))
    49374937        return PDMDEV_SET_ERROR(pDevIns, rc,
    49384938                                N_("HDA configuration error: failed to read Hertz (Hz) rate as unsigned integer"));
    49394939
    4940     if (pThis->u16TimerHz != HDA_TIMER_HZ_DEFAULT)
    4941         LogRel(("HDA: Using custom device timer rate (%RU16Hz)\n", pThis->u16TimerHz));
     4940    if (pThis->uTimerHz != HDA_TIMER_HZ_DEFAULT)
     4941        LogRel(("HDA: Using custom device timer rate (%RU16Hz)\n", pThis->uTimerHz));
    49424942
    49434943    rc = CFGMR3QueryBoolDef(pCfg, "PosAdjustEnabled", &pThis->fPosAdjustEnabled, true);
  • trunk/src/VBox/Devices/Audio/DevHDA.h

    r71730 r75606  
    203203    uint8_t                            u8IRQL;
    204204    /** The device timer Hz rate. Defaults to HDA_TIMER_HZ_DEFAULT. */
    205     uint16_t                           u16TimerHz;
     205    uint16_t                           uTimerHz;
    206206    /** Padding for alignment. */
    207207    uint8_t                            au8Padding3[3];
  • trunk/src/VBox/Devices/Audio/DevIchAc97.cpp

    r74066 r75606  
    5151
    5252/** Default timer frequency (in Hz). */
    53 #define AC97_TIMER_HZ      200
     53#define AC97_TIMER_HZ_DEFAULT 200
    5454
    5555/** Maximum FIFO size (in bytes). */
     
    472472    /** Number of active (running) SDn streams. */
    473473    uint8_t                 cStreamsActive;
    474 #ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS
    475474    /** Flag indicating whether the timer is active or not. */
    476475    bool                    fTimerActive;
    477     uint8_t                 u8Padding1[2];
     476    /** The device timer Hz rate. Defaults to AC97_TIMER_HZ_DEFAULT_DEFAULT. */
     477    uint16_t                uTimerHz;
    478478    /** The timer for pumping data thru the attached LUN drivers - RCPtr. */
    479479    PTMTIMERRC              pTimerRC;
     
    487487     * Used to calculate the time actually elapsed between two timer callbacks. */
    488488    uint64_t                uTimerTS;
    489 #endif
    490489#ifdef VBOX_WITH_STATISTICS
    491490    STAMPROFILE             StatTimer;
     
    636635
    637636static DECLCALLBACK(void) ichac97R3Reset(PPDMDEVINS pDevIns);
    638 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS
     637
    639638static int                ichac97R3TimerStart(PAC97STATE pThis);
    640639static int                ichac97R3TimerMaybeStart(PAC97STATE pThis);
     
    643642static void               ichac97R3TimerMain(PAC97STATE pThis);
    644643static DECLCALLBACK(void) ichac97R3Timer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser);
    645 # endif
     644
    646645static void               ichac97R3DoTransfers(PAC97STATE pThis);
    647646
     
    877876    ichac97R3StreamUnlock(pStream);
    878877
    879 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS
    880878    /* Second, see if we need to start or stop the timer. */
    881879    if (!fEnable)
     
    883881    else
    884882        ichac97R3TimerMaybeStart(pThis);
    885 # endif
    886883
    887884    LogFunc(("[SD%RU8] cStreamsActive=%RU8, fEnable=%RTbool, rc=%Rrc\n", pStream->u8SD, pThis->cStreamsActive, fEnable, rc));
     
    12141211
    12151212    PAC97STREAMSTATEAIO pAIO = &pCtx->pStream->State.AIO;
    1216 
    1217     PRTCIRCBUF pCircBuf = pStream->State.pCircBuf;
    1218     AssertPtr(pCircBuf);
    1219 
    1220     PAUDMIXSINK pMixSink = ichac97R3IndexToSink(pThis, pStream->u8SD);
    1221     AssertPtr(pMixSink);
    12221213
    12231214    ASMAtomicXchgBool(&pAIO->fStarted, true);
     
    19261917
    19271918    /* Set scheduling hint (if available). */
    1928     if (pThis->cTimerTicks)
    1929         pCfg->Device.uSchedulingHintMs = 1000 /* ms */ / (TMTimerGetFreq(pThis->pTimerR3) / pThis->cTimerTicks);
     1919    if (pThis->uTimerHz)
     1920        pCfg->Device.uSchedulingHintMs = 1000 /* ms */ / pThis->uTimerHz;
    19301921
    19311922    switch (pStream->u8SD)
     
    24132404# endif /* Unused */
    24142405
    2415 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS
    2416 
    24172406/**
    24182407 * Starts the internal audio device timer.
     
    25842573    ichac97R3TimerMain(pThis);
    25852574}
    2586 
    2587 # endif /* !VBOX_WITH_AUDIO_AC97_CALLBACKS */
    25882575
    25892576/**
     
    37443731    AudioMixerSinkReset(pThis->pSinkOut);
    37453732
    3746 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS
    37473733    /*
    37483734     * Stop the timer, if any.
     
    37513737
    37523738    pThis->cStreamsActive = 0;
    3753 # endif
    37543739}
    37553740
     
    40143999    PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE);
    40154000    pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    4016 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS
    4017     pThis->pTimerRC = TMTimerRCPtr(pThis->pTimerR3);
    4018 # endif
     4001    pThis->pTimerRC  = TMTimerRCPtr(pThis->pTimerR3);
    40194002}
    40204003
     
    40854068                                N_("AC'97 configuration error: Querying \"Codec\" as string failed"));
    40864069
    4087 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS
    4088     uint16_t uTimerHz;
    4089     rc = CFGMR3QueryU16Def(pCfg, "TimerHz", &uTimerHz, AC97_TIMER_HZ /* Default value, if not set. */);
     4070    rc = CFGMR3QueryU16Def(pCfg, "TimerHz", &pThis->uTimerHz, AC97_TIMER_HZ_DEFAULT /* Default value, if not set. */);
    40904071    if (RT_FAILURE(rc))
    40914072        return PDMDEV_SET_ERROR(pDevIns, rc,
    40924073                                N_("AC'97 configuration error: failed to read Hertz (Hz) rate as unsigned integer"));
    40934074
    4094     if (uTimerHz != AC97_TIMER_HZ)
    4095         LogRel(("AC97: Using custom device timer rate (%RU16Hz)\n", uTimerHz));
    4096 # endif
     4075    if (pThis->uTimerHz != AC97_TIMER_HZ_DEFAULT)
     4076        LogRel(("AC97: Using custom device timer rate (%RU16Hz)\n", pThis->uTimerHz));
    40974077
    40984078    rc = CFGMR3QueryBoolDef(pCfg, "DebugEnabled", &pThis->Dbg.fEnabled, false);
     
    43544334        ichac97R3Reset(pDevIns);
    43554335
    4356 # ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS
    43574336    if (RT_SUCCESS(rc))
    43584337    {
     
    43744353        AssertRCReturn(rc, rc);
    43754354
    4376         pThis->cTimerTicks = TMTimerGetFreq(pThis->pTimerR3) / uTimerHz;
     4355        pThis->cTimerTicks = TMTimerGetFreq(pThis->pTimerR3) / pThis->uTimerHz;
    43774356        pThis->uTimerTS    = TMTimerGet(pThis->pTimerR3);
    4378         LogFunc(("Timer ticks=%RU64 (%RU16 Hz)\n", pThis->cTimerTicks, uTimerHz));
    4379     }
    4380 # else /* !VBOX_WITH_AUDIO_AC97_CALLBACKS */
    4381     if (RT_SUCCESS(rc))
    4382     {
    4383         PAC97DRIVER pDrv;
    4384         RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    4385         {
    4386             /* Only register primary driver.
    4387              * The device emulation does the output multiplexing then. */
    4388             if (!(pDrv->fFlags & PDMAUDIODRVFLAGS_PRIMARY))
    4389                 continue;
    4390 
    4391             PDMAUDIOCBRECORD AudioCallbacks[2];
    4392 
    4393             AC97CALLBACKCTX Ctx = { pThis, pDrv };
    4394 
    4395             AudioCallbacks[0].enmType     = PDMAUDIOCALLBACKTYPE_INPUT;
    4396             AudioCallbacks[0].pfnCallback = ac97CallbackInput;
    4397             AudioCallbacks[0].pvCtx       = &Ctx;
    4398             AudioCallbacks[0].cbCtx       = sizeof(AC97CALLBACKCTX);
    4399 
    4400             AudioCallbacks[1].enmType     = PDMAUDIOCALLBACKTYPE_OUTPUT;
    4401             AudioCallbacks[1].pfnCallback = ac97CallbackOutput;
    4402             AudioCallbacks[1].pvCtx       = &Ctx;
    4403             AudioCallbacks[1].cbCtx       = sizeof(AC97CALLBACKCTX);
    4404 
    4405             rc = pDrv->pConnector->pfnRegisterCallbacks(pDrv->pConnector, AudioCallbacks, RT_ELEMENTS(AudioCallbacks));
    4406             if (RT_FAILURE(rc))
    4407                 break;
    4408         }
    4409     }
    4410 # endif /* VBOX_WITH_AUDIO_AC97_CALLBACKS */
     4357        LogFunc(("Timer ticks=%RU64 (%RU16 Hz)\n", pThis->cTimerTicks, pThis->uTimerHz));
     4358    }
    44114359
    44124360# ifdef VBOX_WITH_STATISTICS
  • trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp

    r75318 r75606  
    15961596    }
    15971597
    1598     rc = RTCircBufCreate(&pCAStream->pCircBuf, PDMAUDIOSTREAMCFG_F2B(pCfgReq, 4096)); /** @todo Make this configurable. */
     1598    rc = RTCircBufCreate(&pCAStream->pCircBuf, PDMAUDIOSTREAMCFG_F2B(pCfgReq, pCfgReq->Backend.cfBufferSize));
    15991599    if (RT_FAILURE(rc))
    16001600        return rc;
  • trunk/src/VBox/Devices/Audio/HDAStream.cpp

    r74037 r75606  
    198198
    199199    /* Set scheduling hint (if available). */
    200     if (pThis->u16TimerHz)
    201         pCfg->Device.uSchedulingHintMs = 1000 /* ms */ / pThis->u16TimerHz;
     200    if (pThis->uTimerHz)
     201        pCfg->Device.uSchedulingHintMs = 1000 /* ms */ / pThis->uTimerHz;
    202202
    203203    /* (Re-)Allocate the stream's internal DMA buffer, based on the PCM  properties we just got above. */
     
    274274    {
    275275        /* Make sure that the chosen Hz rate dividable by the stream's rate. */
    276         if (pStream->State.Cfg.Props.uHz % pThis->u16TimerHz != 0)
     276        if (pStream->State.Cfg.Props.uHz % pThis->uTimerHz != 0)
    277277            LogRel(("HDA: Device timer (%RU32) does not fit to stream #RU8 timing (%RU32)\n",
    278                     pThis->u16TimerHz, pStream->State.Cfg.Props.uHz));
     278                    pThis->uTimerHz, pStream->State.Cfg.Props.uHz));
    279279
    280280        /* Figure out how many transfer fragments we're going to use for this stream. */
     
    369369        /* Calculate the bytes we need to transfer to / from the stream's DMA per iteration.
    370370         * This is bound to the device's Hz rate and thus to the (virtual) timing the device expects. */
    371         pStream->State.cbTransferChunk = (pStream->State.Cfg.Props.uHz / pThis->u16TimerHz) * pStream->State.cbFrameSize;
     371        pStream->State.cbTransferChunk = (pStream->State.Cfg.Props.uHz / pThis->uTimerHz) * pStream->State.cbFrameSize;
    372372        Assert(pStream->State.cbTransferChunk);
    373373        Assert(pStream->State.cbTransferChunk % pStream->State.cbFrameSize == 0);
     
    382382        pStream->State.tsLastUpdateNs             = 0;
    383383
    384         const uint64_t cTicksPerHz = TMTimerGetFreq(pStream->pTimer) / pThis->u16TimerHz;
     384        const uint64_t cTicksPerHz = TMTimerGetFreq(pStream->pTimer) / pThis->uTimerHz;
    385385
    386386        /* Calculate the timer ticks per byte for this stream. */
     
    398398        LogFunc(("[SD%RU8] Timer %uHz (%RU64 ticks per Hz), cTicksPerByte=%RU64, cbTransferChunk=%RU32, cTransferTicks=%RU64, " \
    399399                 "cbTransferSize=%RU32\n",
    400                  pStream->u8SD, pThis->u16TimerHz, cTicksPerHz, pStream->State.cTicksPerByte,
     400                 pStream->u8SD, pThis->uTimerHz, cTicksPerHz, pStream->State.cTicksPerByte,
    401401                 pStream->State.cbTransferChunk, pStream->State.cTransferTicks, pStream->State.cbTransferSize));
    402402
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r75586 r75606  
    19171917    GEN_CHECK_OFF(AC97STATE, StreamOut);
    19181918    GEN_CHECK_OFF(AC97STATE, cStreamsActive);
    1919 #ifndef VBOX_WITH_AUDIO_AC97_CALLBACKS
    19201919    GEN_CHECK_OFF(AC97STATE, pTimerR3);
    19211920    GEN_CHECK_OFF(AC97STATE, pTimerR0);
    19221921    GEN_CHECK_OFF(AC97STATE, pTimerRC);
    19231922    GEN_CHECK_OFF(AC97STATE, fTimerActive);
    1924     GEN_CHECK_OFF(AC97STATE, u8Padding1);
     1923    GEN_CHECK_OFF(AC97STATE, uTimerHz);
    19251924    GEN_CHECK_OFF(AC97STATE, cTimerTicks);
    19261925    GEN_CHECK_OFF(AC97STATE, uTimerTS);
    1927 #endif
    19281926#ifdef VBOX_WITH_STATISTICS
    19291927    GEN_CHECK_OFF(AC97STATE, StatTimer);
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