VirtualBox

Changeset 88195 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Mar 18, 2021 4:35:14 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143353
Message:

DevHDA: Do stream resets w/ locks held in hdaR3GCTLReset, and to them up front. bugreg:9890

File:
1 edited

Legend:

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

    r88194 r88195  
    14001400        if (pStreamShared->State.fRunning)
    14011401        {
    1402             hdaR3StreamEnable(pStreamShared, pStreamR3, false /* fEnable */);
    1403             ASMAtomicWriteBool(&pStreamShared->State.fRunning, false);
     1402            int rc2 = hdaR3StreamEnable(pStreamShared, pStreamR3, false /* fEnable */);
     1403            AssertRC(rc2); Assert(!pStreamShared->State.fRunning);
     1404            pStreamShared->State.fRunning = false;
    14041405        }
    14051406
    14061407        /* Make sure to remove the run bit before doing the actual stream reset. */
    1407         HDA_STREAM_REG(pThis, CTL, uSD) &= ~HDA_SDCTL_RUN;
     1408        HDA_STREAM_REG(pThis, CTL, uSD) &= ~HDA_SDCTL_RUN; /** @todo r=bird: Isn't this utterly pointless? */
    14081409        hdaR3StreamReset(pThis, pThisCC, pStreamShared, pStreamR3, uSD);
    14091410
     
    28582859    LogFlowFuncEnter();
    28592860
     2861    /*
     2862     * Make sure all streams have stopped as these have both timers and
     2863     * asynchronous worker threads that would race us if we delay this work.
     2864     */
     2865    for (size_t idxStream = 0; idxStream < RT_ELEMENTS(pThis->aStreams); idxStream++)
     2866    {
     2867        PHDASTREAM const pStreamShared = &pThis->aStreams[idxStream];
     2868        hdaStreamLock(pStreamShared);
     2869# ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO
     2870        hdaR3StreamAsyncIOLock(&pThisCC->aStreams[idxStream]);
     2871# endif
     2872
     2873        /* We're doing this unconditionally, hope that's not problematic in any way... */
     2874        int rc = hdaR3StreamEnable(pStreamShared, &pThisCC->aStreams[idxStream], false /* fEnable */);
     2875        AssertLogRelMsg(RT_SUCCESS(rc) && !pStreamShared->State.fRunning,
     2876                        ("Disabling stream #%u failed: %Rrc, fRunning=%d\n", idxStream, rc, pStreamShared->State.fRunning));
     2877        pStreamShared->State.fRunning = false;
     2878
     2879        /* Remove the RUN bit from SDnCTL in case the stream was in a running state before. */
     2880        HDA_STREAM_REG(pThis, CTL, idxStream) &= ~HDA_SDCTL_RUN; /** @todo r=bird: Isn't this utterly pointless? */
     2881        hdaR3StreamReset(pThis, pThisCC, pStreamShared, &pThisCC->aStreams[idxStream], (uint8_t)idxStream);
     2882
     2883# ifdef VBOX_WITH_AUDIO_HDA_ASYNC_IO
     2884        hdaR3StreamAsyncIOUnlock(&pThisCC->aStreams[idxStream]);
     2885# endif
     2886        hdaStreamUnlock(pStreamShared);
     2887    }
     2888
     2889    /*
     2890     * Reset registers.
     2891     */
    28602892    HDA_REG(pThis, GCAP)     = HDA_MAKE_GCAP(HDA_MAX_SDO, HDA_MAX_SDI, 0, 0, 1); /* see 6.2.1 */
    28612893    HDA_REG(pThis, VMIN)     = 0x00;                                             /* see 6.2.2 */
     
    29342966    /* Clear our internal response interrupt counter. */
    29352967    pThis->u16RespIntCnt = 0;
    2936 
    2937     for (size_t idxStream = 0; idxStream < RT_ELEMENTS(pThis->aStreams); idxStream++)
    2938     {
    2939 /** @todo r=bird: insufficient locking here, I think... May race stream timer
    2940  *        and AIO threads. We should probably do this a lot earlier too. */
    2941         int rc2 = hdaR3StreamEnable(&pThis->aStreams[idxStream], &pThisCC->aStreams[idxStream], false /* fEnable */);
    2942         if (RT_SUCCESS(rc2))
    2943         {
    2944             /* Remove the RUN bit from SDnCTL in case the stream was in a running state before. */
    2945             HDA_STREAM_REG(pThis, CTL, idxStream) &= ~HDA_SDCTL_RUN;
    2946             hdaR3StreamReset(pThis, pThisCC, &pThis->aStreams[idxStream], &pThisCC->aStreams[idxStream], (uint8_t)idxStream);
    2947         }
    2948     }
    29492968
    29502969    /* Clear stream tags <-> objects mapping table. */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette