VirtualBox

Changeset 70639 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jan 19, 2018 12:03:12 PM (7 years ago)
Author:
vboxsync
Message:

Audio/DrvAudio: Implemented more dynamic support for attaching the host backends to its audio connector at runtime.

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

Legend:

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

    r70635 r70639  
    22132213#endif
    22142214
    2215     int rc2 = CFGMR3QueryString(pCfgHandle, "DriverName", pThis->szName, sizeof(pThis->szName));
     2215    pThis->fTerminate = false;
     2216    pThis->pCFGMNode  = pCfgHandle;
     2217
     2218    int rc2 = CFGMR3QueryString(pThis->pCFGMNode, "DriverName", pThis->szName, sizeof(pThis->szName));
    22162219    if (RT_FAILURE(rc2))
    22172220        RTStrPrintf(pThis->szName, sizeof(pThis->szName), "Untitled");
    22182221
    22192222    /* By default we don't enable anything if wrongly / not set-up. */
    2220     CFGMR3QueryBoolDef(pCfgHandle, "InputEnabled",  &pThis->In.fEnabled,   false);
    2221     CFGMR3QueryBoolDef(pCfgHandle, "OutputEnabled", &pThis->Out.fEnabled,  false);
    2222 
    2223     CFGMR3QueryBoolDef(pCfgHandle, "DebugEnabled",      &pThis->Dbg.fEnabled,  false);
    2224     rc2 = CFGMR3QueryString(pCfgHandle, "DebugPathOut", pThis->Dbg.szPathOut, sizeof(pThis->Dbg.szPathOut));
     2223    CFGMR3QueryBoolDef(pThis->pCFGMNode, "InputEnabled",  &pThis->In.fEnabled,   false);
     2224    CFGMR3QueryBoolDef(pThis->pCFGMNode, "OutputEnabled", &pThis->Out.fEnabled,  false);
     2225
     2226    CFGMR3QueryBoolDef(pThis->pCFGMNode, "DebugEnabled",      &pThis->Dbg.fEnabled,  false);
     2227    rc2 = CFGMR3QueryString(pThis->pCFGMNode, "DebugPathOut", pThis->Dbg.szPathOut, sizeof(pThis->Dbg.szPathOut));
    22252228    if (   RT_FAILURE(rc2)
    22262229        || !strlen(pThis->Dbg.szPathOut))
     
    22352238             pThis->szName, pThis->In.fEnabled ? "enabled" : "disabled", pThis->Out.fEnabled ? "enabled" : "disabled"));
    22362239
    2237     /*
    2238      * If everything went well, initialize the lower driver.
    2239      */
    2240     rc = drvAudioHostInit(pThis, pCfgHandle);
    2241 
    2242     LogFlowFuncLeaveRC(rc);
     2240    LogFunc(("[%s] rc=%Rrc\n", pThis->szName, rc));
    22432241    return rc;
    22442242}
     
    31993197}
    32003198
     3199/**
     3200 * Does the actual backend driver attaching and queries the backend's interface.
     3201 *
     3202 * @return VBox status code.
     3203 * @param  pThis                Pointer to driver instance.
     3204 * @param  fFlags               Attach flags; see PDMDrvHlpAttach().
     3205 */
     3206static int drvAudioDoAttachInternal(PDRVAUDIO pThis, uint32_t fFlags)
     3207{
     3208    Assert(pThis->pHostDrvAudio == NULL); /* No nested attaching. */
     3209
     3210    /*
     3211     * Attach driver below and query its connector interface.
     3212     */
     3213    PPDMIBASE pDownBase;
     3214    int rc = PDMDrvHlpAttach(pThis->pDrvIns, fFlags, &pDownBase);
     3215    if (RT_SUCCESS(rc))
     3216    {
     3217        pThis->pHostDrvAudio = PDMIBASE_QUERY_INTERFACE(pDownBase, PDMIHOSTAUDIO);
     3218        if (!pThis->pHostDrvAudio)
     3219        {
     3220            LogRel(("Audio: Failed to query interface for underlying host driver\n"));
     3221            rc = PDMDRV_SET_ERROR(pThis->pDrvIns, VERR_PDM_MISSING_INTERFACE_BELOW,
     3222                                  N_("Host audio backend missing or invalid"));
     3223        }
     3224    }
     3225
     3226    if (RT_SUCCESS(rc))
     3227    {
     3228        /*
     3229         * If everything went well, initialize the lower driver.
     3230         */
     3231        AssertPtr(pThis->pCFGMNode);
     3232        rc = drvAudioHostInit(pThis, pThis->pCFGMNode);
     3233    }
     3234
     3235    LogFunc(("[%s] rc=%Rrc\n", pThis->szName, rc));
     3236    return rc;
     3237}
     3238
     3239
    32013240/********************************************************************/
    32023241
     
    32273266
    32283267    LogFlowFuncEnter();
     3268
     3269    if (!pThis->pHostDrvAudio) /* If not lower driver is configured, bail out. */
     3270        return;
    32293271
    32303272    /* Just destroy the host stream on the backend side.
     
    32953337#endif
    32963338
    3297     /*
    3298      * Attach driver below and query its connector interface.
    3299      */
    3300     PPDMIBASE pDownBase;
    3301     int rc = PDMDrvHlpAttach(pDrvIns, fFlags, &pDownBase);
    3302     if (RT_FAILURE(rc))
    3303     {
    3304         LogRel(("Audio: Failed to attach to driver %p below (flags=0x%x), rc=%Rrc\n",
    3305                 pDrvIns, fFlags, rc));
    3306         return rc;
    3307     }
    3308 
    3309     pThis->pHostDrvAudio = PDMIBASE_QUERY_INTERFACE(pDownBase, PDMIHOSTAUDIO);
    3310     if (!pThis->pHostDrvAudio)
    3311     {
    3312         LogRel(("Audio: Failed to query interface for underlying host driver\n"));
    3313         return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_BELOW,
    3314                                 N_("Host audio backend missing or invalid"));
    3315     }
    3316 
    3317     rc = drvAudioInit(pDrvIns, pCfg);
     3339    int rc = drvAudioInit(pDrvIns, pCfg);
    33183340    if (RT_SUCCESS(rc))
    33193341    {
    3320         pThis->fTerminate = false;
    3321         pThis->pDrvIns    = pDrvIns;
    3322 
    33233342#ifdef VBOX_WITH_STATISTICS
    33243343        PDMDrvHlpSTAMRegCounterEx(pDrvIns, &pThis->Stats.TotalStreamsActive,   "TotalStreamsActive",
     
    33543373    }
    33553374
     3375    rc = drvAudioDoAttachInternal(pThis, fFlags);
     3376    if (RT_FAILURE(rc))
     3377    {
     3378        /* No lower attached driver (yet)? Not a failure, might get attached later at runtime, just skip. */
     3379        if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
     3380            rc = VINF_SUCCESS;
     3381    }
     3382
    33563383    LogFlowFuncLeaveRC(rc);
    33573384    return rc;
     
    34973524    AssertRC(rc2);
    34983525
    3499     int rc = VINF_SUCCESS;
    3500 
    35013526    LogFunc(("%s\n", pThis->szName));
     3527
     3528    int rc = drvAudioDoAttachInternal(pThis, fFlags);
    35023529
    35033530    rc2 = RTCritSectLeave(&pThis->CritSect);
  • trunk/src/VBox/Devices/Audio/DrvAudio.h

    r70013 r70639  
    9393    /** Pointer to audio driver below us. */
    9494    PPDMIHOSTAUDIO          pHostDrvAudio;
     95    /** Pointer to CFGM configuration node of this driver. */
     96    PCFGMNODE               pCFGMNode;
    9597    /** List of host input/output audio streams. */
    9698    RTLISTANCHOR            lstHstStreams;
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