VirtualBox

Changeset 59357 in vbox


Ignore:
Timestamp:
Jan 15, 2016 11:14:12 AM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
105044
Message:

Audio: Reattaching fixes.

Location:
trunk/src/VBox/Devices
Files:
4 edited

Legend:

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

    r59351 r59357  
    314314    /** LUN # to which this driver has been assigned. */
    315315    uint8_t                            uLUN;
    316     uint8_t                            Padding[5];
     316    /** Whether this driver is in an attached state or not. */
     317    bool                               fAttached;
     318    uint8_t                            Padding[4];
    317319    /** Pointer to attached driver base interface. */
    318320    R3PTRTYPE(PPDMIBASE)               pDrvBase;
     
    21752177
    21762178/**
    2177  * Attach command.
     2179 * Attach command, internal version.
    21782180 *
    21792181 * This is called to let the device attach to a driver for a specified LUN
    21802182 * during runtime. This is not called during VM construction, the device
    2181  * constructor have to attach to all the available drivers.
     2183 * constructor has to attach to all the available drivers.
    21822184 *
    21832185 * @returns VBox status code.
    21842186 * @param   pDevIns     The device instance.
     2187 * @param   pDrv        Driver to (re-)use for (re-)attaching to.
     2188 *                      If NULL is specified, a new driver will be created and appended
     2189 *                      to the driver list.
    21852190 * @param   uLUN        The logical unit which is being detached.
    21862191 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    21872192 */
    2188 static DECLCALLBACK(int) ichac97Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)
     2193static DECLCALLBACK(int) ichac97AttachInternal(PPDMDEVINS pDevIns, PAC97DRIVER pDrv, unsigned uLUN, uint32_t fFlags)
    21892194{
    21902195    PAC97STATE pThis = PDMINS_2_DATA(pDevIns, PAC97STATE);
     
    22042209    if (RT_SUCCESS(rc))
    22052210    {
    2206         PAC97DRIVER pDrv = (PAC97DRIVER)RTMemAllocZ(sizeof(AC97DRIVER));
     2211        if (pDrv == NULL)
     2212            pDrv = (PAC97DRIVER)RTMemAllocZ(sizeof(AC97DRIVER));
    22072213        if (pDrv)
    22082214        {
     
    22222228            LogFunc(("LUN#%RU8: pCon=%p, drvFlags=0x%x\n", uLUN, pDrv->pConnector, pDrv->Flags));
    22232229
    2224             /* Attach to driver list. */
    2225             RTListAppend(&pThis->lstDrv, &pDrv->Node);
     2230            /* Attach to driver list if not attached yet. */
     2231            if (!pDrv->fAttached)
     2232            {
     2233                RTListAppend(&pThis->lstDrv, &pDrv->Node);
     2234                pDrv->fAttached = true;
     2235            }
    22262236        }
    22272237        else
     
    22452255    LogFunc(("iLUN=%u, fFlags=0x%x, rc=%Rrc\n", uLUN, fFlags, rc));
    22462256    return rc;
     2257}
     2258
     2259
     2260/**
     2261 * Attach command.
     2262 *
     2263 * This is called to let the device attach to a driver for a specified LUN
     2264 * during runtime. This is not called during VM construction, the device
     2265 * constructor has to attach to all the available drivers.
     2266 *
     2267 * @returns VBox status code.
     2268 * @param   pDevIns     The device instance.
     2269 * @param   uLUN        The logical unit which is being detached.
     2270 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
     2271 */
     2272static DECLCALLBACK(int) ichac97Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)
     2273{
     2274    return ichac97AttachInternal(pDevIns, NULL /* pDrv */, uLUN, fFlags);
    22472275}
    22482276
     
    22892317
    22902318    if (RT_SUCCESS(rc))
    2291         rc = ichac97Attach(pThis->pDevInsR3, pDrv->uLUN, 0 /* fFlags */);
     2319        rc = ichac97AttachInternal(pThis->pDevInsR3, pDrv, pDrv->uLUN, 0 /* fFlags */);
    22922320
    22932321    LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc));
     
    24232451    {
    24242452        LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN));
    2425         rc = ichac97Attach(pDevIns, uLUN, 0 /* fFlags */);
     2453        rc = ichac97AttachInternal(pDevIns, NULL /* pDrv */, uLUN, 0 /* fFlags */);
    24262454        if (RT_FAILURE(rc))
    24272455        {
     
    25112539            else if (cFailed)
    25122540            {
    2513                 if (!pDrv->pConnector->pfnIsValidIn (pDrv->pConnector, pDrv->LineIn.pStrmIn))
     2541                if (!pDrv->pConnector->pfnIsValidIn (pCon, pDrv->LineIn.pStrmIn))
    25142542                    LogRel(("AC97: WARNING: Unable to open PCM line input for LUN #%RU32!\n",       pDrv->uLUN));
    2515                 if (!pDrv->pConnector->pfnIsValidIn (pDrv->pConnector, pDrv->MicIn.pStrmIn))
     2543                if (!pDrv->pConnector->pfnIsValidIn (pCon, pDrv->MicIn.pStrmIn))
    25162544                    LogRel(("AC97: WARNING: Unable to open PCM microphone input for LUN #%RU32!\n", pDrv->uLUN));
    2517                 if (!pDrv->pConnector->pfnIsValidOut(pDrv->pConnector, pDrv->Out.pStrmOut))
     2545                if (!pDrv->pConnector->pfnIsValidOut(pCon, pDrv->Out.pStrmOut))
    25182546                    LogRel(("AC97: WARNING: Unable to open PCM output for LUN #%RU32!\n",           pDrv->uLUN));
    25192547
     
    25732601            /* Only register primary driver.
    25742602             * The device emulation does the output multiplexing then. */
    2575             if (pDrv->Flags != PDMAUDIODRVFLAG_PRIMARY)
     2603            if (!(pDrv->Flags & PDMAUDIODRVFLAG_PRIMARY))
    25762604                continue;
    25772605
  • 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        {
  • trunk/src/VBox/Devices/Audio/DevSB16.cpp

    r59351 r59357  
    9797    /** LUN # to which this driver has been assigned. */
    9898    uint8_t                            uLUN;
    99     uint8_t                            Padding[5];
     99    /** Whether this driver is in an attached state or not. */
     100    bool                               fAttached;
     101    uint8_t                            Padding[4];
    100102    /** Pointer to attached driver base interface. */
    101103    R3PTRTYPE(PPDMIBASE)               pDrvBase;
     
    192194
    193195/**
    194  * Attach command.
     196 * Attach command, internal version.
    195197 *
    196198 * This is called to let the device attach to a driver for a specified LUN
    197199 * during runtime. This is not called during VM construction, the device
    198  * constructor have to attach to all the available drivers.
     200 * constructor has to attach to all the available drivers.
    199201 *
    200202 * @returns VBox status code.
    201203 * @param   pDevIns     The device instance.
     204 * @param   pDrv        Driver to (re-)use for (re-)attaching to.
     205 *                      If NULL is specified, a new driver will be created and appended
     206 *                      to the driver list.
    202207 * @param   uLUN        The logical unit which is being detached.
    203208 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
    204209 */
    205 static DECLCALLBACK(int) sb16Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)
     210static DECLCALLBACK(int) sb16AttachInternal(PPDMDEVINS pDevIns, PSB16DRIVER pDrv, unsigned uLUN, uint32_t fFlags)
    206211{
    207212    PSB16STATE pThis = PDMINS_2_DATA(pDevIns, PSB16STATE);
     
    221226    if (RT_SUCCESS(rc))
    222227    {
    223         PSB16DRIVER pDrv = (PSB16DRIVER)RTMemAllocZ(sizeof(SB16DRIVER));
     228        if (pDrv == NULL)
     229            pDrv = (PSB16DRIVER)RTMemAllocZ(sizeof(SB16DRIVER));
    224230        if (pDrv)
    225231        {
     
    239245            LogFunc(("LUN#%RU8: pCon=%p, drvFlags=0x%x\n", uLUN, pDrv->pConnector, pDrv->Flags));
    240246
    241             /* Attach to driver list. */
    242             RTListAppend(&pThis->lstDrv, &pDrv->Node);
     247            /* Attach to driver list if not attached yet. */
     248            if (!pDrv->fAttached)
     249            {
     250                RTListAppend(&pThis->lstDrv, &pDrv->Node);
     251                pDrv->fAttached = true;
     252            }
    243253        }
    244254        else
     
    262272    LogFunc(("iLUN=%u, fFlags=0x%x, rc=%Rrc\n", uLUN, fFlags, rc));
    263273    return rc;
     274}
     275
     276/**
     277 * Attach command.
     278 *
     279 * This is called to let the device attach to a driver for a specified LUN
     280 * during runtime. This is not called during VM construction, the device
     281 * constructor has to attach to all the available drivers.
     282 *
     283 * @returns VBox status code.
     284 * @param   pDevIns     The device instance.
     285 * @param   uLUN        The logical unit which is being detached.
     286 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
     287 */
     288static DECLCALLBACK(int) sb16Attach(PPDMDEVINS pDevIns, unsigned uLUN, uint32_t fFlags)
     289{
     290    return sb16AttachInternal(pDevIns, NULL /* pDrv */, uLUN, fFlags);
    264291}
    265292
     
    306333
    307334    if (RT_SUCCESS(rc))
    308         rc = sb16Attach(pThis->pDevInsR3, pDrv->uLUN, 0 /* fFlags */);
     335        rc = sb16AttachInternal(pThis->pDevInsR3, pDrv, pDrv->uLUN, 0 /* fFlags */);
    309336
    310337    LogFunc(("pThis=%p, uLUN=%u, pszDriver=%s, rc=%Rrc\n", pThis, pDrv->uLUN, pszDriver, rc));
     
    22412268    {
    22422269        LogFunc(("Trying to attach driver for LUN #%RU8 ...\n", uLUN));
    2243         rc = sb16Attach(pDevIns, uLUN, 0 /* fFlags */);
     2270        rc = sb16AttachInternal(pDevIns, NULL /* pDrv */, uLUN, 0 /* fFlags */);
    22442271        if (RT_FAILURE(rc))
    22452272        {
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r59348 r59357  
    18491849    GEN_CHECK_OFF(AC97DRIVER, Flags);
    18501850    GEN_CHECK_OFF(AC97DRIVER, uLUN);
     1851    GEN_CHECK_OFF(AC97DRIVER, fAttached);
    18511852    GEN_CHECK_OFF(AC97DRIVER, pConnector);
    18521853    GEN_CHECK_OFF(AC97DRIVER, LineIn);
     
    18671868    GEN_CHECK_OFF(HDADRIVER, Flags);
    18681869    GEN_CHECK_OFF(HDADRIVER, uLUN);
     1870    GEN_CHECK_OFF(HDADRIVER, fAttached);
    18691871    GEN_CHECK_OFF(HDADRIVER, pConnector);
    18701872    GEN_CHECK_OFF(HDADRIVER, LineIn);
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