VirtualBox

Ignore:
Timestamp:
Nov 26, 2019 4:14:05 PM (5 years ago)
Author:
vboxsync
Message:

DevSB16: Use PDMDevHlpDriverReconfigure2. (Dropping the unknown 'AudioDriver' config value for NullAudio.) bugref:9218

File:
1 edited

Legend:

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

    r82223 r82225  
    22642264 * @returns VBox status code.
    22652265 * @param   pThis       Device instance.
    2266  * @param   pDrv        Driver instance used for attaching to.
    2267  *                      If NULL is specified, a new driver will be created and appended
    2268  *                      to the driver list.
    22692266 * @param   uLUN        The logical unit which is being re-detached.
    22702267 * @param   pszDriver   New driver name to attach.
    22712268 */
    2272 static int sb16Reattach(PSB16STATE pThis, PSB16DRIVER pDrv, uint8_t uLUN, const char *pszDriver)
    2273 {
    2274     AssertPtrReturn(pThis,     VERR_INVALID_POINTER);
    2275     AssertPtrReturn(pszDriver, VERR_INVALID_POINTER);
    2276 
    2277     int rc;
    2278 
    2279     if (pDrv)
    2280     {
    2281         rc = sb16DetachInternal(pThis, pDrv, 0 /* fFlags */);
    2282         if (RT_SUCCESS(rc))
    2283             rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */);
    2284 
    2285         if (RT_FAILURE(rc))
    2286             return rc;
    2287 
    2288         pDrv = NULL;
    2289     }
    2290 
    2291     PCPDMDEVHLPR3 pHlp  = pThis->pDevInsR3->pHlpR3;
    2292     PVM           pVM   = PDMDevHlpGetVM(pThis->pDevInsR3);
    2293     PCFGMNODE     pRoot = CFGMR3GetRoot(pVM);
    2294     PCFGMNODE     pDev0 = pHlp->pfnCFGMGetChild(pRoot, "Devices/sb16/0/");
    2295 
    2296     /* Remove LUN branch. */
    2297     CFGMR3RemoveNode(pHlp->pfnCFGMGetChildF(pDev0, "LUN#%u/", uLUN));
    2298 
    2299     if (pDrv)
    2300     {
    2301         /* Re-use the driver instance so detach it before. */
    2302         rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */);
    2303         if (RT_FAILURE(rc))
    2304             return rc;
    2305     }
    2306 
    2307 #define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; }
    2308 
    2309     do
    2310     {
    2311         PCFGMNODE pLunL0;
    2312         rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", uLUN);        RC_CHECK();
    2313         rc = CFGMR3InsertString(pLunL0, "Driver",       "AUDIO");       RC_CHECK();
    2314         rc = CFGMR3InsertNode(pLunL0,   "Config/",       NULL);         RC_CHECK();
    2315 
    2316         PCFGMNODE pLunL1, pLunL2;
    2317         rc = CFGMR3InsertNode  (pLunL0, "AttachedDriver/", &pLunL1);    RC_CHECK();
    2318         rc = CFGMR3InsertNode  (pLunL1,  "Config/",        &pLunL2);    RC_CHECK();
    2319         rc = CFGMR3InsertString(pLunL1,  "Driver",          pszDriver); RC_CHECK();
    2320 
    2321         rc = CFGMR3InsertString(pLunL2, "AudioDriver", pszDriver);      RC_CHECK();
    2322 
    2323     } while (0);
    2324 
     2269static int sb16Reattach(PSB16STATE pThis, uint8_t uLUN, const char *pszDriver)
     2270{
     2271    AssertPtr(pThis);
     2272
     2273    int rc = PDMDevHlpDriverReconfigure2(pThis->pDevInsR3, uLUN, "AUDIO", pszDriver);
    23252274    if (RT_SUCCESS(rc))
    23262275        rc = sb16AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */);
    23272276
    23282277    LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, uLUN, pszDriver, rc));
    2329 
    2330 #undef RC_CHECK
    23312278
    23322279    return rc;
     
    25172464            else if (rc == VERR_AUDIO_BACKEND_INIT_FAILED)
    25182465            {
    2519                 sb16Reattach(pThis, NULL /* pDrv */, uLUN, "NullAudio");
     2466                sb16Reattach(pThis, uLUN, "NullAudio");
    25202467                PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
    2521                         N_("Host audio backend initialization has failed. Selecting the NULL audio backend "
    2522                            "with the consequence that no sound is audible"));
     2468                                           N_("Host audio backend initialization has failed. Selecting the NULL audio backend with the consequence that no sound is audible"));
    25232469                /* Attaching to the NULL audio backend will never fail. */
    25242470                rc = VINF_SUCCESS;
     
    25332479
    25342480#ifdef VBOX_WITH_AUDIO_SB16_ONETIME_INIT
    2535     PSB16DRIVER pDrv;
    2536     RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node)
     2481    PSB16DRIVER pDrv, pNext;
     2482    RTListForEachSafe(&pThis->lstDrv, pDrv, pNext, SB16DRIVER, Node)
    25372483    {
    25382484        /*
     
    25572503
    25582504            sb16CmdResetLegacy(pThis);
    2559             sb16Reattach(pThis, pDrv, pDrv->uLUN, "NullAudio");
     2505            sb16Reattach(pThis, pDrv->uLUN, "NullAudio");
     2506            pDrv = NULL; /* no longer valid */
    25602507
    25612508            PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
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