VirtualBox

Changeset 88216 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Mar 20, 2021 1:50:05 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143381
Message:

DrvAudio,ConsoleImpl2: Constructor cleanup, moved the input/output config and added range checks to it. bugref:9890

File:
1 edited

Legend:

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

    r88211 r88216  
    35993599    HRESULT hrc;
    36003600
    3601     Utf8Str strTmp;
    3602     GetExtraDataBoth(pVirtualBox, pMachine, "VBoxInternal2/Audio/Debug/Enabled", &strTmp);
    3603     const uint64_t fDebugEnabled = strTmp.equalsIgnoreCase("true") || strTmp.equalsIgnoreCase("1");
    3604 
    36053601    BOOL fAudioEnabledIn = FALSE;
    36063602    hrc = pAudioAdapter->COMGETTER(EnabledIn)(&fAudioEnabledIn);                            H();
     
    36163612    InsertConfigInteger(pCfg, "OutputEnabled", fAudioEnabledOut);
    36173613
     3614    Utf8Str strTmp;
     3615    GetExtraDataBoth(pVirtualBox, pMachine, "VBoxInternal2/Audio/Debug/Enabled", &strTmp);
     3616    const uint64_t fDebugEnabled = strTmp.equalsIgnoreCase("true") || strTmp.equalsIgnoreCase("1");
    36183617    if (fDebugEnabled)
    36193618    {
     
    36303629     * And global ones for all host drivers: VBoxInternal2/Audio/<Value>
    36313630     */
    3632     static const struct
     3631    for (unsigned iDir = 0; iDir < 2; iDir++)
    36333632    {
    3634         const char *pszExtraName;
    3635         const char *pszCfgmName;
    3636         uint32_t    uDefault;
    3637     } s_aToCopy[]
    3638     {
    3639 #define AUDIO_DRV_TO_COPY_ENTRIES(a_szDir) \
    3640             /* PCM  parameters: */ \
    3641             { "PCMSampleBit"        a_szDir, "PCMSampleBit"        a_szDir, 0          }, \
    3642             { "PCMSampleHz"         a_szDir, "PCMSampleHz"         a_szDir, 0          }, \
    3643             { "PCMSampleSigned"     a_szDir, "PCMSampleSigned"     a_szDir, UINT8_MAX  }, \
    3644             { "PCMSampleSwapEndian" a_szDir, "PCMSampleSwapEndian" a_szDir, UINT8_MAX  }, \
    3645             { "PCMSampleChannels"   a_szDir, "PCMSampleChannels"   a_szDir, 0          }, \
    3646             /* Buffering stuff: */ \
    3647             { "PeriodSizeMs"        a_szDir, "PeriodSizeMs"        a_szDir, 0          }, \
    3648             { "BufferSizeMs"        a_szDir, "BufferSizeMs"        a_szDir, 0          }, \
    3649             { "PreBufferSizeMs"     a_szDir, "PreBufferSizeMs"     a_szDir, UINT32_MAX }
    3650         AUDIO_DRV_TO_COPY_ENTRIES("In"),
    3651         AUDIO_DRV_TO_COPY_ENTRIES("Out")
    3652 #undef AUDIO_DRV_TO_COPY_ENTRIES
    3653     };
    3654     for (size_t i = 0; i < RT_ELEMENTS(s_aToCopy); i++)
    3655     {
    3656         char szExtra[128];
    3657         RTStrPrintf(szExtra, sizeof(szExtra), "VBoxInternal2/Audio/%s/%s", pszDrvName, s_aToCopy[i].pszExtraName);
    3658         GetExtraDataBoth(pVirtualBox, pMachine, szExtra, &strTmp); /* throws hrc */
    3659         if (strTmp.isEmpty())
    3660         {
    3661             RTStrPrintf(szExtra, sizeof(szExtra), "VBoxInternal2/Audio/%s", s_aToCopy[i].pszExtraName);
    3662             GetExtraDataBoth(pVirtualBox, pMachine, szExtra, &strTmp);
     3633        static const struct
     3634        {
     3635            const char *pszExtraName;
     3636            const char *pszCfgmName;
     3637        } s_aToCopy[] =
     3638        {   /* PCM  parameters: */
     3639            { "PCMSampleBit",        "PCMSampleBit"        },
     3640            { "PCMSampleHz",         "PCMSampleHz"         },
     3641            { "PCMSampleSigned",     "PCMSampleSigned"     },
     3642            { "PCMSampleSwapEndian", "PCMSampleSwapEndian" },
     3643            { "PCMSampleChannels",   "PCMSampleChannels"   },
     3644            /* Buffering stuff: */
     3645            { "PeriodSizeMs",        "PeriodSizeMs"        },
     3646            { "BufferSizeMs",        "BufferSizeMs"        },
     3647            { "PreBufferSizeMs",     "PreBufferSizeMs"     },
     3648        };
     3649
     3650        PCFGMNODE   pDirNode = NULL;
     3651        const char *pszDir   = iDir == 0 ? "In" : "Out";
     3652        for (size_t i = 0; i < RT_ELEMENTS(s_aToCopy); i++)
     3653        {
     3654            char szExtra[128];
     3655            RTStrPrintf(szExtra, sizeof(szExtra), "VBoxInternal2/Audio/%s/%s%s", pszDrvName, s_aToCopy[i].pszExtraName, pszDir);
     3656            GetExtraDataBoth(pVirtualBox, pMachine, szExtra, &strTmp); /* throws hrc */
    36633657            if (strTmp.isEmpty())
    3664                 continue;
    3665         }
    3666 
    3667         uint32_t uValue;
    3668         int vrc = RTStrToUInt32Full(strTmp.c_str(), 0, &uValue);
    3669         if (RT_SUCCESS(vrc))
    3670             InsertConfigInteger(pCfg, s_aToCopy[i].pszCfgmName, uValue);
    3671         else
    3672             LogRel(("Ignoring malformed 32-bit unsigned integer config value '%s' = '%s': %Rrc\n", szExtra, strTmp.c_str(), vrc));
     3658            {
     3659                RTStrPrintf(szExtra, sizeof(szExtra), "VBoxInternal2/Audio/%s%s", s_aToCopy[i].pszExtraName, pszDir);
     3660                GetExtraDataBoth(pVirtualBox, pMachine, szExtra, &strTmp);
     3661                if (strTmp.isEmpty())
     3662                    continue;
     3663            }
     3664
     3665            uint32_t uValue;
     3666            int vrc = RTStrToUInt32Full(strTmp.c_str(), 0, &uValue);
     3667            if (RT_SUCCESS(vrc))
     3668            {
     3669                if (!pDirNode)
     3670                    InsertConfigNode(pCfg, pszDir, &pDirNode);
     3671                InsertConfigInteger(pDirNode, s_aToCopy[i].pszCfgmName, uValue);
     3672            }
     3673            else
     3674                LogRel(("Ignoring malformed 32-bit unsigned integer config value '%s' = '%s': %Rrc\n", szExtra, strTmp.c_str(), vrc));
     3675        }
    36733676    }
    36743677
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