Changeset 82225 in vbox for trunk/src/VBox/Devices/Audio/DevSB16.cpp
- Timestamp:
- Nov 26, 2019 4:14:05 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r82223 r82225 2264 2264 * @returns VBox status code. 2265 2265 * @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 appended2268 * to the driver list.2269 2266 * @param uLUN The logical unit which is being re-detached. 2270 2267 * @param pszDriver New driver name to attach. 2271 2268 */ 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 2269 static int sb16Reattach(PSB16STATE pThis, uint8_t uLUN, const char *pszDriver) 2270 { 2271 AssertPtr(pThis); 2272 2273 int rc = PDMDevHlpDriverReconfigure2(pThis->pDevInsR3, uLUN, "AUDIO", pszDriver); 2325 2274 if (RT_SUCCESS(rc)) 2326 2275 rc = sb16AttachInternal(pThis, uLUN, 0 /* fFlags */, NULL /* ppDrv */); 2327 2276 2328 2277 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, uLUN, pszDriver, rc)); 2329 2330 #undef RC_CHECK2331 2278 2332 2279 return rc; … … 2517 2464 else if (rc == VERR_AUDIO_BACKEND_INIT_FAILED) 2518 2465 { 2519 sb16Reattach(pThis, NULL /* pDrv */,uLUN, "NullAudio");2466 sb16Reattach(pThis, uLUN, "NullAudio"); 2520 2467 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")); 2523 2469 /* Attaching to the NULL audio backend will never fail. */ 2524 2470 rc = VINF_SUCCESS; … … 2533 2479 2534 2480 #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) 2537 2483 { 2538 2484 /* … … 2557 2503 2558 2504 sb16CmdResetLegacy(pThis); 2559 sb16Reattach(pThis, pDrv, pDrv->uLUN, "NullAudio"); 2505 sb16Reattach(pThis, pDrv->uLUN, "NullAudio"); 2506 pDrv = NULL; /* no longer valid */ 2560 2507 2561 2508 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
Note:
See TracChangeset
for help on using the changeset viewer.