VirtualBox

Changeset 87436 in vbox


Ignore:
Timestamp:
Jan 26, 2021 4:59:29 PM (4 years ago)
Author:
vboxsync
Message:

Audio/HDA+AC97: Made the device emulation's internal [in|out]put FIFO buffer size configurable via extra data "VBoxInternal2/Audio/Device/BufSize[In|Out]Ms" (optional, defaults to 1000ms if not set). ticketoem2ref:36

Location:
trunk/src/VBox
Files:
6 edited

Legend:

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

    r87329 r87436  
    14691469                             uSD, cTicksToNext / 1000,  cTicksElapsed / 1000, pStreamShared->State.cTransferPendingInterrupts));
    14701470
    1471             cTicksToNext = 0;
     1471            cTicksToNext = pStreamShared->State.cTransferTicks;
    14721472        }
    14731473
     
    45964596     * Validate and read configuration.
    45974597     */
    4598     PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "TimerHz|PosAdjustEnabled|PosAdjustFrames|DebugEnabled|DebugPathOut", "");
    4599 
    4600     int rc = pHlp->pfnCFGMQueryU16Def(pCfg, "TimerHz", &pThis->uTimerHz, HDA_TIMER_HZ_DEFAULT /* Default value, if not set. */);
     4598    PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns, "BufSizeInMs|BufSizeOutMs|TimerHz|PosAdjustEnabled|PosAdjustFrames|DebugEnabled|DebugPathOut", "");
     4599
     4600    /* Note: Error checking of this value happens in hdaR3StreamSetUp(). */
     4601    int rc = pHlp->pfnCFGMQueryU16Def(pCfg, "BufSizeInMs", &pThis->cbCircBufInMs, RT_MS_1SEC /* Default value, if not set. */);
     4602    if (RT_FAILURE(rc))
     4603        return PDMDEV_SET_ERROR(pDevIns, rc,
     4604                                N_("HDA configuration error: failed to read input buffer size (ms) as unsigned integer"));
     4605
     4606    /* Note: Error checking of this value happens in hdaR3StreamSetUp(). */
     4607    rc = pHlp->pfnCFGMQueryU16Def(pCfg, "BufSizeOutMs", &pThis->cbCircBufOutMs, RT_MS_1SEC /* Default value, if not set. */);
     4608    if (RT_FAILURE(rc))
     4609        return PDMDEV_SET_ERROR(pDevIns, rc,
     4610                                N_("HDA configuration error: failed to read output buffer size (ms) as unsigned integer"));
     4611
     4612    rc = pHlp->pfnCFGMQueryU16Def(pCfg, "TimerHz", &pThis->uTimerHz, HDA_TIMER_HZ_DEFAULT /* Default value, if not set. */);
    46014613    if (RT_FAILURE(rc))
    46024614        return PDMDEV_SET_ERROR(pDevIns, rc,
  • trunk/src/VBox/Devices/Audio/DevHDA.h

    r82968 r87436  
    122122    /** The device timer Hz rate. Defaults to HDA_TIMER_HZ_DEFAULT. */
    123123    uint16_t                uTimerHz;
     124    /** Buffer size (in ms) of the internal input FIFO buffer.
     125     *  The actual buffer size in bytes will depend on the actual stream configuration. */
     126    uint16_t                cbCircBufInMs;
     127    /** Buffer size (in ms) of the internal output FIFO buffer.
     128     *  The actual buffer size in bytes will depend on the actual stream configuration. */
     129    uint16_t                cbCircBufOutMs;
    124130    /** Padding for alignment. */
    125     uint16_t                au16Padding3[3];
     131    uint16_t                u16Padding3;
    126132    /** Last updated wall clock (WALCLK) counter. */
    127133    uint64_t                u64WalClk;
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r87179 r87436  
    195195uint32_t DrvAudioHlpCalcBitrate(uint8_t cBits, uint32_t uHz, uint8_t cChannels);
    196196uint32_t DrvAudioHlpCalcBitrate(const PPDMAUDIOPCMPROPS pProps);
    197 uint32_t DrvAudioHlpBytesAlign(uint32_t cbSize, const PPDMAUDIOPCMPROPS pProps);
    198 bool     DrvAudioHlpBytesIsAligned(uint32_t cbSize, const PPDMAUDIOPCMPROPS pProps);
     197uint32_t DrvAudioHlpBytesAlign(size_t cbSize, const PPDMAUDIOPCMPROPS pProps);
     198bool     DrvAudioHlpBytesIsAligned(size_t cbSize, const PPDMAUDIOPCMPROPS pProps);
    199199uint32_t DrvAudioHlpBytesToFrames(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps);
    200200uint64_t DrvAudioHlpBytesToMilli(uint32_t cbBytes, const PPDMAUDIOPCMPROPS pProps);
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r82968 r87436  
    11811181 * @param   pProps              PCM properties to align size to.
    11821182 */
    1183 uint32_t DrvAudioHlpBytesAlign(uint32_t cbSize, const PPDMAUDIOPCMPROPS pProps)
     1183uint32_t DrvAudioHlpBytesAlign(size_t cbSize, const PPDMAUDIOPCMPROPS pProps)
    11841184{
    11851185    AssertPtrReturn(pProps, 0);
     
    11981198 * @param   pProps              PCM properties to use for checking the alignment.
    11991199 */
    1200 bool DrvAudioHlpBytesIsAligned(uint32_t cbSize, const PPDMAUDIOPCMPROPS pProps)
     1200bool DrvAudioHlpBytesIsAligned(size_t cbSize, const PPDMAUDIOPCMPROPS pProps)
    12011201{
    12021202    AssertPtrReturn(pProps, 0);
  • trunk/src/VBox/Devices/Audio/HDAStream.cpp

    r87427 r87436  
    361361    }
    362362
    363     /* By default we allocate an internal buffer of 100ms. */
    364     rc = RTCircBufCreate(&pStreamR3->State.pCircBuf,
    365                          DrvAudioHlpMilliToBytes(100 /* ms */, &pCfg->Props)); /** @todo Make this configurable. */
     363    const size_t cbCircBufDefault = DrvAudioHlpMilliToBytes(RT_MS_1SEC, &pCfg->Props);
     364
     365    size_t cbCircBuf = DrvAudioHlpMilliToBytes(  hdaGetDirFromSD(uSD) == PDMAUDIODIR_IN
     366                                               ? pThis->cbCircBufInMs : pThis->cbCircBufOutMs, &pCfg->Props);
     367
     368    ASSERT_GUEST_LOGREL_MSG_STMT(cbCircBuf,
     369                                 ("Ring buffer size for stream #%RU8 is invalid (%zu), setting to default\n", uSD, cbCircBuf),
     370                                 cbCircBuf = cbCircBufDefault);
     371    ASSERT_GUEST_LOGREL_MSG_STMT(DrvAudioHlpBytesIsAligned(cbCircBuf, &pCfg->Props),
     372                                 ("Ring buffer size for stream #%RU8 is misaligned (%zu), setting to default\n", uSD, cbCircBuf),
     373                                 cbCircBuf = cbCircBufDefault);
     374
     375    if (cbCircBuf != cbCircBufDefault)
     376        LogRel2(("HDA: Stream #%RU8 is using a custom ring buffer size of %RU64ms (%zu bytes)\n",
     377                 uSD, DrvAudioHlpBytesToMilli(cbCircBuf, &pCfg->Props), cbCircBuf));
     378
     379    rc = RTCircBufCreate(&pStreamR3->State.pCircBuf, cbCircBuf);
    366380    AssertRCReturn(rc, rc);
    367381
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r87395 r87436  
    29622962            const uint64_t uTimerHz = strTmp.toUInt64();
    29632963
     2964            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/Audio/Device/BufSizeInMs", &strTmp);
     2965            const uint64_t uBufSizeInMs = strTmp.toUInt64();
     2966
     2967            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/Audio/Device/BufSizeOutMs", &strTmp);
     2968            const uint64_t uBufSizeOutMs = strTmp.toUInt64();
     2969
    29642970            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/Audio/Debug/Enabled", &strTmp);
    29652971            const bool fDebugEnabled = strTmp.equalsIgnoreCase("true") || strTmp.equalsIgnoreCase("1");
     
    29963002                    if (uTimerHz)
    29973003                        InsertConfigInteger(pCfg,   "TimerHz",              uTimerHz);
     3004                    if (uBufSizeInMs)
     3005                        InsertConfigInteger(pCfg,   "BufSizeInMs",          uBufSizeInMs);
     3006                    if (uBufSizeOutMs)
     3007                        InsertConfigInteger(pCfg,   "BufSizeOutMs",         uBufSizeOutMs);
    29983008                    InsertConfigInteger(pCfg,       "DebugEnabled",         fDebugEnabled);
    29993009                    if (strDebugPathOut.isNotEmpty())
     
    30313041                    if (uTimerHz)
    30323042                        InsertConfigInteger(pCfg,   "TimerHz",              uTimerHz);
     3043                    if (uBufSizeInMs)
     3044                        InsertConfigInteger(pCfg,   "BufSizeInMs",          uBufSizeInMs);
     3045                    if (uBufSizeOutMs)
     3046                        InsertConfigInteger(pCfg,   "BufSizeOutMs",         uBufSizeOutMs);
    30333047                    InsertConfigInteger(pCfg,       "DebugEnabled",         fDebugEnabled);
    30343048                    if (strDebugPathOut.isNotEmpty())
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