VirtualBox

Changeset 59376 in vbox


Ignore:
Timestamp:
Jan 18, 2016 12:59:36 PM (9 years ago)
Author:
vboxsync
Message:

Audio: if the backend couldn't be initialized (ie pfnInit() failed), use the NULL audio driver

Location:
trunk/src/VBox/Devices/Audio
Files:
3 edited

Legend:

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

    r59357 r59376  
    22802280}
    22812281
    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 */
     2293static int ichac97Reattach(PAC97STATE pThis, PAC97DRIVER pDrv, uint8_t uLUN, const char *pszDriver)
    22832294{
    22842295    AssertPtrReturn(pThis,     VERR_INVALID_POINTER);
    2285     AssertPtrReturn(pCfg,      VERR_INVALID_POINTER);
    2286     AssertPtrReturn(pDrv,      VERR_INVALID_POINTER);
    22872296    AssertPtrReturn(pszDriver, VERR_INVALID_POINTER);
    22882297
     
    22922301
    22932302    /* 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    }
    22992312
    23002313#define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; }
    23012314
     2315    int rc = VINF_SUCCESS;
    23022316    do
    23032317    {
    23042318        PCFGMNODE pLunL0;
    2305         rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", pDrv->uLUN);  RC_CHECK();
     2319        rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", uLUN);        RC_CHECK();
    23062320        rc = CFGMR3InsertString(pLunL0, "Driver",       "AUDIO");       RC_CHECK();
    23072321        rc = CFGMR3InsertNode(pLunL0,   "Config/",       NULL);         RC_CHECK();
     
    23172331
    23182332    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));
    23222336
    23232337#undef RC_CHECK
     
    24482462     */
    24492463    uint8_t uLUN;
    2450     for (uLUN = 0; uLUN < UINT8_MAX; uLUN)
     2464    for (uLUN = 0; uLUN < UINT8_MAX; ++uLUN)
    24512465    {
    24522466        LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN));
     
    24562470            if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    24572471                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        }
    24622483    }
    24632484
     
    25312552
    25322553                ichac97Reset(pDevIns);
    2533                 ichac97Reattach(pThis, pCfg, pDrv, "NullAudio");
     2554                ichac97Reattach(pThis, pDrv, pDrv->uLUN, "NullAudio");
    25342555
    25352556                PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
  • trunk/src/VBox/Devices/Audio/DevIchHda.cpp

    r59358 r59376  
    44124412}
    44134413
    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 */
     4425static int hdaReattach(PHDASTATE pThis, PHDADRIVER pDrv, uint8_t uLUN, const char *pszDriver)
    44154426{
    44164427    AssertPtrReturn(pThis,     VERR_INVALID_POINTER);
    4417     AssertPtrReturn(pCfg,      VERR_INVALID_POINTER);
    4418     AssertPtrReturn(pDrv,      VERR_INVALID_POINTER);
    44194428    AssertPtrReturn(pszDriver, VERR_INVALID_POINTER);
    44204429
     
    44244433
    44254434    /* 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    }
    44314444
    44324445#define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; }
    44334446
     4447    int rc = VINF_SUCCESS;
    44344448    do
    44354449    {
    44364450        PCFGMNODE pLunL0;
    4437         rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", pDrv->uLUN);  RC_CHECK();
     4451        rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", uLUN);        RC_CHECK();
    44384452        rc = CFGMR3InsertString(pLunL0, "Driver",       "AUDIO");       RC_CHECK();
    44394453        rc = CFGMR3InsertNode(pLunL0,   "Config/",       NULL);         RC_CHECK();
     
    44494463
    44504464    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));
    44544468
    44554469#undef RC_CHECK
     
    46104624
    46114625    uint8_t uLUN;
    4612     for (uLUN = 0; uLUN < UINT8_MAX; uLUN)
     4626    for (uLUN = 0; uLUN < UINT8_MAX; ++uLUN)
    46134627    {
    46144628        LogFunc(("Trying to attach driver for LUN #%RU32 ...\n", uLUN));
     
    46184632            if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    46194633                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            }
    46214643            break;
    46224644        }
    4623 
    4624         uLUN++;
    46254645    }
    46264646
     
    47354755
    47364756                hdaReset(pDevIns);
    4737                 hdaReattach(pThis, pCfg, pDrv, "NullAudio");
     4757                hdaReattach(pThis, pDrv, pDrv->uLUN, "NullAudio");
    47384758
    47394759                PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
  • trunk/src/VBox/Devices/Audio/DevSB16.cpp

    r59357 r59376  
    296296}
    297297
    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 */
     309static int sb16Reattach(PSB16STATE pThis, PSB16DRIVER pDrv, uint8_t uLUN, const char *pszDriver)
    299310{
    300311    AssertPtrReturn(pThis,     VERR_INVALID_POINTER);
    301     AssertPtrReturn(pCfg,      VERR_INVALID_POINTER);
    302     AssertPtrReturn(pDrv,      VERR_INVALID_POINTER);
    303312    AssertPtrReturn(pszDriver, VERR_INVALID_POINTER);
    304313
     
    308317
    309318    /* 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    }
    315328
    316329#define RC_CHECK() if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; }
    317330
     331    int rc = VINF_SUCCESS;
    318332    do
    319333    {
    320334        PCFGMNODE pLunL0;
    321         rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", pDrv->uLUN);  RC_CHECK();
     335        rc = CFGMR3InsertNodeF(pDev0, &pLunL0, "LUN#%u/", uLUN);        RC_CHECK();
    322336        rc = CFGMR3InsertString(pLunL0, "Driver",       "AUDIO");       RC_CHECK();
    323337        rc = CFGMR3InsertNode(pLunL0,   "Config/",       NULL);         RC_CHECK();
     
    333347
    334348    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));
    338352
    339353#undef RC_CHECK
     
    22652279     */
    22662280    uint8_t uLUN;
    2267     for (uLUN = 0; uLUN < UINT8_MAX; uLUN)
     2281    for (uLUN = 0; uLUN < UINT8_MAX; ++uLUN)
    22682282    {
    22692283        LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN));
     
    22732287            if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
    22742288                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            }
    22752298            break;
    22762299        }
    2277 
    2278         uLUN++;
    22792300    }
    22802301
     
    23052326
    23062327            sb16ResetLegacy(pThis);
    2307             sb16Reattach(pThis, pCfg, pDrv, "NullAudio");
     2328            sb16Reattach(pThis, pDrv, pDrv->uLUN, "NullAudio");
    23082329
    23092330            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