VirtualBox

Changeset 82224 in vbox for trunk/src


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

PDMDevHlp: Adding PDMDevHlpDriverReconfigure[|1|2] for the audio devices to use when falling back on the 'NullAudio' driver. bugref:9218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp

    r82067 r82224  
    25032503
    25042504    LogFlow(("pdmR3DevHlp_DriverDetach: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
     2505    return rc;
     2506}
     2507
     2508
     2509/** @interface_method_impl{PDMDEVHLPR3,pfnDriverReconfigure} */
     2510static DECLCALLBACK(int) pdmR3DevHlp_DriverReconfigure(PPDMDEVINS pDevIns, uint32_t iLun, uint32_t cDepth,
     2511                                                       const char * const *papszDrivers, PCFGMNODE *papConfigs, uint32_t fFlags)
     2512{
     2513    PDMDEV_ASSERT_DEVINS(pDevIns);
     2514    PVM pVM = pDevIns->Internal.s.pVMR3;
     2515    VM_ASSERT_EMT(pVM);
     2516    LogFlow(("pdmR3DevHlp_DriverReconfigure: caller='%s'/%d: iLun=%u cDepth=%u fFlags=%#x\n",
     2517             pDevIns->pReg->szName, pDevIns->iInstance, iLun, cDepth, fFlags));
     2518
     2519    /*
     2520     * Validate input.
     2521     */
     2522    AssertReturn(cDepth <= 8, VERR_INVALID_PARAMETER);
     2523    AssertPtrReturn(papszDrivers, VERR_INVALID_POINTER);
     2524    AssertPtrNullReturn(papConfigs, VERR_INVALID_POINTER);
     2525    for (uint32_t i = 0; i < cDepth; i++)
     2526    {
     2527        AssertPtrReturn(papszDrivers[i], VERR_INVALID_POINTER);
     2528        size_t cchDriver = strlen(papszDrivers[i]);
     2529        AssertPtrReturn(cchDriver > 0 && cchDriver < RT_SIZEOFMEMB(PDMDRVREG, szName), VERR_OUT_OF_RANGE);
     2530
     2531        if (papConfigs)
     2532            AssertPtrNullReturn(papConfigs[i], VERR_INVALID_POINTER);
     2533    }
     2534    AssertReturn(fFlags == 0, VERR_INVALID_FLAGS);
     2535
     2536    /*
     2537     * Do we have to detach an existing driver first?
     2538     */
     2539    for (PPDMLUN pLun = pDevIns->Internal.s.pLunsR3; pLun; pLun = pLun->pNext)
     2540        if (pLun->iLun == iLun)
     2541        {
     2542            if (pLun->pTop)
     2543            {
     2544                int rc = pdmR3DrvDetach(pLun->pTop, 0);
     2545                AssertRCReturn(rc, rc);
     2546            }
     2547            break;
     2548        }
     2549
     2550    /*
     2551     * Remove the old tree.
     2552     */
     2553    PCFGMNODE pCfgDev = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/", pDevIns->pReg->szName, pDevIns->iInstance);
     2554    AssertReturn(pCfgDev, VERR_INTERNAL_ERROR_2);
     2555    PCFGMNODE pCfgLun = CFGMR3GetChildF(pCfgDev, "LUN#%u", iLun);
     2556    if (pCfgLun)
     2557        CFGMR3RemoveNode(pCfgLun);
     2558
     2559    /*
     2560     * Construct a new tree.
     2561     */
     2562    int rc = CFGMR3InsertNodeF(pCfgDev, &pCfgLun, "LUN#%u", iLun);
     2563    AssertRCReturn(rc, rc);
     2564    PCFGMNODE pCfgDrv = pCfgLun;
     2565    for (uint32_t i = 0; i < cDepth; i++)
     2566    {
     2567        rc = CFGMR3InsertString(pCfgDrv, "Driver", papszDrivers[i]);
     2568        AssertRCReturn(rc, rc);
     2569        if (papConfigs && papConfigs[i])
     2570        {
     2571            rc = CFGMR3InsertSubTree(pCfgDrv, "Config", papConfigs[i], NULL);
     2572            AssertRCReturn(rc, rc);
     2573            papConfigs[i] = NULL;
     2574        }
     2575        else
     2576        {
     2577            rc = CFGMR3InsertNode(pCfgDrv, "Config", NULL);
     2578            AssertRCReturn(rc, rc);
     2579        }
     2580
     2581        if (i + 1 >= cDepth)
     2582            break;
     2583        rc = CFGMR3InsertNode(pCfgDrv, "AttachedDriver", &pCfgDrv);
     2584        AssertRCReturn(rc, rc);
     2585    }
     2586
     2587    LogFlow(("pdmR3DevHlp_DriverReconfigure: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
    25052588    return rc;
    25062589}
     
    44984581    pdmR3DevHlp_DriverAttach,
    44994582    pdmR3DevHlp_DriverDetach,
     4583    pdmR3DevHlp_DriverReconfigure,
    45004584    pdmR3DevHlp_QueueCreatePtr,
    45014585    pdmR3DevHlp_QueueCreate,
     
    49955079    pdmR3DevHlp_DriverAttach,
    49965080    pdmR3DevHlp_DriverDetach,
     5081    pdmR3DevHlp_DriverReconfigure,
    49975082    pdmR3DevHlp_QueueCreatePtr,
    49985083    pdmR3DevHlp_QueueCreate,
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