Changeset 59348 in vbox for trunk/src/VBox/Devices/Audio
- Timestamp:
- Jan 14, 2016 2:48:08 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 105029
- Location:
- trunk/src/VBox/Devices/Audio
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r59275 r59348 315 315 uint8_t uLUN; 316 316 uint8_t Padding[5]; 317 /** Audio connector interface to the underlying 318 * host backend. */ 317 /** Pointer to attached driver base interface. */ 318 R3PTRTYPE(PPDMIBASE) pDrvBase; 319 /** Audio connector interface to the underlying host backend. */ 319 320 R3PTRTYPE(PPDMIAUDIOCONNECTOR) pConnector; 320 321 /** Stream for line input. */ … … 372 373 uint8_t silence[128]; 373 374 int bup_flag; 374 /** Pointer to the attached audio driver. */375 PPDMIBASE pDrvBase;376 375 /** The base interface for LUN\#0. */ 377 376 PDMIBASE IBase; … … 2191 2190 PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE); 2192 2191 2193 AssertMsgReturn(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,2194 ("AC'97 device does not support hotplugging\n"),2195 VERR_INVALID_PARAMETER);2196 2197 2192 /* 2198 2193 * Attach driver. … … 2200 2195 char *pszDesc = NULL; 2201 2196 if (RTStrAPrintf(&pszDesc, "Audio driver port (AC'97) for LUN #%u", uLUN) <= 0) 2202 AssertMsgReturn(pszDesc, 2203 ("Not enough memory for AC'97 driver port description of LUN #%u\n", uLUN), 2204 VERR_NO_MEMORY); 2205 2197 AssertReleaseMsgReturn(pszDesc, 2198 ("Not enough memory for AC'97 driver port description of LUN #%u\n", uLUN), 2199 VERR_NO_MEMORY); 2200 2201 PPDMIBASE pDrvBase; 2206 2202 int rc = PDMDevHlpDriverAttach(pDevIns, uLUN, 2207 &pThis->IBase, &p This->pDrvBase, pszDesc);2203 &pThis->IBase, &pDrvBase, pszDesc); 2208 2204 if (RT_SUCCESS(rc)) 2209 2205 { … … 2211 2207 if (pDrv) 2212 2208 { 2213 pDrv->pConnector = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIAUDIOCONNECTOR); 2214 AssertMsg(pDrv->pConnector != NULL, 2215 ("Configuration error: LUN #%u has no host audio interface, rc=%Rrc\n", 2216 uLUN, rc)); 2209 pDrv->pDrvBase = pDrvBase; 2210 pDrv->pConnector = PDMIBASE_QUERY_INTERFACE(pDrvBase, PDMIAUDIOCONNECTOR); 2211 AssertMsg(pDrv->pConnector != NULL, ("Configuration error: LUN #%u has no host audio interface, rc=%Rrc\n", uLUN, rc)); 2217 2212 pDrv->pAC97State = pThis; 2218 pDrv->uLUN = uLUN;2213 pDrv->uLUN = uLUN; 2219 2214 2220 2215 /* … … 2241 2236 uLUN, pszDesc, rc)); 2242 2237 2243 RTStrFree(pszDesc); 2238 if (RT_FAILURE(rc)) 2239 { 2240 /* Only free this string on failure; 2241 * must remain valid for the live of the driver instance. */ 2242 RTStrFree(pszDesc); 2243 } 2244 2244 2245 2245 LogFunc(("iLUN=%u, fFlags=0x%x, rc=%Rrc\n", uLUN, fFlags, rc)); … … 2247 2247 } 2248 2248 2249 static void ichac97Detach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) 2250 { 2251 LogFunc(("iLUN=%u, fFlags=0x%x\n", uLUN, fFlags)); 2252 } 2253 2254 static int ichac97Reattach(PAC97STATE pThis, PCFGMNODE pCfg, PAC97DRIVER pDrv, const char *pszDriver) 2255 { 2256 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 2257 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 2258 AssertPtrReturn(pDrv, VERR_INVALID_POINTER); 2259 AssertPtrReturn(pszDriver, VERR_INVALID_POINTER); 2260 2261 PVM pVM = PDMDevHlpGetVM(pThis->pDevInsR3); 2262 PCFGMNODE pRoot = CFGMR3GetRoot(pVM); 2263 PCFGMNODE pDev0 = CFGMR3GetChild(pRoot, "Devices/ichac97/0/"); 2264 2265 /* Remove LUN branch. */ 2266 CFGMR3RemoveNode(CFGMR3GetChildF(pDev0, "LUN#%u/", pDrv->uLUN)); 2267 2268 int rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); 2269 if (RT_FAILURE(rc)) 2270 return rc; 2271 2272 #define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } 2273 2274 do 2275 { 2276 PCFGMNODE pLunL0; 2277 rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", pDrv->uLUN); RC_CHECK(); 2278 rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK(); 2279 rc = CFGMR3InsertNode(pLunL0, "Config/", NULL); RC_CHECK(); 2280 2281 PCFGMNODE pLunL1, pLunL2; 2282 rc = CFGMR3InsertNode (pLunL0, "AttachedDriver/", &pLunL1); RC_CHECK(); 2283 rc = CFGMR3InsertNode (pLunL1, "Config/", &pLunL2); RC_CHECK(); 2284 rc = CFGMR3InsertString(pLunL1, "Driver", pszDriver); RC_CHECK(); 2285 2286 rc = CFGMR3InsertString(pLunL2, "AudioDriver", pszDriver); RC_CHECK(); 2287 2288 } while (0); 2289 2290 if (RT_SUCCESS(rc)) 2291 rc = ichac97Attach(pThis->pDevInsR3, pDrv->uLUN, 0 /* fFlags */); 2292 2293 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc)); 2294 2295 #undef RC_CHECK 2296 2297 return rc; 2298 } 2249 2299 2250 2300 /** … … 2373 2423 { 2374 2424 LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN)); 2375 rc = ichac97Attach(pDevIns, uLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG);2425 rc = ichac97Attach(pDevIns, uLUN, 0 /* fFlags */); 2376 2426 if (RT_FAILURE(rc)) 2377 2427 { … … 2450 2500 if (cFailed == 3) 2451 2501 { 2452 LogRel(("AC97: Falling back to NULL driver(no sound audible)\n"));2502 LogRel(("AC97: Falling back to NULL backend (no sound audible)\n")); 2453 2503 2454 2504 ichac97Reset(pDevIns); 2455 2456 /* Was not able initialize *any* stream. 2457 * Select the NULL audio driver instead. */ 2458 pCon->pfnInitNull(pCon); 2505 ichac97Reattach(pThis, pCfg, pDrv, "NullAudio"); 2459 2506 2460 2507 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", … … 2606 2653 NULL, 2607 2654 /* pfnAttach */ 2608 NULL,2655 ichac97Attach, 2609 2656 /* pfnDetach */ 2610 NULL,2657 ichac97Detach, 2611 2658 /* pfnQueryInterface. */ 2612 2659 NULL, -
trunk/src/VBox/Devices/Audio/DevIchHda.cpp
r59343 r59348 658 658 /** LUN to which this driver has been assigned. */ 659 659 uint8_t uLUN; 660 /** Audio connector interface to the underlying 661 * host backend. */ 660 /** Pointer to attached driver base interface. */ 661 R3PTRTYPE(PPDMIBASE) pDrvBase; 662 /** Audio connector interface to the underlying host backend. */ 662 663 R3PTRTYPE(PPDMIAUDIOCONNECTOR) pConnector; 663 664 /** Stream for line input. */ … … 684 685 /** Padding for alignment. */ 685 686 uint32_t u32Padding; 686 /** Pointer to the attached audio driver. */687 R3PTRTYPE(PPDMIBASE) pDrvBase;688 687 /** The base interface for LUN\#0. */ 689 688 PDMIBASE IBase; … … 4323 4322 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); 4324 4323 4325 AssertMsgReturn(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,4326 ("HDA device does not support hotplugging\n"),4327 VERR_INVALID_PARAMETER);4328 4329 4324 /* 4330 4325 * Attach driver. … … 4332 4327 char *pszDesc = NULL; 4333 4328 if (RTStrAPrintf(&pszDesc, "Audio driver port (HDA) for LUN#%u", uLUN) <= 0) 4334 AssertMsgReturn(pszDesc, 4335 ("Not enough memory for HDA driver port description of LUN #%u\n", uLUN), 4336 VERR_NO_MEMORY); 4337 4329 AssertReleaseMsgReturn(pszDesc, 4330 ("Not enough memory for HDA driver port description of LUN #%u\n", uLUN), 4331 VERR_NO_MEMORY); 4332 4333 PPDMIBASE pDrvBase; 4338 4334 int rc = PDMDevHlpDriverAttach(pDevIns, uLUN, 4339 &pThis->IBase, &p This->pDrvBase, pszDesc);4335 &pThis->IBase, &pDrvBase, pszDesc); 4340 4336 if (RT_SUCCESS(rc)) 4341 4337 { … … 4343 4339 if (pDrv) 4344 4340 { 4345 pDrv->pConnector = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIAUDIOCONNECTOR); 4341 pDrv->pDrvBase = pDrvBase; 4342 pDrv->pConnector = PDMIBASE_QUERY_INTERFACE(pDrvBase, PDMIAUDIOCONNECTOR); 4346 4343 AssertMsg(pDrv->pConnector != NULL, ("Configuration error: LUN#%u has no host audio interface, rc=%Rrc\n", uLUN, rc)); 4347 4344 pDrv->pHDAState = pThis; … … 4363 4360 rc = VERR_NO_MEMORY; 4364 4361 } 4365 else if ( rc == VERR_PDM_NO_ATTACHED_DRIVER 4366 || rc == VERR_PDM_CFG_MISSING_DRIVER_NAME) 4362 else if (rc == VERR_PDM_NO_ATTACHED_DRIVER) 4367 4363 { 4368 4364 LogFunc(("No attached driver for LUN #%u\n", uLUN)); … … 4372 4368 uLUN, pszDesc, rc)); 4373 4369 4374 RTStrFree(pszDesc); 4370 if (RT_FAILURE(rc)) 4371 { 4372 /* Only free this string on failure; 4373 * must remain valid for the live of the driver instance. */ 4374 RTStrFree(pszDesc); 4375 } 4375 4376 4376 4377 LogFunc(("uLUN=%u, fFlags=0x%x, rc=%Rrc\n", uLUN, fFlags, rc)); … … 4378 4379 } 4379 4380 4380 static DECLCALLBACK(void) hdaDetach(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags) 4381 { 4382 NOREF(pDevIns); NOREF(iLUN); NOREF(fFlags); 4383 4384 LogFlowFuncEnter(); 4381 static DECLCALLBACK(void) hdaDetach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) 4382 { 4383 LogFunc(("iLUN=%u, fFlags=0x%x\n", uLUN, fFlags)); 4384 } 4385 4386 static int hdaReattach(PHDASTATE pThis, PCFGMNODE pCfg, PHDADRIVER pDrv, const char *pszDriver) 4387 { 4388 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 4389 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 4390 AssertPtrReturn(pDrv, VERR_INVALID_POINTER); 4391 AssertPtrReturn(pszDriver, VERR_INVALID_POINTER); 4392 4393 PVM pVM = PDMDevHlpGetVM(pThis->pDevInsR3); 4394 PCFGMNODE pRoot = CFGMR3GetRoot(pVM); 4395 PCFGMNODE pDev0 = CFGMR3GetChild(pRoot, "Devices/hda/0/"); 4396 4397 /* Remove LUN branch. */ 4398 CFGMR3RemoveNode(CFGMR3GetChildF(pDev0, "LUN#%u/", pDrv->uLUN)); 4399 4400 int rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); 4401 if (RT_FAILURE(rc)) 4402 return rc; 4403 4404 #define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } 4405 4406 do 4407 { 4408 PCFGMNODE pLunL0; 4409 rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", pDrv->uLUN); RC_CHECK(); 4410 rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK(); 4411 rc = CFGMR3InsertNode(pLunL0, "Config/", NULL); RC_CHECK(); 4412 4413 PCFGMNODE pLunL1, pLunL2; 4414 rc = CFGMR3InsertNode (pLunL0, "AttachedDriver/", &pLunL1); RC_CHECK(); 4415 rc = CFGMR3InsertNode (pLunL1, "Config/", &pLunL2); RC_CHECK(); 4416 rc = CFGMR3InsertString(pLunL1, "Driver", pszDriver); RC_CHECK(); 4417 4418 rc = CFGMR3InsertString(pLunL2, "AudioDriver", pszDriver); RC_CHECK(); 4419 4420 } while (0); 4421 4422 if (RT_SUCCESS(rc)) 4423 rc = hdaAttach(pThis->pDevInsR3, pDrv->uLUN, 0 /* fFlags */); 4424 4425 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc)); 4426 4427 #undef RC_CHECK 4428 4429 return rc; 4385 4430 } 4386 4431 … … 4388 4433 * @interface_method_impl{PDMDEVREG,pfnConstruct} 4389 4434 */ 4390 static DECLCALLBACK(int) hdaConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg Handle)4435 static DECLCALLBACK(int) hdaConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 4391 4436 { 4392 4437 PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE); … … 4397 4442 * Validations. 4398 4443 */ 4399 if (!CFGMR3AreValuesValid(pCfg Handle, "R0Enabled\0"4400 4401 4444 if (!CFGMR3AreValuesValid(pCfg, "R0Enabled\0" 4445 "RCEnabled\0" 4446 "TimerHz\0")) 4402 4447 return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES, 4403 4448 N_ ("Invalid configuration for the Intel HDA device")); 4404 4449 4405 int rc = CFGMR3QueryBoolDef(pCfg Handle, "RCEnabled", &pThis->fRCEnabled, false);4450 int rc = CFGMR3QueryBoolDef(pCfg, "RCEnabled", &pThis->fRCEnabled, false); 4406 4451 if (RT_FAILURE(rc)) 4407 4452 return PDMDEV_SET_ERROR(pDevIns, rc, 4408 4453 N_("HDA configuration error: failed to read RCEnabled as boolean")); 4409 rc = CFGMR3QueryBoolDef(pCfg Handle, "R0Enabled", &pThis->fR0Enabled, false);4454 rc = CFGMR3QueryBoolDef(pCfg, "R0Enabled", &pThis->fR0Enabled, false); 4410 4455 if (RT_FAILURE(rc)) 4411 4456 return PDMDEV_SET_ERROR(pDevIns, rc, … … 4413 4458 #ifndef VBOX_WITH_AUDIO_CALLBACKS 4414 4459 uint16_t uTimerHz; 4415 rc = CFGMR3QueryU16Def(pCfg Handle, "TimerHz", &uTimerHz, 200 /* Hz */);4460 rc = CFGMR3QueryU16Def(pCfg, "TimerHz", &uTimerHz, 200 /* Hz */); 4416 4461 if (RT_FAILURE(rc)) 4417 4462 return PDMDEV_SET_ERROR(pDevIns, rc, … … 4540 4585 { 4541 4586 LogFunc(("Trying to attach driver for LUN #%RU32 ...\n", uLUN)); 4542 rc = hdaAttach(pDevIns, uLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG);4587 rc = hdaAttach(pDevIns, uLUN, 0 /* fFlags */); 4543 4588 if (RT_FAILURE(rc)) 4544 4589 { … … 4607 4652 4608 4653 /* Construct the codec. */ 4609 rc = hdaCodecConstruct(pDevIns, pThis->pCodec, 0 /* Codec index */, pCfg Handle);4654 rc = hdaCodecConstruct(pDevIns, pThis->pCodec, 0 /* Codec index */, pCfg); 4610 4655 if (RT_FAILURE(rc)) 4611 4656 AssertRCReturn(rc, rc); … … 4629 4674 rc = hdaStreamCreate(&pThis->StrmStOut); 4630 4675 AssertRC(rc); 4676 4677 PHDADRIVER pDrv; 4678 RTListForEach(&pThis->lstDrv, pDrv, HDADRIVER, Node) 4679 { 4680 /* 4681 * Only primary drivers are critical for the VM to run. Everything else 4682 * might not worth showing an own error message box in the GUI. 4683 */ 4684 if (!(pDrv->Flags & PDMAUDIODRVFLAG_PRIMARY)) 4685 continue; 4686 4687 PPDMIAUDIOCONNECTOR pCon = pDrv->pConnector; 4688 AssertPtr(pCon); 4689 4690 uint8_t cFailed = 0; 4691 if (!pCon->pfnIsValidIn (pCon, pDrv->LineIn.pStrmIn)) 4692 cFailed++; 4693 #ifdef VBOX_WITH_HDA_MIC_IN 4694 if (!pCon->pfnIsValidIn (pCon, pDrv->MicIn.pStrmIn)) 4695 cFailed++; 4696 #endif 4697 if (!pCon->pfnIsValidOut(pCon, pDrv->Out.pStrmOut)) 4698 cFailed++; 4699 4700 #ifdef VBOX_WITH_HDA_MIC_IN 4701 if (cFailed == 3) 4702 #else 4703 if (cFailed == 2) 4704 #endif 4705 { 4706 LogRel(("HDA: Falling back to NULL backend (no sound audible)\n")); 4707 4708 hdaReset(pDevIns); 4709 hdaReattach(pThis, pCfg, pDrv, "NullAudio"); 4710 4711 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 4712 N_("No audio devices could be opened. Selecting the NULL audio backend " 4713 "with the consequence that no sound is audible")); 4714 } 4715 else if (cFailed) 4716 { 4717 if (!pDrv->pConnector->pfnIsValidIn (pDrv->pConnector, pDrv->LineIn.pStrmIn)) 4718 LogRel(("HDA: WARNING: Unable to open PCM line input for LUN #%RU32!\n", pDrv->uLUN)); 4719 #ifdef VBOX_WITH_HDA_MIC_IN 4720 if (!pDrv->pConnector->pfnIsValidIn (pDrv->pConnector, pDrv->MicIn.pStrmIn)) 4721 LogRel(("HDA: WARNING: Unable to open PCM microphone input for LUN #%RU32!\n", pDrv->uLUN)); 4722 #endif 4723 if (!pDrv->pConnector->pfnIsValidOut(pDrv->pConnector, pDrv->Out.pStrmOut)) 4724 LogRel(("HDA: WARNING: Unable to open PCM output for LUN #%RU32!\n", pDrv->uLUN)); 4725 4726 char szMissingStreams[255]; 4727 size_t len = 0; 4728 if (!pCon->pfnIsValidIn (pCon, pDrv->LineIn.pStrmIn)) 4729 len = RTStrPrintf(szMissingStreams, 4730 sizeof(szMissingStreams), "PCM Input"); 4731 #ifdef VBOX_WITH_HDA_MIC_IN 4732 if (!pCon->pfnIsValidIn (pCon, pDrv->MicIn.pStrmIn)) 4733 len += RTStrPrintf(szMissingStreams + len, 4734 sizeof(szMissingStreams) - len, len ? ", PCM Microphone" : "PCM Microphone"); 4735 #endif 4736 if (!pCon->pfnIsValidOut(pCon, pDrv->Out.pStrmOut)) 4737 len += RTStrPrintf(szMissingStreams + len, 4738 sizeof(szMissingStreams) - len, len ? ", PCM Output" : "PCM Output"); 4739 4740 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 4741 N_("Some HDA audio streams (%s) could not be opened. Guest applications generating audio " 4742 "output or depending on audio input may hang. Make sure your host audio device " 4743 "is working properly. Check the logfile for error messages of the audio " 4744 "subsystem"), szMissingStreams); 4745 } 4746 } 4631 4747 } 4632 4748 … … 4819 4935 NULL, 4820 4936 /* pfnAttach */ 4821 NULL,4937 hdaAttach, 4822 4938 /* pfnDetach */ 4823 NULL,4939 hdaDetach, 4824 4940 /* pfnQueryInterface. */ 4825 4941 NULL, -
trunk/src/VBox/Devices/Audio/DevSB16.cpp
r59275 r59348 98 98 uint8_t uLUN; 99 99 uint8_t Padding[5]; 100 /** Audio connector interface to the underlying 101 * host backend. */ 100 /** Pointer to attached driver base interface. */ 101 R3PTRTYPE(PPDMIBASE) pDrvBase; 102 /** Audio connector interface to the underlying host backend. */ 102 103 R3PTRTYPE(PPDMIAUDIOCONNECTOR) pConnector; 103 104 /** Stream for output. */ … … 109 110 #ifdef VBOX 110 111 /** Pointer to the device instance. */ 111 PPDMDEVINSR3 pDevIns ;112 PPDMDEVINSR3 pDevInsR3; 112 113 /** Pointer to the connector of the attached audio driver. */ 113 114 PPDMIAUDIOCONNECTOR pDrv; … … 179 180 uint64_t uTimerTSIO; 180 181 #endif 181 PTMTIMER pTimerIRQ; 182 PPDMIBASE pDrvBase; 183 /** LUN\#0: Base interface. */ 184 PDMIBASE IBase; 182 PTMTIMER pTimerIRQ; 183 /** The base interface for LUN\#0. */ 184 PDMIBASE IBase; 185 185 186 186 /* mixer state */ … … 207 207 PSB16STATE pThis = PDMINS_2_DATA(pDevIns, PSB16STATE); 208 208 209 AssertMsgReturn(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG,210 ("AC'97 device does not support hotplugging\n"),211 VERR_INVALID_PARAMETER);212 213 209 /* 214 210 * Attach driver. … … 216 212 char *pszDesc = NULL; 217 213 if (RTStrAPrintf(&pszDesc, "Audio driver port (SB16) for LUN #%u", uLUN) <= 0) 218 AssertMsgReturn(pszDesc, 219 ("Not enough memory for SB16 driver port description of LUN #%u\n", uLUN), 220 VERR_NO_MEMORY); 221 214 AssertReleaseMsgReturn(pszDesc, 215 ("Not enough memory for SB16 driver port description of LUN #%u\n", uLUN), 216 VERR_NO_MEMORY); 217 218 PPDMIBASE pDrvBase; 222 219 int rc = PDMDevHlpDriverAttach(pDevIns, uLUN, 223 &pThis->IBase, &p This->pDrvBase, pszDesc);220 &pThis->IBase, &pDrvBase, pszDesc); 224 221 if (RT_SUCCESS(rc)) 225 222 { … … 227 224 if (pDrv) 228 225 { 229 pDrv->pConnector = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIAUDIOCONNECTOR); 230 AssertMsg(pDrv->pConnector != NULL, 231 ("Configuration error: LUN #%u has no host audio interface, rc=%Rrc\n", 232 uLUN, rc)); 226 pDrv->pDrvBase = pDrvBase; 227 pDrv->pConnector = PDMIBASE_QUERY_INTERFACE(pDrvBase, PDMIAUDIOCONNECTOR); 228 AssertMsg(pDrv->pConnector != NULL, ("Configuration error: LUN #%u has no host audio interface, rc=%Rrc\n", uLUN, rc)); 233 229 pDrv->pSB16State = pThis; 234 pDrv->uLUN = uLUN;230 pDrv->uLUN = uLUN; 235 231 236 232 /* … … 257 253 uLUN, pszDesc, rc)); 258 254 259 RTStrFree(pszDesc); 255 if (RT_FAILURE(rc)) 256 { 257 /* Only free this string on failure; 258 * must remain valid for the live of the driver instance. */ 259 RTStrFree(pszDesc); 260 } 260 261 261 262 LogFunc(("iLUN=%u, fFlags=0x%x, rc=%Rrc\n", uLUN, fFlags, rc)); 263 return rc; 264 } 265 266 static void sb16Detach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags) 267 { 268 LogFunc(("iLUN=%u, fFlags=0x%x\n", uLUN, fFlags)); 269 } 270 271 static int sb16Reattach(PSB16STATE pThis, PCFGMNODE pCfg, PSB16DRIVER pDrv, const char *pszDriver) 272 { 273 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 274 AssertPtrReturn(pCfg, VERR_INVALID_POINTER); 275 AssertPtrReturn(pDrv, VERR_INVALID_POINTER); 276 AssertPtrReturn(pszDriver, VERR_INVALID_POINTER); 277 278 PVM pVM = PDMDevHlpGetVM(pThis->pDevInsR3); 279 PCFGMNODE pRoot = CFGMR3GetRoot(pVM); 280 PCFGMNODE pDev0 = CFGMR3GetChild(pRoot, "Devices/SB16/0/"); 281 282 /* Remove LUN branch. */ 283 CFGMR3RemoveNode(CFGMR3GetChildF(pDev0, "LUN#%u/", pDrv->uLUN)); 284 285 int rc = PDMDevHlpDriverDetach(pThis->pDevInsR3, PDMIBASE_2_PDMDRV(pDrv->pDrvBase), 0 /* fFlags */); 286 if (RT_FAILURE(rc)) 287 return rc; 288 289 #define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } 290 291 do 292 { 293 PCFGMNODE pLunL0; 294 rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", pDrv->uLUN); RC_CHECK(); 295 rc = CFGMR3InsertString(pLunL0, "Driver", "AUDIO"); RC_CHECK(); 296 rc = CFGMR3InsertNode(pLunL0, "Config/", NULL); RC_CHECK(); 297 298 PCFGMNODE pLunL1, pLunL2; 299 rc = CFGMR3InsertNode (pLunL0, "AttachedDriver/", &pLunL1); RC_CHECK(); 300 rc = CFGMR3InsertNode (pLunL1, "Config/", &pLunL2); RC_CHECK(); 301 rc = CFGMR3InsertString(pLunL1, "Driver", pszDriver); RC_CHECK(); 302 303 rc = CFGMR3InsertString(pLunL2, "AudioDriver", pszDriver); RC_CHECK(); 304 305 } while (0); 306 307 if (RT_SUCCESS(rc)) 308 rc = sb16Attach(pThis->pDevInsR3, pDrv->uLUN, 0 /* fFlags */); 309 310 LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc)); 311 312 #undef RC_CHECK 313 262 314 return rc; 263 315 } … … 336 388 if (hold) 337 389 { 338 PDMDevHlpDMASetDREQ (pThis->pDevIns , dma, 1);339 PDMDevHlpDMASchedule (pThis->pDevIns );390 PDMDevHlpDMASetDREQ (pThis->pDevInsR3, dma, 1); 391 PDMDevHlpDMASchedule (pThis->pDevInsR3); 340 392 RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node) 341 393 pDrv->pConnector->pfnEnableOut(pDrv->pConnector, … … 344 396 else 345 397 { 346 PDMDevHlpDMASetDREQ (pThis->pDevIns , dma, 0);398 PDMDevHlpDMASetDREQ (pThis->pDevInsR3, dma, 0); 347 399 RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node) 348 400 pDrv->pConnector->pfnEnableOut(pDrv->pConnector, … … 355 407 PSB16STATE pThis = (PSB16STATE)pvThis; 356 408 pThis->can_write = 1; 357 PDMDevHlpISASetIrq(pThis->pDevIns , pThis->irq, 1);409 PDMDevHlpISASetIrq(pThis->pDevInsR3, pThis->irq, 1); 358 410 } 359 411 … … 747 799 dsp_out_data(pThis, 0xaa); 748 800 pThis->mixer_regs[0x82] |= (cmd == 0xf2) ? 1 : 2; 749 PDMDevHlpISASetIrq(pThis->pDevIns , pThis->irq, 1);801 PDMDevHlpISASetIrq(pThis->pDevInsR3, pThis->irq, 1); 750 802 break; 751 803 … … 920 972 ticks = (bytes * TMTimerGetFreq(pThis->pTimerIRQ)) / freq; 921 973 if (ticks < TMTimerGetFreq(pThis->pTimerIRQ) / 1024) 922 PDMDevHlpISASetIrq(pThis->pDevIns , pThis->irq, 1);974 PDMDevHlpISASetIrq(pThis->pDevInsR3, pThis->irq, 1); 923 975 else 924 976 TMTimerSet(pThis->pTimerIRQ, TMTimerGet(pThis->pTimerIRQ) + ticks); … … 1024 1076 static void sb16Reset(PSB16STATE pThis) 1025 1077 { 1026 PDMDevHlpISASetIrq(pThis->pDevIns , pThis->irq, 0);1078 PDMDevHlpISASetIrq(pThis->pDevInsR3, pThis->irq, 0); 1027 1079 if (pThis->dma_auto) 1028 1080 { 1029 PDMDevHlpISASetIrq(pThis->pDevIns , pThis->irq, 1);1030 PDMDevHlpISASetIrq(pThis->pDevIns , pThis->irq, 0);1081 PDMDevHlpISASetIrq(pThis->pDevInsR3, pThis->irq, 1); 1082 PDMDevHlpISASetIrq(pThis->pDevInsR3, pThis->irq, 0); 1031 1083 } 1032 1084 … … 1067 1119 { 1068 1120 pThis->highspeed = 0; 1069 PDMDevHlpISASetIrq(pThis->pDevIns , pThis->irq, 0);1121 PDMDevHlpISASetIrq(pThis->pDevInsR3, pThis->irq, 0); 1070 1122 sb16Control(pThis, 0); 1071 1123 } … … 1191 1243 ack = 1; 1192 1244 pThis->mixer_regs[0x82] &= ~1; 1193 PDMDevHlpISASetIrq(pThis->pDevIns , pThis->irq, 0);1245 PDMDevHlpISASetIrq(pThis->pDevInsR3, pThis->irq, 0); 1194 1246 } 1195 1247 break; … … 1201 1253 ack = 1; 1202 1254 pThis->mixer_regs[0x82] &= ~2; 1203 PDMDevHlpISASetIrq(pThis->pDevIns , pThis->irq, 0);1255 PDMDevHlpISASetIrq(pThis->pDevInsR3, pThis->irq, 0); 1204 1256 } 1205 1257 break; … … 1529 1581 cbToRead = sizeof(tmpbuf); 1530 1582 1531 int rc = PDMDevHlpDMAReadMemory(pThis->pDevIns , nchan, tmpbuf, dma_pos, cbToRead, &cbRead);1583 int rc = PDMDevHlpDMAReadMemory(pThis->pDevInsR3, nchan, tmpbuf, dma_pos, cbToRead, &cbRead); 1532 1584 AssertMsgRC(rc, ("DMAReadMemory -> %Rrc\n", rc)); 1533 1585 … … 1622 1674 { 1623 1675 pThis->mixer_regs[0x82] |= (nchan & 4) ? 2 : 1; 1624 PDMDevHlpISASetIrq(pThis->pDevIns , pThis->irq, 1);1676 PDMDevHlpISASetIrq(pThis->pDevInsR3, pThis->irq, 1); 1625 1677 if (0 == pThis->dma_auto) 1626 1678 { … … 1730 1782 1731 1783 /* New space available, see if we can transfer more. */ 1732 PDMDevHlpDMASchedule(pThis->pDevIns );1784 PDMDevHlpDMASchedule(pThis->pDevInsR3); 1733 1785 } 1734 1786 … … 1962 2014 PSB16DRIVER pDrv; 1963 2015 uint8_t uLUN = 0; 1964 char *pszDesc; 2016 1965 2017 RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node) 1966 2018 { 2019 char *pszDesc; 1967 2020 if (RTStrAPrintf(&pszDesc, "[LUN#%RU8] sb16.po", uLUN) <= 0) 1968 2021 { … … 1993 2046 uLUN++; 1994 2047 } 2048 1995 2049 /* Ensure volume gets propagated. */ 1996 2050 AudioMixerInvalidate(pThis->pMixer); … … 2009 2063 * sure there's no interrupt or DMA activity. 2010 2064 */ 2011 PDMDevHlpISASetIrq(pThis->pDevIns , pThis->irq, 0);2065 PDMDevHlpISASetIrq(pThis->pDevInsR3, pThis->irq, 0); 2012 2066 2013 2067 pThis->mixer_regs[0x82] = 0; … … 2067 2121 } 2068 2122 2069 static DECLCALLBACK(int) sb16Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg Handle)2123 static DECLCALLBACK(int) sb16Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg) 2070 2124 { 2071 2125 PSB16STATE pThis = PDMINS_2_DATA(pDevIns, PSB16STATE); … … 2076 2130 Assert(iInstance == 0); 2077 2131 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 2078 if (!CFGMR3AreValuesValid(pCfg Handle,2132 if (!CFGMR3AreValuesValid(pCfg, 2079 2133 "IRQ\0" 2080 2134 "DMA\0" … … 2089 2143 * Read config data. 2090 2144 */ 2091 int rc = CFGMR3QuerySIntDef(pCfg Handle, "IRQ", &pThis->irq, 5);2145 int rc = CFGMR3QuerySIntDef(pCfg, "IRQ", &pThis->irq, 5); 2092 2146 if (RT_FAILURE(rc)) 2093 2147 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2095 2149 pThis->irqCfg = pThis->irq; 2096 2150 2097 rc = CFGMR3QuerySIntDef(pCfg Handle, "DMA", &pThis->dma, 1);2151 rc = CFGMR3QuerySIntDef(pCfg, "DMA", &pThis->dma, 1); 2098 2152 if (RT_FAILURE(rc)) 2099 2153 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2101 2155 pThis->dmaCfg = pThis->dma; 2102 2156 2103 rc = CFGMR3QuerySIntDef(pCfg Handle, "DMA16", &pThis->hdma, 5);2157 rc = CFGMR3QuerySIntDef(pCfg, "DMA16", &pThis->hdma, 5); 2104 2158 if (RT_FAILURE(rc)) 2105 2159 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2108 2162 2109 2163 RTIOPORT Port; 2110 rc = CFGMR3QueryPortDef(pCfg Handle, "Port", &Port, 0x220);2164 rc = CFGMR3QueryPortDef(pCfg, "Port", &Port, 0x220); 2111 2165 if (RT_FAILURE(rc)) 2112 2166 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2116 2170 2117 2171 uint16_t u16Version; 2118 rc = CFGMR3QueryU16Def(pCfg Handle, "Version", &u16Version, 0x0405);2172 rc = CFGMR3QueryU16Def(pCfg, "Version", &u16Version, 0x0405); 2119 2173 if (RT_FAILURE(rc)) 2120 2174 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2123 2177 #ifndef VBOX_WITH_AUDIO_CALLBACKS 2124 2178 uint16_t uTimerHz; 2125 rc = CFGMR3QueryU16Def(pCfg Handle, "TimerHz", &uTimerHz, 200 /* Hz */);2179 rc = CFGMR3QueryU16Def(pCfg, "TimerHz", &uTimerHz, 200 /* Hz */); 2126 2180 if (RT_FAILURE(rc)) 2127 2181 return PDMDEV_SET_ERROR(pDevIns, rc, … … 2135 2189 * Init instance data. 2136 2190 */ 2137 pThis->pDevIns 2191 pThis->pDevInsR3 = pDevIns; 2138 2192 pThis->IBase.pfnQueryInterface = sb16QueryInterface; 2139 2193 pThis->cmd = -1; … … 2187 2241 { 2188 2242 LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN)); 2189 rc = sb16Attach(pDevIns, uLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG);2243 rc = sb16Attach(pDevIns, uLUN, 0 /* fFlags */); 2190 2244 if (RT_FAILURE(rc)) 2191 2245 { … … 2201 2255 2202 2256 sb16ResetLegacy(pThis); 2257 2258 PSB16DRIVER pDrv; 2259 RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node) 2260 { 2261 /* 2262 * Only primary drivers are critical for the VM to run. Everything else 2263 * might not worth showing an own error message box in the GUI. 2264 */ 2265 if (!(pDrv->Flags & PDMAUDIODRVFLAG_PRIMARY)) 2266 continue; 2267 2268 PPDMIAUDIOCONNECTOR pCon = pDrv->pConnector; 2269 AssertPtr(pCon); 2270 2271 uint8_t cFailed = 0; 2272 if (!pCon->pfnIsValidOut(pCon, pDrv->Out.pStrmOut)) 2273 cFailed++; 2274 2275 if (cFailed) 2276 { 2277 LogRel(("SB16: Falling back to NULL backend (no sound audible)\n")); 2278 2279 sb16ResetLegacy(pThis); 2280 sb16Reattach(pThis, pCfg, pDrv, "NullAudio"); 2281 2282 PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding", 2283 N_("No audio devices could be opened. Selecting the NULL audio backend " 2284 "with the consequence that no sound is audible")); 2285 } 2286 } 2203 2287 2204 2288 #ifndef VBOX_WITH_AUDIO_CALLBACKS … … 2222 2306 if (RT_SUCCESS(rc)) 2223 2307 { 2308 /** @todo Merge this callback registration with the validation block above once 2309 * this becomes the standard. */ 2224 2310 PSB16DRIVER pDrv; 2225 2311 RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node) … … 2291 2377 NULL, 2292 2378 /* pfnAttach */ 2293 NULL,2379 sb16Attach, 2294 2380 /* pfnDetach */ 2295 NULL,2381 sb16Detach, 2296 2382 /* pfnQueryInterface */ 2297 2383 NULL, -
trunk/src/VBox/Devices/Audio/DrvAudio.cpp
r59275 r59348 1728 1728 } 1729 1729 1730 static DECLCALLBACK(int) drvAudioInitNull(PPDMIAUDIOCONNECTOR pInterface)1731 {1732 PDRVAUDIO pThis = PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface);1733 NOREF(pThis);1734 1735 LogRel(("Audio: Using NULL driver; no sound will be audible\n"));1736 1737 /* Nothing to do here yet. */1738 return VINF_SUCCESS;1739 }1740 1741 1730 static DECLCALLBACK(int) drvAudioRead(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMIN pGstStrmIn, 1742 1731 void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead) … … 2169 2158 pThis->IAudioConnector.pfnIsValidIn = drvAudioIsValidIn; 2170 2159 pThis->IAudioConnector.pfnIsValidOut = drvAudioIsValidOut; 2171 pThis->IAudioConnector.pfnInitNull = drvAudioInitNull;2172 2160 pThis->IAudioConnector.pfnEnableOut = drvAudioEnableOut; 2173 2161 pThis->IAudioConnector.pfnEnableIn = drvAudioEnableIn;
Note:
See TracChangeset
for help on using the changeset viewer.