VirtualBox

Ignore:
Timestamp:
Jul 20, 2018 9:29:47 AM (6 years ago)
Author:
vboxsync
Message:

Audio/Main: Implemented feeding the pre-buffering, buffer size and period size (all in ms) values on a per-driver level from extra data into CFGM.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r73239 r73258  
    34283428}
    34293429
     3430/**
     3431 * Retrieves an uint32_t value from audio's extra data branch and returns a default value
     3432 * if not found or an invalid value is found.
     3433 *
     3434 * @return VBox status code.
     3435 * @param  pVirtualBox          Pointer to IVirtualBox instance.
     3436 * @param  pMachine             Pointer to IMachine instance.
     3437 * @param  pszDriverName        Audio driver name to retrieve value for.
     3438 * @param  pszValue             Value name to retrieve.
     3439 * @param  uDefault             Default value to return if value not found / invalid.
     3440 */
     3441uint32_t Console::i_getAudioDriverValU32(IVirtualBox *pVirtualBox, IMachine *pMachine,
     3442                                         const char *pszDriverName, const char *pszValue, uint32_t uDefault)
     3443{
     3444    Utf8StrFmt strPath("VBoxInternal2/Audio/%s/%s", pszDriverName, pszValue);
     3445
     3446    Utf8Str strTmp;
     3447    GetExtraDataBoth(pVirtualBox, pMachine, strPath.c_str(), &strTmp);
     3448
     3449    if (strTmp.isNotEmpty())
     3450        return strTmp.toUInt32();
     3451
     3452    return uDefault;
     3453}
     3454
     3455/**
     3456 * Configures an audio driver via CFGM by getting (optional) values from extra data.
     3457 *
     3458 * @return VBox status code.
     3459 * @param  pAudioAdapter        Pointer to audio adapter instance. Needed for the driver's input / output configuration.
     3460 * @param  pVirtualBox          Pointer to IVirtualBox instance.
     3461 * @param  pMachine             Pointer to IMachine instance.
     3462 * @param  pLUN                 Pointer to CFGM node of LUN (the driver) to configure.
     3463 * @param  pszDrvName           Name of the driver to configure.
     3464 */
    34303465int Console::i_configAudioDriver(IAudioAdapter *pAudioAdapter, IVirtualBox *pVirtualBox, IMachine *pMachine,
    3431                                  PCFGMNODE pLUN, const char *pszDriverName)
     3466                                 PCFGMNODE pLUN, const char *pszDrvName)
    34323467{
    34333468#define H()         AssertLogRelMsgReturn(!FAILED(hrc), ("hrc=%Rhrc\n", hrc), VERR_MAIN_CONFIG_CONSTRUCTOR_COM_ERROR)
     
    34383473    GetExtraDataBoth(pVirtualBox, pMachine, "VBoxInternal2/Audio/Debug/Enabled", &strTmp);
    34393474    const uint64_t fDebugEnabled = (strTmp.equalsIgnoreCase("true") || strTmp.equalsIgnoreCase("1")) ? 1 : 0;
    3440 
    3441     Utf8Str strDebugPathOut;
    3442     GetExtraDataBoth(pVirtualBox, pMachine, "VBoxInternal2/Audio/Debug/PathOut", &strDebugPathOut);
    34433475
    34443476    BOOL fAudioEnabledIn = FALSE;
     
    34513483    PCFGMNODE pCfg;
    34523484    InsertConfigNode(pLUN,   "Config", &pCfg);
    3453         InsertConfigString (pCfg, "DriverName",    pszDriverName);
     3485        InsertConfigString (pCfg, "DriverName",    pszDrvName);
    34543486        InsertConfigInteger(pCfg, "InputEnabled",  fAudioEnabledIn);
    34553487        InsertConfigInteger(pCfg, "OutputEnabled", fAudioEnabledOut);
    3456         InsertConfigInteger(pCfg, "DebugEnabled",  fDebugEnabled);
    3457         InsertConfigString (pCfg, "DebugPathOut",  strDebugPathOut.c_str());
     3488
     3489        if (fDebugEnabled)
     3490        {
     3491            InsertConfigInteger(pCfg, "DebugEnabled",  fDebugEnabled);
     3492
     3493            Utf8Str strDebugPathOut;
     3494            GetExtraDataBoth(pVirtualBox, pMachine, "VBoxInternal2/Audio/Debug/PathOut", &strDebugPathOut);
     3495            InsertConfigString(pCfg, "DebugPathOut",  strDebugPathOut.c_str());
     3496        }
     3497
     3498        InsertConfigInteger(pCfg, "PeriodMs",
     3499                            i_getAudioDriverValU32(pVirtualBox, pMachine, pszDrvName, "PeriodMs", 0 /* Default */));
     3500        InsertConfigInteger(pCfg, "BufferSizeMs",
     3501                            i_getAudioDriverValU32(pVirtualBox, pMachine, pszDrvName, "BufferSizeMs", 0 /* Default */));
     3502        InsertConfigInteger(pCfg, "PreBufferMs",
     3503                            i_getAudioDriverValU32(pVirtualBox, pMachine, pszDrvName, "PreBufferMs", UINT32_MAX /* Default */));
    34583504
    34593505    PCFGMNODE pLunL1;
     
    34663512            InsertConfigString(pCfg, "StreamName", bstrTmp);
    34673513
    3468         InsertConfigString(pLunL1, "Driver", pszDriverName);
    3469 
    3470     LogFlowFunc(("szDrivName=%s, hrc=%Rhrc\n", pszDriverName, hrc));
     3514        InsertConfigString(pLunL1, "Driver", pszDrvName);
     3515
     3516    LogFlowFunc(("szDrivName=%s, hrc=%Rhrc\n", pszDrvName, hrc));
    34713517    return hrc;
    34723518
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