VirtualBox

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


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

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

Legend:

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

    r88213 r88216  
    22082208 * @return  IPRT status code.
    22092209 * @param   pThis               Driver instance to be called.
    2210  * @param   pCfgHandle          CFGM configuration handle to use for this driver.
    2211  */
    2212 static int drvAudioHostInit(PDRVAUDIO pThis, PCFGMNODE pCfgHandle)
    2213 {
    2214     /* pCfgHandle is optional. */
    2215     NOREF(pCfgHandle);
     2210 */
     2211static int drvAudioHostInit(PDRVAUDIO pThis)
     2212{
    22162213    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
    22172214
     
    22592256     * If the backend supports it, offer a callback to this connector.
    22602257     */
     2258/** @todo r=bird: Total misdesign.  If the backend wants to talk to us, it
     2259 *                should use PDMIBASE_QUERY_INTERFACE to get an interface from us. */
    22612260    if (pThis->pHostDrvAudio->pfnSetCallback)
    22622261    {
     
    22972296    rc2 = RTCritSectLeave(&pThis->CritSect);
    22982297    AssertRC(rc2);
    2299 }
    2300 
    2301 /**
    2302  * Retrieves an audio configuration from the specified CFGM node.
    2303  *
    2304  * @return VBox status code.
    2305  * @param  pThis                Driver instance to be called.
    2306  * @param  pNode                Where to get the audio configuration from.
    2307  * @param  enmDir               Type of audio configuration to retrieve (input / output).
    2308  * @param  pCfg                 Where to store the retrieved audio configuration to.
    2309  */
    2310 static int drvAudioGetCfgFromCFGM(PDRVAUDIO pThis, PCFGMNODE pNode, PDMAUDIODIR enmDir, PDRVAUDIOCFG pCfg)
    2311 {
    2312     RT_NOREF(pThis, enmDir);
    2313 
    2314     /* Debug stuff. */
    2315     CFGMR3QueryBoolDef(pNode, "DebugEnabled",      &pCfg->Dbg.fEnabled,  false);
    2316     int rc2 = CFGMR3QueryString(pNode, "DebugPathOut", pCfg->Dbg.szPathOut, sizeof(pCfg->Dbg.szPathOut));
    2317     if (   RT_FAILURE(rc2)
    2318         || !strlen(pCfg->Dbg.szPathOut))
    2319     {
    2320         rc2 = RTPathTemp(pCfg->Dbg.szPathOut, sizeof(pCfg->Dbg.szPathOut));
    2321         if (RT_FAILURE(rc2))
    2322             LogRel(("Audio: Error retrieving temporary directory, rc=%Rrc\n", rc2));
    2323     }
    2324 
    2325     if (pCfg->Dbg.fEnabled)
    2326         LogRel(("Audio: Debugging for driver '%s' enabled (audio data written to '%s')\n", pThis->szName, pCfg->Dbg.szPathOut));
    2327 
    2328     /* Queries an audio input / output stream's configuration from the CFGM tree. */
    2329 #define QUERY_CONFIG(a_InOut) \
    2330     /* PCM stuff. */ \
    2331     CFGMR3QueryU8Def (pNode, "PCMSampleBit"         #a_InOut, &pCfg->Props.cbSample,  0); \
    2332     CFGMR3QueryU32Def(pNode, "PCMSampleHz"          #a_InOut, &pCfg->Props.uHz,       0); \
    2333     CFGMR3QueryU8Def (pNode, "PCMSampleSigned"      #a_InOut, &pCfg->uSigned,         UINT8_MAX /* No custom value set */); \
    2334     CFGMR3QueryU8Def (pNode, "PCMSampleSwapEndian"  #a_InOut, &pCfg->uSwapEndian,     UINT8_MAX /* No custom value set */); \
    2335     CFGMR3QueryU8Def (pNode, "PCMSampleChannels"    #a_InOut, &pCfg->Props.cChannels, 0); \
    2336     \
    2337     /* Buffering stuff. */ \
    2338     CFGMR3QueryU32Def(pNode, "PeriodSizeMs"         #a_InOut, &pCfg->uPeriodSizeMs, 0); \
    2339     CFGMR3QueryU32Def(pNode, "BufferSizeMs"         #a_InOut, &pCfg->uBufferSizeMs, 0); \
    2340     CFGMR3QueryU32Def(pNode, "PreBufferSizeMs"      #a_InOut, &pCfg->uPreBufSizeMs, UINT32_MAX /* No custom value set */);
    2341 
    2342     if (enmDir == PDMAUDIODIR_IN)
    2343     {
    2344         QUERY_CONFIG(In);
    2345     }
    2346     else
    2347     {
    2348         QUERY_CONFIG(Out);
    2349     }
    2350 
    2351 #undef QUERY_CONFIG
    2352 
    2353     pCfg->Props.cbSample /= 8; /* Convert bit to bytes. */
    2354 
    2355     return VINF_SUCCESS;
    2356 }
    2357 
    2358 /**
    2359  * Intializes an audio driver instance.
    2360  *
    2361  * @returns IPRT status code.
    2362  * @param   pDrvIns             Pointer to driver instance.
    2363  * @param   pCfgHandle          CFGM handle to use for configuration.
    2364  */
    2365 static int drvAudioInit(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle)
    2366 {
    2367     AssertPtrReturn(pCfgHandle, VERR_INVALID_POINTER);
    2368     AssertPtrReturn(pDrvIns,    VERR_INVALID_POINTER);
    2369 
    2370     PDRVAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIO);
    2371 
    2372     int rc = RTCritSectInit(&pThis->CritSect);
    2373     AssertRCReturn(rc, rc);
    2374 
    2375     const size_t cbScratchBuf = _4K; /** @todo Make this configurable? */
    2376     pThis->pvScratchBuf = RTMemAlloc(cbScratchBuf);
    2377     AssertPtrReturn(pThis->pvScratchBuf, VERR_NO_MEMORY);
    2378     pThis->cbScratchBuf = cbScratchBuf;
    2379 
    2380     /*
    2381      * Configure driver from CFGM.
    2382      */
    2383 #ifdef DEBUG
    2384     CFGMR3Dump(pCfgHandle);
    2385 #endif
    2386 
    2387     pThis->fTerminate = false;
    2388     pThis->pCFGMNode  = pCfgHandle;
    2389 
    2390     int rc2 = CFGMR3QueryString(pThis->pCFGMNode, "DriverName", pThis->szName, sizeof(pThis->szName));
    2391     if (RT_FAILURE(rc2))
    2392         RTStrPrintf(pThis->szName, sizeof(pThis->szName), "Untitled");
    2393 
    2394     /* By default we don't enable anything if wrongly / not set-up. */
    2395     CFGMR3QueryBoolDef(pThis->pCFGMNode, "InputEnabled",  &pThis->In.fEnabled,   false);
    2396     CFGMR3QueryBoolDef(pThis->pCFGMNode, "OutputEnabled", &pThis->Out.fEnabled,  false);
    2397 
    2398     LogRel2(("Audio: Verbose logging for driver '%s' enabled\n", pThis->szName));
    2399 
    2400     LogRel2(("Audio: Initial status for driver '%s' is: input is %s, output is %s\n",
    2401              pThis->szName, pThis->In.fEnabled ? "enabled" : "disabled", pThis->Out.fEnabled ? "enabled" : "disabled"));
    2402 
    2403     /*
    2404      * Load configurations.
    2405      */
    2406     rc = drvAudioGetCfgFromCFGM(pThis, pThis->pCFGMNode, PDMAUDIODIR_IN, &pThis->In.Cfg);
    2407     if (RT_SUCCESS(rc))
    2408         rc = drvAudioGetCfgFromCFGM(pThis, pThis->pCFGMNode, PDMAUDIODIR_OUT, &pThis->Out.Cfg);
    2409 
    2410     LogFunc(("[%s] rc=%Rrc\n", pThis->szName, rc));
    2411     return rc;
    24122298}
    24132299
     
    35573443 * This is a worker for both drvAudioAttach and drvAudioConstruct.
    35583444 *
    3559  * @return VBox status code.
    3560  * @param  pThis                Pointer to driver instance.
    3561  * @param  fFlags               Attach flags; see PDMDrvHlpAttach().
     3445 * @returns VBox status code.
     3446 * @param   pThis       Pointer to driver instance.
     3447 * @param   fFlags      Attach flags; see PDMDrvHlpAttach().
    35623448 */
    35633449static int drvAudioDoAttachInternal(PDRVAUDIO pThis, uint32_t fFlags)
     
    35733459    {
    35743460        pThis->pHostDrvAudio = PDMIBASE_QUERY_INTERFACE(pDownBase, PDMIHOSTAUDIO);
    3575         if (!pThis->pHostDrvAudio)
     3461        if (pThis->pHostDrvAudio)
     3462        {
     3463            /*
     3464             * If everything went well, initialize the lower driver.
     3465             */
     3466            rc = drvAudioHostInit(pThis);
     3467        }
     3468        else
    35763469        {
    35773470            LogRel(("Audio: Failed to query interface for underlying host driver '%s'\n", pThis->szName));
     
    35813474    }
    35823475
    3583     if (RT_SUCCESS(rc))
    3584     {
    3585         /*
    3586          * If everything went well, initialize the lower driver.
    3587          */
    3588         AssertPtr(pThis->pCFGMNode);
    3589         rc = drvAudioHostInit(pThis, pThis->pCFGMNode);
    3590     }
    3591 
    35923476    LogFunc(("[%s] rc=%Rrc\n", pThis->szName, rc));
    35933477    return rc;
     
    36033487static DECLCALLBACK(int) drvAudioAttach(PPDMDRVINS pDrvIns, uint32_t fFlags)
    36043488{
    3605     RT_NOREF(fFlags);
    3606 
    36073489    PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
    36083490    PDRVAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIO);
    3609 
    3610     int rc2 = RTCritSectEnter(&pThis->CritSect);
    3611     AssertRC(rc2);
    3612 
    36133491    LogFunc(("%s\n", pThis->szName));
    36143492
    3615     int rc = drvAudioDoAttachInternal(pThis, fFlags);
    3616 
    3617     rc2 = RTCritSectLeave(&pThis->CritSect);
    3618     if (RT_SUCCESS(rc))
    3619         rc = rc2;
    3620 
     3493    int rc = RTCritSectEnter(&pThis->CritSect);
     3494    AssertRCReturn(rc, rc);
     3495
     3496    rc = drvAudioDoAttachInternal(pThis, fFlags);
     3497
     3498    RTCritSectLeave(&pThis->CritSect);
    36213499    return rc;
    36223500}
     
    37223600
    37233601#ifdef VBOX_WITH_STATISTICS
    3724     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalStreamsActive);
    3725     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalStreamsCreated);
    3726     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalFramesRead);
    3727     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalFramesWritten);
    3728     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalFramesMixedIn);
    3729     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalFramesMixedOut);
    3730     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalFramesLostIn);
    3731     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalFramesLostOut);
    3732     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalFramesOut);
    3733     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalFramesIn);
    3734     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalBytesRead);
    3735     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.TotalBytesWritten);
    3736     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.DelayIn);
    3737     PDMDrvHlpSTAMDeregister(pThis->pDrvIns, &pThis->Stats.DelayOut);
     3602    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalStreamsActive);
     3603    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalStreamsCreated);
     3604    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalFramesRead);
     3605    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalFramesWritten);
     3606    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalFramesMixedIn);
     3607    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalFramesMixedOut);
     3608    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalFramesLostIn);
     3609    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalFramesLostOut);
     3610    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalFramesOut);
     3611    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalFramesIn);
     3612    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalBytesRead);
     3613    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.TotalBytesWritten);
     3614    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.DelayIn);
     3615    PDMDrvHlpSTAMDeregister(pDrvIns, &pThis->Stats.DelayOut);
    37383616#endif
    37393617
     
    37623640#endif
    37633641
     3642    /*
     3643     * Read configuration.
     3644     */
     3645    PDMDRV_VALIDATE_CONFIG_RETURN(pDrvIns,
     3646                                  "DriverName|"
     3647                                  "InputEnabled|"
     3648                                  "OutputEnabled|"
     3649                                  "DebugEnabled|"
     3650                                  "DebugPathOut|"
     3651                                  /* Deprecated: */
     3652                                  "PCMSampleBitIn|"
     3653                                  "PCMSampleBitOut|"
     3654                                  "PCMSampleHzIn|"
     3655                                  "PCMSampleHzOut|"
     3656                                  "PCMSampleSignedIn|"
     3657                                  "PCMSampleSignedOut|"
     3658                                  "PCMSampleSwapEndianIn|"
     3659                                  "PCMSampleSwapEndianOut|"
     3660                                  "PCMSampleChannelsIn|"
     3661                                  "PCMSampleChannelsOut|"
     3662                                  "PeriodSizeMsIn|"
     3663                                  "PeriodSizeMsOut|"
     3664                                  "BufferSizeMsIn|"
     3665                                  "BufferSizeMsOut|"
     3666                                  "PreBufferSizeMsIn|"
     3667                                  "PreBufferSizeMsOut",
     3668                                  "In|Out");
     3669
     3670    int rc = CFGMR3QueryStringDef(pCfg, "DriverName", pThis->szName, sizeof(pThis->szName), "Untitled");
     3671    AssertLogRelRCReturn(rc, rc);
     3672
     3673    /* Neither input nor output by default for security reasons. */
     3674    rc = CFGMR3QueryBoolDef(pCfg, "InputEnabled",  &pThis->In.fEnabled, false);
     3675    AssertLogRelRCReturn(rc, rc);
     3676
     3677    rc = CFGMR3QueryBoolDef(pCfg, "OutputEnabled", &pThis->Out.fEnabled, false);
     3678    AssertLogRelRCReturn(rc, rc);
     3679
     3680    /* Debug stuff (same for both directions). */
     3681    rc = CFGMR3QueryBoolDef(pCfg, "DebugEnabled", &pThis->In.Cfg.Dbg.fEnabled, false);
     3682    AssertLogRelRCReturn(rc, rc);
     3683
     3684    rc = CFGMR3QueryStringDef(pCfg, "DebugPathOut", pThis->In.Cfg.Dbg.szPathOut, sizeof(pThis->In.Cfg.Dbg.szPathOut), "");
     3685    AssertLogRelRCReturn(rc, rc);
     3686    if (pThis->In.Cfg.Dbg.szPathOut[0] == '\0')
     3687    {
     3688        rc = RTPathTemp(pThis->In.Cfg.Dbg.szPathOut, sizeof(pThis->In.Cfg.Dbg.szPathOut));
     3689        if (RT_FAILURE(rc))
     3690        {
     3691            LogRel(("Audio: Warning! Failed to retrieve temporary directory: %Rrc - disabling debugging.\n", rc));
     3692            pThis->In.Cfg.Dbg.szPathOut[0] = '\0';
     3693            pThis->In.Cfg.Dbg.fEnabled = false;
     3694        }
     3695    }
     3696    if (pThis->In.Cfg.Dbg.fEnabled)
     3697        LogRel(("Audio: Debugging for driver '%s' enabled (audio data written to '%s')\n", pThis->szName, pThis->In.Cfg.Dbg.szPathOut));
     3698
     3699    /* Copy debug setup to the output direction. */
     3700    pThis->Out.Cfg.Dbg = pThis->In.Cfg.Dbg;
     3701
     3702    LogRel2(("Audio: Verbose logging for driver '%s' is probably enabled too.\n", pThis->szName));
     3703    /* This ^^^^^^^ is the *WRONG* place for that kind of statement. Verbose logging might only be enabled for DrvAudio. */
     3704    LogRel2(("Audio: Initial status for driver '%s' is: input is %s, output is %s\n",
     3705             pThis->szName, pThis->In.fEnabled ? "enabled" : "disabled", pThis->Out.fEnabled ? "enabled" : "disabled"));
     3706
     3707    /*
     3708     * Per direction configuration.  A bit complicated as
     3709     * these wasn't originally in sub-nodes.
     3710     */
     3711    for (unsigned iDir = 0; iDir < 2; iDir++)
     3712    {
     3713        char         szNm[48];
     3714        PDRVAUDIOCFG pAudioCfg = iDir == 0 ? &pThis->In.Cfg : &pThis->Out.Cfg;
     3715        const char  *pszDir    = iDir == 0 ? "In"           : "Out";
     3716
     3717#define QUERY_VAL_RET(a_Width, a_szName, a_pValue, a_uDefault, a_ExprValid, a_szValidRange) \
     3718            do { \
     3719                rc = RT_CONCAT(CFGMR3QueryU,a_Width)(pDirNode, strcpy(szNm, a_szName), a_pValue); \
     3720                if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT) \
     3721                { \
     3722                    rc = RT_CONCAT(CFGMR3QueryU,a_Width)(pCfg, strcat(szNm, pszDir), a_pValue); \
     3723                    if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_NO_PARENT) \
     3724                    { \
     3725                        *(a_pValue) = a_uDefault; \
     3726                        rc = VINF_SUCCESS; \
     3727                    } \
     3728                    else \
     3729                        LogRel(("DrvAudio: Warning! Please use '%s/" a_szName "' instead of '%s' for your VBoxInternal hacks\n", pszDir, szNm)); \
     3730                } \
     3731                AssertRCReturn(rc, PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, \
     3732                                                       N_("Configuration error: Failed to read %s config value '%s'"), pszDir, szNm)); \
     3733                if (!(a_ExprValid)) \
     3734                    return PDMDrvHlpVMSetError(pDrvIns, VERR_OUT_OF_RANGE, RT_SRC_POS, \
     3735                                               N_("Configuration error: Unsupported %s value %u. " a_szValidRange), szNm, *(a_pValue)); \
     3736            } while (0)
     3737
     3738        PCFGMNODE const pDirNode = CFGMR3GetChild(pCfg, pszDir);
     3739        rc = CFGMR3ValidateConfig(pDirNode, iDir == 0 ? "In/" : "Out/",
     3740                                  "PCMSampleBit|"
     3741                                  "PCMSampleHz|"
     3742                                  "PCMSampleSigned|"
     3743                                  "PCMSampleSwapEndian|"
     3744                                  "PCMSampleChannels|"
     3745                                  "PeriodSizeMs|"
     3746                                  "BufferSizeMs|"
     3747                                  "PreBufferSizeMs",
     3748                                  "", pDrvIns->pReg->szName, pDrvIns->iInstance);
     3749        AssertRCReturn(rc, rc);
     3750
     3751        QUERY_VAL_RET(8,  "PCMSampleBit",        &pAudioCfg->Props.cbSample,    0,
     3752                         pAudioCfg->Props.cbSample == 0
     3753                      || pAudioCfg->Props.cbSample == 8
     3754                      || pAudioCfg->Props.cbSample == 16
     3755                      || pAudioCfg->Props.cbSample == 32
     3756                      || pAudioCfg->Props.cbSample == 64,
     3757                      "Must be either 0, 8, 16, 32 or 64");
     3758        pAudioCfg->Props.cbSample /= 8;
     3759
     3760        QUERY_VAL_RET(8,  "PCMSampleChannels",   &pAudioCfg->Props.cChannels,   0,
     3761                      pAudioCfg->Props.cChannels <= 16, "Max 16");
     3762
     3763        QUERY_VAL_RET(32, "PCMSampleHz",         &pAudioCfg->Props.uHz,         0,
     3764                      pAudioCfg->Props.uHz == 0 || (pAudioCfg->Props.uHz >= 6000 && pAudioCfg->Props.uHz <= 768000),
     3765                      "In the range 6000 thru 768000, or 0");
     3766
     3767        QUERY_VAL_RET(8,  "PCMSampleSigned",     &pAudioCfg->uSigned,           UINT8_MAX,
     3768                      pAudioCfg->uSigned == 0 || pAudioCfg->uSigned == 1 || pAudioCfg->uSigned == UINT8_MAX,
     3769                      "Must be either 0, 1, or 255");
     3770
     3771        QUERY_VAL_RET(8,  "PCMSampleSwapEndian", &pAudioCfg->uSwapEndian,       UINT8_MAX,
     3772                      pAudioCfg->uSwapEndian == 0 || pAudioCfg->uSwapEndian == 1 || pAudioCfg->uSwapEndian == UINT8_MAX,
     3773                      "Must be either 0, 1, or 255");
     3774
     3775        QUERY_VAL_RET(32, "PeriodSizeMs",        &pAudioCfg->uPeriodSizeMs,     0,
     3776                      pAudioCfg->uPeriodSizeMs <= RT_MS_1SEC, "Max 1000");
     3777
     3778        QUERY_VAL_RET(32, "BufferSizeMs",        &pAudioCfg->uBufferSizeMs,     0,
     3779                      pAudioCfg->uBufferSizeMs <= RT_MS_5SEC, "Max 5000");
     3780
     3781        QUERY_VAL_RET(32, "PreBufferSizeMs",     &pAudioCfg->uPreBufSizeMs,     UINT32_MAX,
     3782                      pAudioCfg->uPreBufSizeMs <= RT_MS_1SEC || pAudioCfg->uPreBufSizeMs == UINT32_MAX,
     3783                      "Max 1000, or 0xffffffff");
     3784#undef QUERY_VAL_RET
     3785    }
     3786
     3787    /*
     3788     * Init the rest of the driver instance data.
     3789     */
     3790    rc = RTCritSectInit(&pThis->CritSect);
     3791    AssertRCReturn(rc, rc);
     3792
     3793    const size_t cbScratchBuf = _4K; /** @todo Make this configurable? */
     3794    pThis->pvScratchBuf = RTMemAlloc(cbScratchBuf);
     3795    AssertPtrReturn(pThis->pvScratchBuf, VERR_NO_MEMORY);
     3796    pThis->cbScratchBuf = cbScratchBuf;
     3797
     3798    pThis->fTerminate                           = false;
    37643799    pThis->pDrvIns                              = pDrvIns;
    37653800    /* IBase. */
     
    37883823#endif
    37893824
    3790     int rc = drvAudioInit(pDrvIns, pCfg);
    3791     if (RT_SUCCESS(rc))
    3792     {
     3825    /*
     3826     * Statistics.
     3827     */
    37933828#ifdef VBOX_WITH_STATISTICS
    3794         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalStreamsActive,   "TotalStreamsActive",
    3795                                   STAMUNIT_COUNT, "Total active audio streams.");
    3796         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalStreamsCreated,  "TotalStreamsCreated",
    3797                                   STAMUNIT_COUNT, "Total created audio streams.");
    3798         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesRead,      "TotalFramesRead",
    3799                                   STAMUNIT_COUNT, "Total frames read by device emulation.");
    3800         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesWritten,   "TotalFramesWritten",
    3801                                   STAMUNIT_COUNT, "Total frames written by device emulation ");
    3802         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesMixedIn,   "TotalFramesMixedIn",
    3803                                   STAMUNIT_COUNT, "Total input frames mixed.");
    3804         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesMixedOut,  "TotalFramesMixedOut",
    3805                                   STAMUNIT_COUNT, "Total output frames mixed.");
    3806         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesLostIn,    "TotalFramesLostIn",
    3807                                   STAMUNIT_COUNT, "Total input frames lost.");
    3808         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesLostOut,   "TotalFramesLostOut",
    3809                                   STAMUNIT_COUNT, "Total output frames lost.");
    3810         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesOut,       "TotalFramesOut",
    3811                                   STAMUNIT_COUNT, "Total frames played by backend.");
    3812         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesIn,        "TotalFramesIn",
    3813                                   STAMUNIT_COUNT, "Total frames captured by backend.");
    3814         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalBytesRead,       "TotalBytesRead",
    3815                                   STAMUNIT_BYTES, "Total bytes read.");
    3816         PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalBytesWritten,    "TotalBytesWritten",
    3817                                   STAMUNIT_BYTES, "Total bytes written.");
    3818 
    3819         PDMDrvHlpSTAMRegProfileAdvEx(pDrvIns, &pThis->Stats.DelayIn,           "DelayIn",
    3820                                      STAMUNIT_NS_PER_CALL, "Profiling of input data processing.");
    3821         PDMDrvHlpSTAMRegProfileAdvEx(pDrvIns, &pThis->Stats.DelayOut,          "DelayOut",
    3822                                      STAMUNIT_NS_PER_CALL, "Profiling of output data processing.");
     3829    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalStreamsActive,   "TotalStreamsActive",
     3830                              STAMUNIT_COUNT, "Total active audio streams.");
     3831    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalStreamsCreated,  "TotalStreamsCreated",
     3832                              STAMUNIT_COUNT, "Total created audio streams.");
     3833    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesRead,      "TotalFramesRead",
     3834                              STAMUNIT_COUNT, "Total frames read by device emulation.");
     3835    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesWritten,   "TotalFramesWritten",
     3836                              STAMUNIT_COUNT, "Total frames written by device emulation ");
     3837    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesMixedIn,   "TotalFramesMixedIn",
     3838                              STAMUNIT_COUNT, "Total input frames mixed.");
     3839    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesMixedOut,  "TotalFramesMixedOut",
     3840                              STAMUNIT_COUNT, "Total output frames mixed.");
     3841    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesLostIn,    "TotalFramesLostIn",
     3842                              STAMUNIT_COUNT, "Total input frames lost.");
     3843    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesLostOut,   "TotalFramesLostOut",
     3844                              STAMUNIT_COUNT, "Total output frames lost.");
     3845    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesOut,       "TotalFramesOut",
     3846                              STAMUNIT_COUNT, "Total frames played by backend.");
     3847    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalFramesIn,        "TotalFramesIn",
     3848                              STAMUNIT_COUNT, "Total frames captured by backend.");
     3849    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalBytesRead,       "TotalBytesRead",
     3850                              STAMUNIT_BYTES, "Total bytes read.");
     3851    PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalBytesWritten,    "TotalBytesWritten",
     3852                              STAMUNIT_BYTES, "Total bytes written.");
     3853
     3854    PDMDrvHlpSTAMRegProfileAdvEx(pDrvIns, &pThis->Stats.DelayIn,           "DelayIn",
     3855                                 STAMUNIT_NS_PER_CALL, "Profiling of input data processing.");
     3856    PDMDrvHlpSTAMRegProfileAdvEx(pDrvIns, &pThis->Stats.DelayOut,          "DelayOut",
     3857                                 STAMUNIT_NS_PER_CALL, "Profiling of output data processing.");
    38233858#endif
    3824     }
    3825 
    3826     /** @todo r=bird: you're overwriting rc here. sigh.  Just return immediately on
    3827      *        failure, don't try make it to the end of the function! GRRR! */
     3859
     3860    /*
     3861     * Attach the host driver, if present.
     3862     */
    38283863    rc = drvAudioDoAttachInternal(pThis, fFlags);
    3829     if (RT_FAILURE(rc))
    3830     {
    3831         /* No lower attached driver (yet)? Not a failure, might get attached later at runtime, just skip. */
    3832         if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    3833             rc = VINF_SUCCESS;
    3834     }
     3864    if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
     3865        rc = VINF_SUCCESS;
    38353866
    38363867    LogFlowFuncLeaveRC(rc);
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r88047 r88216  
    133133    /** Pointer to audio driver below us. */
    134134    PPDMIHOSTAUDIO          pHostDrvAudio;
    135     /** Pointer to CFGM configuration node of this driver. */
    136     PCFGMNODE               pCFGMNode;
    137135    /** List of audio streams. */
    138136    RTLISTANCHOR            lstStreams;
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