VirtualBox

Changeset 76049 in vbox for trunk/src


Ignore:
Timestamp:
Dec 7, 2018 10:51:32 AM (6 years ago)
Author:
vboxsync
Message:

Audio/HDA: Implemented adaptive stream timer Hz rates, based on the stream's channel count.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DevHDACommon.h

    r76019 r76049  
    9696 *       a higher Hz rate, as the device emulation otherwise will come into
    9797 *       timing trouble, making the output (DMA reads) crackling. */
    98 #define HDA_TIMER_HZ_DEFAULT        200
     98#define HDA_TIMER_HZ_DEFAULT        100
    9999
    100100/** Default position adjustment (in audio samples).
  • trunk/src/VBox/Devices/Audio/HDAStream.cpp

    r76045 r76049  
    239239    AssertRCReturn(rc, rc);
    240240
     241    /*
     242     * Set the stream's timer Hz rate, based on the stream channel count.
     243     * Currently this is just a rough guess and we might want to optimize this further.
     244     *
     245     * In any case, more channels per SDI/SDO means that we have to drive data more frequently.
     246     */
     247    if (pThis->uTimerHz == HDA_TIMER_HZ_DEFAULT) /* Make sure that we don't have any custom Hz rate set we want to enforce */
     248    {
     249        if (Props.cChannels >= 5)
     250            pStream->State.uTimerHz = 300;
     251        else if (Props.cChannels == 4)
     252            pStream->State.uTimerHz = 150;
     253        else
     254            pStream->State.uTimerHz = 100;
     255    }
     256    else
     257        pStream->State.uTimerHz = pThis->uTimerHz;
     258
    241259#ifndef VBOX_WITH_AUDIO_HDA_51_SURROUND
    242260    if (Props.cChannels > 2)
     
    329347    {
    330348        /* Make sure that the chosen Hz rate dividable by the stream's rate. */
    331         if (pStream->State.Cfg.Props.uHz % pThis->uTimerHz != 0)
    332             LogRel(("HDA: Device timer (%RU32) does not fit to stream #%RU8 timing (%RU32)\n",
    333                     pThis->uTimerHz, pStream->u8SD, pStream->State.Cfg.Props.uHz));
     349        if (pStream->State.Cfg.Props.uHz % pStream->State.uTimerHz != 0)
     350            LogRel(("HDA: Stream timer Hz rate (%RU32) does not fit to stream #%RU8 timing (%RU32)\n",
     351                    pStream->State.uTimerHz, pStream->u8SD, pStream->State.Cfg.Props.uHz));
    334352
    335353        /* Figure out how many transfer fragments we're going to use for this stream. */
     
    427445        /* Calculate the bytes we need to transfer to / from the stream's DMA per iteration.
    428446         * This is bound to the device's Hz rate and thus to the (virtual) timing the device expects. */
    429         pStream->State.cbTransferChunk = (pStream->State.Cfg.Props.uHz / pThis->uTimerHz) * pStream->State.Mapping.cbFrameSize;
     447        pStream->State.cbTransferChunk = (pStream->State.Cfg.Props.uHz / pStream->State.uTimerHz) * pStream->State.Mapping.cbFrameSize;
    430448        Assert(pStream->State.cbTransferChunk);
    431449        Assert(pStream->State.cbTransferChunk % pStream->State.Mapping.cbFrameSize == 0);
     
    435453            pStream->State.cbTransferChunk = pStream->State.cbTransferSize;
    436454
    437         const uint64_t cTicksPerHz = TMTimerGetFreq(pStream->pTimer) / pThis->uTimerHz;
     455        const uint64_t cTicksPerHz = TMTimerGetFreq(pStream->pTimer) / pStream->State.uTimerHz;
    438456
    439457        /* Calculate the timer ticks per byte for this stream. */
     
    447465        LogFunc(("[SD%RU8] Timer %uHz (%RU64 ticks per Hz), cTicksPerByte=%RU64, cbTransferChunk=%RU32, cTransferTicks=%RU64, " \
    448466                 "cbTransferSize=%RU32\n",
    449                  pStream->u8SD, pThis->uTimerHz, cTicksPerHz, pStream->State.cTicksPerByte,
     467                 pStream->u8SD, pStream->State.uTimerHz, cTicksPerHz, pStream->State.cTicksPerByte,
    450468                 pStream->State.cbTransferChunk, pStream->State.cTransferTicks, pStream->State.cbTransferSize));
    451469
  • trunk/src/VBox/Devices/Audio/HDAStream.h

    r76018 r76049  
    150150     *  BDLE interrupt-on-completion (IOC) bits set. */
    151151    uint8_t                 cTransferPendingInterrupts;
    152     uint8_t                 Padding2[4];
     152    uint8_t                 Padding2[2];
     153    /** The stream's timer Hz rate.
     154     *  This value can can be different from the device's default Hz rate,
     155     *  depending on the rate the stream expects (e.g. for 5.1 speaker setups).
     156     *  Set in hdaR3StreamInit(). */
     157    uint16_t                uTimerHz;
    153158    /** Number of audio data frames for the position adjustment.
    154159     *  0 if no position adjustment is needed. */
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