VirtualBox

Ignore:
Timestamp:
Jan 15, 2016 11:14:12 AM (9 years ago)
Author:
vboxsync
Message:

Audio: Reattaching fixes.

File:
1 edited

Legend:

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

    r59348 r59357  
    658658    /** LUN to which this driver has been assigned. */
    659659    uint8_t                            uLUN;
     660    /** Whether this driver is in an attached state or not. */
     661    bool                               fAttached;
    660662    /** Pointer to attached driver base interface. */
    661663    R3PTRTYPE(PPDMIBASE)               pDrvBase;
     
    43064308}
    43074309
     4310
    43084311/**
    4309  * Attach command.
     4312 * Attach command, internal version.
    43104313 *
    43114314 * This is called to let the device attach to a driver for a specified LUN
    43124315 * during runtime. This is not called during VM construction, the device
    4313  * constructor have to attach to all the available drivers.
     4316 * constructor has to attach to all the available drivers.
    43144317 *
    43154318 * @returns VBox status code.
    43164319 * @param   pDevIns     The device instance.
     4320 * @param   pDrv        Driver to (re-)use for (re-)attaching to.
     4321 *                      If NULL is specified, a new driver will be created and appended
     4322 *                      to the driver list.
    43174323 * @param   uLUN        The logical unit which is being detached.
    43184324 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    43194325 */
    4320 static DECLCALLBACK(int) hdaAttach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)
     4326static int hdaAttachInternal(PPDMDEVINS pDevIns, PHDADRIVER pDrv, unsigned uLUN, uint32_t fFlags)
    43214327{
    43224328    PHDASTATE pThis = PDMINS_2_DATA(pDevIns, PHDASTATE);
     
    43364342    if (RT_SUCCESS(rc))
    43374343    {
    4338         PHDADRIVER pDrv = (PHDADRIVER)RTMemAllocZ(sizeof(HDADRIVER));
     4344        if (pDrv == NULL)
     4345            pDrv = (PHDADRIVER)RTMemAllocZ(sizeof(HDADRIVER));
    43394346        if (pDrv)
    43404347        {
     
    43544361            LogFunc(("LUN#%u: pCon=%p, drvFlags=0x%x\n", uLUN, pDrv->pConnector, pDrv->Flags));
    43554362
    4356             /* Attach to driver list. */
    4357             RTListAppend(&pThis->lstDrv, &pDrv->Node);
     4363            /* Attach to driver list if not attached yet. */
     4364            if (!pDrv->fAttached)
     4365            {
     4366                RTListAppend(&pThis->lstDrv, &pDrv->Node);
     4367                pDrv->fAttached = true;
     4368            }
    43584369        }
    43594370        else
     
    43774388    LogFunc(("uLUN=%u, fFlags=0x%x, rc=%Rrc\n", uLUN, fFlags, rc));
    43784389    return rc;
     4390}
     4391
     4392/**
     4393 * Attach command.
     4394 *
     4395 * This is called to let the device attach to a driver for a specified LUN
     4396 * during runtime. This is not called during VM construction, the device
     4397 * constructor has to attach to all the available drivers.
     4398 *
     4399 * @returns VBox status code.
     4400 * @param   pDevIns     The device instance.
     4401 * @param   uLUN        The logical unit which is being detached.
     4402 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
     4403 */
     4404static DECLCALLBACK(int) hdaAttach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)
     4405{
     4406    return hdaAttachInternal(pDevIns, NULL /* pDrv */, uLUN, fFlags);
    43794407}
    43804408
     
    44214449
    44224450    if (RT_SUCCESS(rc))
    4423         rc = hdaAttach(pThis->pDevInsR3, pDrv->uLUN, 0 /* fFlags */);
     4451        rc = hdaAttachInternal(pThis->pDevInsR3, pDrv, pDrv->uLUN, 0 /* fFlags */);
    44244452
    44254453    LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc));
     
    45854613    {
    45864614        LogFunc(("Trying to attach driver for LUN #%RU32 ...\n", uLUN));
    4587         rc = hdaAttach(pDevIns, uLUN, 0 /* fFlags */);
     4615        rc = hdaAttachInternal(pDevIns, NULL /* pDrv */, uLUN, 0 /* fFlags */);
    45884616        if (RT_FAILURE(rc))
    45894617        {
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