Changeset 59376 in vbox
- Timestamp:
- Jan 18, 2016 12:59:36 PM (9 years ago)
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r59357 r59376 2280 2280 } 2281 2281 2282 static int ichac97Reattach(PAC97STATE pThis, PCFGMNODE pCfg, PAC97DRIVER pDrv, const char *pszDriver) 2282 /** 2283 * Re-attach. 2284 * 2285 * @returns VBox status code. 2286 * @param pThis Device instance. 2287 * @param pDrv Driver instance used for attaching to. 2288 * If NULL is specified, a new driver will be created and appended 2289 * to the driver list. 2290 * @param uLUN The logical unit which is being re-detached. 2291 * @param pszDriver Driver name. 2292 */ 2293 static int ichac97Reattach(PAC97STATE pThis, PAC97DRIVER pDrv, uint8_t uLUN, const char *pszDriver) 2283 2294 { 2284 2295 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 2285 AssertPtrReturn(pCfg, VERR_INVALID_POINTER);2286 AssertPtrReturn(pDrv, VERR_INVALID_POINTER);2287 2296 AssertPtrReturn(pszDriver, VERR_INVALID_POINTER); 2288 2297 … … 2292 2301 2293 2302 /* Remove LUN branch. */ 2294 CFGMR3RemoveNode(CFGMR3GetChildF(pDev0, "LUN#%u/", pDrv->uLUN)); 2295 2296 int rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); 2297 if (RT_FAILURE(rc)) 2298 return rc; 2303 CFGMR3RemoveNode(CFGMR3GetChildF(pDev0, "LUN#%u/", uLUN)); 2304 2305 if (pDrv) 2306 { 2307 /* Re-use a driver instance => detach the driver before. */ 2308 int rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); 2309 if (RT_FAILURE(rc)) 2310 return rc; 2311 } 2299 2312 2300 2313 #define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } 2301 2314 2315 int rc = VINF_SUCCESS; 2302 2316 do 2303 2317 { 2304 2318 PCFGMNODE pLunL0; 2305 rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", pDrv->uLUN);RC_CHECK();2319 rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", uLUN); RC_CHECK(); 2306 2320 rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK(); 2307 2321 rc = CFGMR3InsertNode(pLunL0, "Config/", NULL); RC_CHECK(); … … 2317 2331 2318 2332 if (RT_SUCCESS(rc)) 2319 rc = ichac97AttachInternal(pThis->pDevInsR3, pDrv, pDrv->uLUN, 0 /* fFlags */);2320 2321 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc));2333 rc = ichac97AttachInternal(pThis->pDevInsR3, pDrv, uLUN, 0 /* fFlags */); 2334 2335 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, uLUN, pszDriver, rc)); 2322 2336 2323 2337 #undef RC_CHECK … … 2448 2462 */ 2449 2463 uint8_t uLUN; 2450 for (uLUN = 0; uLUN < UINT8_MAX; uLUN)2464 for (uLUN = 0; uLUN < UINT8_MAX; ++uLUN) 2451 2465 { 2452 2466 LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN)); … … 2456 2470 if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 2457 2471 rc = VINF_SUCCESS; 2458 break; 2459 } 2460 2461 uLUN++; 2472 else if (rc == VERR_AUDIO_BACKEND_INIT_FAILED) 2473 { 2474 ichac97Reattach(pThis, NULL /* pDrv */, uLUN, "NullAudio"); 2475 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 2476 N_("No audio devices could be opened. Selecting the NULL audio backend " 2477 "with the consequence that no sound is audible")); 2478 /* attaching to the NULL audio backend will never fail */ 2479 rc = VINF_SUCCESS; 2480 } 2481 break; 2482 } 2462 2483 } 2463 2484 … … 2531 2552 2532 2553 ichac97Reset(pDevIns); 2533 ichac97Reattach(pThis, p Cfg, pDrv, "NullAudio");2554 ichac97Reattach(pThis, pDrv, pDrv->uLUN, "NullAudio"); 2534 2555 2535 2556 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", -
trunk/src/VBox/Devices/Audio/DevIchHda.cpp
r59358 r59376 4412 4412 } 4413 4413 4414 static int hdaReattach(PHDASTATE pThis, PCFGMNODE pCfg, PHDADRIVER pDrv, const char *pszDriver) 4414 /** 4415 * Re-attach. 4416 * 4417 * @returns VBox status code. 4418 * @param pThis Device instance. 4419 * @param pDrv Driver instance used for attaching to. 4420 * If NULL is specified, a new driver will be created and appended 4421 * to the driver list. 4422 * @param uLUN The logical unit which is being re-detached. 4423 * @param pszDriver Driver name. 4424 */ 4425 static int hdaReattach(PHDASTATE pThis, PHDADRIVER pDrv, uint8_t uLUN, const char *pszDriver) 4415 4426 { 4416 4427 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 4417 AssertPtrReturn(pCfg, VERR_INVALID_POINTER);4418 AssertPtrReturn(pDrv, VERR_INVALID_POINTER);4419 4428 AssertPtrReturn(pszDriver, VERR_INVALID_POINTER); 4420 4429 … … 4424 4433 4425 4434 /* Remove LUN branch. */ 4426 CFGMR3RemoveNode(CFGMR3GetChildF(pDev0, "LUN#%u/", pDrv->uLUN)); 4427 4428 int rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); 4429 if (RT_FAILURE(rc)) 4430 return rc; 4435 CFGMR3RemoveNode(CFGMR3GetChildF(pDev0, "LUN#%u/", uLUN)); 4436 4437 if (pDrv) 4438 { 4439 /* Re-use a driver instance => detach the driver before. */ 4440 int rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); 4441 if (RT_FAILURE(rc)) 4442 return rc; 4443 } 4431 4444 4432 4445 #define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } 4433 4446 4447 int rc = VINF_SUCCESS; 4434 4448 do 4435 4449 { 4436 4450 PCFGMNODE pLunL0; 4437 rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", pDrv->uLUN);RC_CHECK();4451 rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", uLUN); RC_CHECK(); 4438 4452 rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK(); 4439 4453 rc = CFGMR3InsertNode(pLunL0, "Config/", NULL); RC_CHECK(); … … 4449 4463 4450 4464 if (RT_SUCCESS(rc)) 4451 rc = hdaAttachInternal(pThis->pDevInsR3, pDrv, pDrv->uLUN, 0 /* fFlags */);4452 4453 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc));4465 rc = hdaAttachInternal(pThis->pDevInsR3, pDrv, uLUN, 0 /* fFlags */); 4466 4467 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, uLUN, pszDriver, rc)); 4454 4468 4455 4469 #undef RC_CHECK … … 4610 4624 4611 4625 uint8_t uLUN; 4612 for (uLUN = 0; uLUN < UINT8_MAX; uLUN)4626 for (uLUN = 0; uLUN < UINT8_MAX; ++uLUN) 4613 4627 { 4614 4628 LogFunc(("Trying to attach driver for LUN #%RU32 ...\n", uLUN)); … … 4618 4632 if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 4619 4633 rc = VINF_SUCCESS; 4620 4634 else if (rc == VERR_AUDIO_BACKEND_INIT_FAILED) 4635 { 4636 hdaReattach(pThis, NULL /* pDrv */, uLUN, "NullAudio"); 4637 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 4638 N_("No audio devices could be opened. Selecting the NULL audio backend " 4639 "with the consequence that no sound is audible")); 4640 /* attaching to the NULL audio backend will never fail */ 4641 rc = VINF_SUCCESS; 4642 } 4621 4643 break; 4622 4644 } 4623 4624 uLUN++;4625 4645 } 4626 4646 … … 4735 4755 4736 4756 hdaReset(pDevIns); 4737 hdaReattach(pThis, p Cfg, pDrv, "NullAudio");4757 hdaReattach(pThis, pDrv, pDrv->uLUN, "NullAudio"); 4738 4758 4739 4759 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r59357 r59376 296 296 } 297 297 298 static int sb16Reattach(PSB16STATE pThis, PCFGMNODE pCfg, PSB16DRIVER pDrv, const char *pszDriver) 298 /** 299 * Re-attach. 300 * 301 * @returns VBox status code. 302 * @param pThis Device instance. 303 * @param pDrv Driver instance used for attaching to. 304 * If NULL is specified, a new driver will be created and appended 305 * to the driver list. 306 * @param uLUN The logical unit which is being re-detached. 307 * @param pszDriver Driver name. 308 */ 309 static int sb16Reattach(PSB16STATE pThis, PSB16DRIVER pDrv, uint8_t uLUN, const char *pszDriver) 299 310 { 300 311 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 301 AssertPtrReturn(pCfg, VERR_INVALID_POINTER);302 AssertPtrReturn(pDrv, VERR_INVALID_POINTER);303 312 AssertPtrReturn(pszDriver, VERR_INVALID_POINTER); 304 313 … … 308 317 309 318 /* Remove LUN branch. */ 310 CFGMR3RemoveNode(CFGMR3GetChildF(pDev0, "LUN#%u/", pDrv->uLUN)); 311 312 int rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); 313 if (RT_FAILURE(rc)) 314 return rc; 319 CFGMR3RemoveNode(CFGMR3GetChildF(pDev0, "LUN#%u/", uLUN)); 320 321 if (pDrv) 322 { 323 /* Re-use the driver instance so detach it before. */ 324 int rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); 325 if (RT_FAILURE(rc)) 326 return rc; 327 } 315 328 316 329 #define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } 317 330 331 int rc = VINF_SUCCESS; 318 332 do 319 333 { 320 334 PCFGMNODE pLunL0; 321 rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", pDrv->uLUN);RC_CHECK();335 rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", uLUN); RC_CHECK(); 322 336 rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK(); 323 337 rc = CFGMR3InsertNode(pLunL0, "Config/", NULL); RC_CHECK(); … … 333 347 334 348 if (RT_SUCCESS(rc)) 335 rc = sb16AttachInternal(pThis->pDevInsR3, pDrv, pDrv->uLUN, 0 /* fFlags */);336 337 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc));349 rc = sb16AttachInternal(pThis->pDevInsR3, pDrv, uLUN, 0 /* fFlags */); 350 351 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, uLUN, pszDriver, rc)); 338 352 339 353 #undef RC_CHECK … … 2265 2279 */ 2266 2280 uint8_t uLUN; 2267 for (uLUN = 0; uLUN < UINT8_MAX; uLUN)2281 for (uLUN = 0; uLUN < UINT8_MAX; ++uLUN) 2268 2282 { 2269 2283 LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN)); … … 2273 2287 if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 2274 2288 rc = VINF_SUCCESS; 2289 else if (rc == VERR_AUDIO_BACKEND_INIT_FAILED) 2290 { 2291 sb16Reattach(pThis, NULL /* pDrv */, uLUN, "NullAudio"); 2292 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 2293 N_("No audio devices could be opened. Selecting the NULL audio backend " 2294 "with the consequence that no sound is audible")); 2295 /* attaching to the NULL audio backend will never fail */ 2296 rc = VINF_SUCCESS; 2297 } 2275 2298 break; 2276 2299 } 2277 2278 uLUN++;2279 2300 } 2280 2301 … … 2305 2326 2306 2327 sb16ResetLegacy(pThis); 2307 sb16Reattach(pThis, p Cfg, pDrv, "NullAudio");2328 sb16Reattach(pThis, pDrv, pDrv->uLUN, "NullAudio"); 2308 2329 2309 2330 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
Note:
See TracChangeset
for help on using the changeset viewer.