VirtualBox

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


Ignore:
Timestamp:
Jun 24, 2021 11:28:32 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
145343
Message:

DevHda: Kicked out the InitialDelayMs config value and associated code. DrvAudio is responsible for prebuffering. bugref:9890

Location:
trunk/src/VBox/Devices/Audio
Files:
4 edited

Legend:

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

    r89878 r89885  
    45284528                                  "BufSizeInMs"
    45294529                                  "|BufSizeOutMs"
    4530                                   "|InitialDelayMs"
    45314530                                  "|DebugEnabled"
    45324531                                  "|DebugPathOut",
     
    45524551        return PDMDEV_SET_ERROR(pDevIns, VERR_OUT_OF_RANGE,
    45534552                                N_("HDA configuration error: 'BufSizeOutMs' is out of bound, max 2000 ms"));
    4554 
    4555     /** @devcfgm{hda,InitialDelayMs,uint16_t,0,256,12,ms}
    4556      * How long to delay when a stream starts before engaging the asynchronous I/O
    4557      * thread from the DMA timer callback.  Because it's used from the DMA timer
    4558      * callback, it will implicitly be rounded up to the next timer period.
    4559      * This is for adding a little host scheduling leeway into the playback. */
    4560     /** @todo InitialDelayMs is rather pointless, DrvAudio does pre-buffering in
    4561      * both directions now. (bird, 2021-06-08) */
    4562     rc = pHlp->pfnCFGMQueryU16Def(pCfg, "InitialDelayMs", &pThis->msInitialDelay, 12);
    4563     if (RT_FAILURE(rc))
    4564          return PDMDEV_SET_ERROR(pDevIns, rc, N_("HDA configuration error: failed to read 'InitialDelayMs' as uint16_t"));
    4565     if (pThis->msInitialDelay > 256)
    4566         return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    4567                                    N_("HDA configuration error: Out of range: 0 <= InitialDelayMs < 256: %u"), pThis->msInitialDelay);
    45684553
    45694554    rc = pHlp->pfnCFGMQueryBoolDef(pCfg, "DebugEnabled", &pThisCC->Dbg.fEnabled, false);
  • trunk/src/VBox/Devices/Audio/DevHda.h

    r89878 r89885  
    143143    /** Current IRQ level. */
    144144    uint8_t                 u8IRQL;
    145     uint8_t                 abPadding[4 + 2];
    146     /** Number of milliseconds to delay kicking off the AIO when a stream starts.
    147      * @sa InitialDelayMs config value.  */
    148     uint16_t                msInitialDelay;
    149145    /** Config: Internal input DMA buffer size override, specified in milliseconds.
    150146     * Zero means default size according to buffer and stream config.
  • trunk/src/VBox/Devices/Audio/DevHdaStream.cpp

    r89884 r89885  
    683683       work the AIO thread. */
    684684    pStreamShared->State.fInputPreBuffered = false;
    685     pStreamShared->State.cbInputPreBuffer  = PDMAudioPropsMilliToBytes(&pCfg->Props, pThis->msInitialDelay);
    686     pStreamShared->State.cbInputPreBuffer  = RT_MIN(cbMaxPeriod * 2, pStreamShared->State.cbInputPreBuffer);
     685    pStreamShared->State.cbInputPreBuffer  = cbMaxPeriod * 2;
    687686
    688687    /*
     
    750749     *       channels we don't support / need to save space.
    751750     */
    752     uint32_t cbCircBuf = PDMAudioPropsMilliToBytes(&pCfg->Props, pThis->msInitialDelay + RT_MS_1SEC * 6 / uTransferHz);
     751    uint32_t cbCircBuf = PDMAudioPropsMilliToBytes(&pCfg->Props, RT_MS_1SEC * 6 / uTransferHz);
    753752    LogRel2(("HDA: Stream #%RU8 default ring buffer size is %RU32 bytes / %RU64 ms\n",
    754753             uSD, cbCircBuf, PDMAudioPropsBytesToMilli(&pCfg->Props, cbCircBuf)));
     
    861860    pStreamShared->State.tsLastTransferNs = 0;
    862861    pStreamShared->State.tsLastReadNs     = 0;
    863     pStreamShared->State.tsAioDelayEnd    = UINT64_MAX;
    864862    pStreamShared->State.tsStart          = 0;
    865863
     
    10071005    pStreamShared->State.tsLastReadNs  = RTTimeNanoTS();
    10081006    pStreamShared->State.tsStart       = tsNow;
    1009     pStreamShared->State.tsAioDelayEnd = tsNow + PDMDevHlpTimerFromMilli(pDevIns, pStreamShared->hTimer, pThis->msInitialDelay);
    1010     Log3Func(("#%u: tsStart=%RU64 tsAioDelayEnd=%RU64 tsLastReadNs=%RU64\n", pStreamShared->u8SD,
    1011               pStreamShared->State.tsStart, pStreamShared->State.tsAioDelayEnd, pStreamShared->State.tsLastReadNs));
    1012 
     1007    Log3Func(("#%u: tsStart=%RU64 tsLastReadNs=%RU64\n",
     1008              pStreamShared->u8SD, pStreamShared->State.tsStart, pStreamShared->State.tsLastReadNs));
     1009    RT_NOREF(pDevIns, pThis);
    10131010}
    10141011
     
    10191016{
    10201017    Log3Func(("#%u\n", pStreamShared->u8SD));
    1021     pStreamShared->State.tsAioDelayEnd = UINT64_MAX;
     1018    RT_NOREF(pStreamShared);
    10221019}
    10231020
     
    13721369}
    13731370#endif /* IN_RING3 || VBOX_HDA_WITH_ON_REG_ACCESS_DMA */
    1374 
    13751371
    13761372#ifdef IN_RING3
     
    22362232        /*
    22372233         * Should we push data to down thru the mixer to and to the host drivers?
    2238          *
    2239          * We initially delay this by pThis->msInitialDelay, but after than we'll
    2240          * kick the AIO thread every time we've put more data in the buffer (which is
    2241          * every time) as the host audio device needs to get data in a timely manner.
    2242          *
    2243          * (We used to try only wake up the AIO thread according to pThis->uIoTimer
    2244          * and host wall clock, but that meant we would miss a wakup after the DMA
    2245          * timer was called a little late or if TM entered into catch-up mode.)
    22462234         */
    2247         bool fKickAioThread;
    2248         if (!pStreamShared->State.tsAioDelayEnd)
    2249             fKickAioThread = pStreamShared->State.offWrite > offWriteBefore
    2250                           || hdaR3StreamGetFree(pStreamR3) < pStreamShared->State.cbAvgTransfer * 2;
    2251         else if (PDMDevHlpTimerGet(pDevIns, pStreamShared->hTimer) >= pStreamShared->State.tsAioDelayEnd)
    2252         {
    2253             Log3Func(("Initial delay done: Passed tsAioDelayEnd.\n"));
    2254             pStreamShared->State.tsAioDelayEnd = 0;
    2255             fKickAioThread = true;
    2256         }
    2257         else if (hdaR3StreamGetFree(pStreamR3) < pStreamShared->State.cbAvgTransfer * 2)
    2258         {
    2259             Log3Func(("Initial delay done: Passed running short on buffer.\n"));
    2260             pStreamShared->State.tsAioDelayEnd = 0;
    2261             fKickAioThread = true;
    2262         }
    2263         else
    2264         {
    2265             Log3Func(("Initial delay pending...\n"));
    2266             fKickAioThread = false;
    2267         }
     2235        bool fKickAioThread = pStreamShared->State.offWrite > offWriteBefore
     2236                           || hdaR3StreamGetFree(pStreamR3) < pStreamShared->State.cbAvgTransfer * 2;
    22682237
    22692238        Log3Func(("msDelta=%RU64 (vs %u) cbStreamFree=%#x (vs %#x) => fKickAioThread=%RTbool\n",
  • trunk/src/VBox/Devices/Audio/DevHdaStream.h

    r89876 r89885  
    116116    uint64_t                tsLastReadNs;
    117117
    118     /** This is set to the timer clock time when the msInitialDelay period is over.
    119      * Once reached, this is set to zero to avoid unnecessary time queries. */
    120     uint64_t                tsAioDelayEnd;
    121118    /** The start time for the playback (on the timer clock). */
    122119    uint64_t                tsStart;
     
    154151    /** Current loop number within the current scheduling step.  */
    155152    uint32_t                idxScheduleLoop;
    156 
    157     /** Aligning the next members on 16 bytes. */
    158     uint64_t                u64Padding;
    159153
    160154    /** Buffer descriptors and additional timer scheduling state.
     
    252246    TMTIMERHANDLE               hTimer;
    253247
    254 #if 0
    255248    /** Pad the structure size to a 64 byte alignment. */
    256249    uint64_t                    au64Padding1[2];
    257 #endif
    258250} HDASTREAM;
    259251AssertCompileMemberAlignment(HDASTREAM, State.aBdl, 16);
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