VirtualBox

Changeset 89213 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
May 21, 2021 10:00:12 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
144554
Message:

Audio: Added an fImmediate indicator to the pfnStreamDestroy methods so the backend knows whether it's okay to continue draining the stream or if it must be destroyed without delay. The latter is typically only for shutdown and driver plumbing. This helps quite a bit for HDA/CoreAudio/knoppix. bugref:9890

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

Legend:

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

    r89190 r89213  
    112112
    113113static int audioMixerStreamCtlInternal(PAUDMIXSTREAM pMixStream, PDMAUDIOSTREAMCMD enmCmd);
    114 static void audioMixerStreamDestroyInternal(PAUDMIXSTREAM pStream, PPDMDEVINS pDevIns);
     114static void audioMixerStreamDestroyInternal(PAUDMIXSTREAM pStream, PPDMDEVINS pDevIns, bool fImmediate);
    115115static int audioMixerStreamUpdateStatus(PAUDMIXSTREAM pMixStream);
    116116
     
    663663                    }
    664664
    665                     rc = pConn->pfnStreamDestroy(pConn, pStream);
     665                    rc = pConn->pfnStreamDestroy(pConn, pStream, true /*fImmediate*/);
    666666                }
    667667
     
    10001000    {
    10011001        audioMixerSinkRemoveStreamInternal(pSink, pStream);
    1002         audioMixerStreamDestroyInternal(pStream, pDevIns); /* (Unlike the other two, this frees the stream structure.) */
     1002        audioMixerStreamDestroyInternal(pStream, pDevIns, true /*fImmediate*/); /* (Unlike the other two, this frees the stream structure.) */
    10031003    }
    10041004
     
    27352735 * @param   pMixStream  Mixer stream to destroy.
    27362736 * @param   pDevIns     The device instance the statistics are registered with.
    2737  */
    2738 static void audioMixerStreamDestroyInternal(PAUDMIXSTREAM pMixStream, PPDMDEVINS pDevIns)
     2737 * @param   fImmediate  How to handle still draining streams, whether to let
     2738 *                      them complete (@c false) or destroy them immediately (@c
     2739 *                      true).
     2740 */
     2741static void audioMixerStreamDestroyInternal(PAUDMIXSTREAM pMixStream, PPDMDEVINS pDevIns, bool fImmediate)
    27392742{
    27402743    AssertPtrReturnVoid(pMixStream);
     
    27482751        {
    27492752            pMixStream->pConn->pfnStreamRelease(pMixStream->pConn, pMixStream->pStream);
    2750             pMixStream->pConn->pfnStreamDestroy(pMixStream->pConn, pMixStream->pStream);
     2753            pMixStream->pConn->pfnStreamDestroy(pMixStream->pConn, pMixStream->pStream, fImmediate);
    27512754
    27522755            pMixStream->pStream = NULL;
     
    27762779 * Destroys a mixer stream.
    27772780 *
    2778  * @param   pMixStream      Mixer stream to destroy.
    2779  * @param   pDevIns         The device instance statistics are registered with.
    2780  */
    2781 void AudioMixerStreamDestroy(PAUDMIXSTREAM pMixStream, PPDMDEVINS pDevIns)
     2781 * @param   pMixStream  Mixer stream to destroy.
     2782 * @param   pDevIns     The device instance statistics are registered with.
     2783 * @param   fImmediate  How to handle still draining streams, whether to let
     2784 *                      them complete (@c false) or destroy them immediately (@c
     2785 *                      true).
     2786 */
     2787void AudioMixerStreamDestroy(PAUDMIXSTREAM pMixStream, PPDMDEVINS pDevIns, bool fImmediate)
    27822788{
    27832789    if (!pMixStream)
     
    28112817    if (RT_SUCCESS(rc2))
    28122818    {
    2813         audioMixerStreamDestroyInternal(pMixStream, pDevIns);
     2819        audioMixerStreamDestroyInternal(pMixStream, pDevIns, fImmediate);
    28142820        pMixStream = NULL;
    28152821    }
  • trunk/src/VBox/Devices/Audio/AudioMixer.h

    r88991 r89213  
    324324int         AudioMixerSinkUnlock(PAUDMIXSINK pSink);
    325325
    326 void AudioMixerStreamDestroy(PAUDMIXSTREAM pStream, PPDMDEVINS pDevIns);
     326void AudioMixerStreamDestroy(PAUDMIXSTREAM pStream, PPDMDEVINS pDevIns, bool fImmediate);
    327327
    328328#endif /* !VBOX_INCLUDED_SRC_Audio_AudioMixer_h */
  • trunk/src/VBox/Devices/Audio/DevHda.cpp

    r88941 r89213  
    17861786 * Removes an audio stream from the device setup using the given configuration.
    17871787 *
     1788 * Used by hdaRegWriteSDCTL().
     1789 *
    17881790 * @returns VBox status code.
    17891791 * @param   pThisCC             The ring-3 HDA device state.
     
    18451847        && enmMixerCtl != PDMAUDIOMIXERCTL_UNKNOWN)
    18461848    {
    1847         rc = hdaR3CodecRemoveStream(pThisCC->pCodec, enmMixerCtl);
     1849        rc = hdaR3CodecRemoveStream(pThisCC->pCodec, enmMixerCtl, false /*fImmediate*/);
    18481850    }
    18491851
     
    22142216
    22152217        AudioMixerSinkRemoveStream(pThisCC->SinkLineIn.pMixSink, pDrv->LineIn.pMixStrm);
    2216         AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm, pDevIns);
     2218        AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm, pDevIns, true /*fImmediate*/);
    22172219        pDrv->LineIn.pMixStrm = NULL;
    22182220    }
     
    22252227
    22262228        AudioMixerSinkRemoveStream(pThisCC->SinkMicIn.pMixSink, pDrv->MicIn.pMixStrm);
    2227         AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm, pDevIns);
     2229        AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm, pDevIns, true /*fImmediate*/);
    22282230        pDrv->MicIn.pMixStrm = NULL;
    22292231    }
     
    22332235    {
    22342236        AudioMixerSinkRemoveStream(pThisCC->SinkFront.pMixSink, pDrv->Front.pMixStrm);
    2235         AudioMixerStreamDestroy(pDrv->Front.pMixStrm, pDevIns);
     2237        AudioMixerStreamDestroy(pDrv->Front.pMixStrm, pDevIns, true /*fImmediate*/);
    22362238        pDrv->Front.pMixStrm = NULL;
    22372239    }
     
    22412243    {
    22422244        AudioMixerSinkRemoveStream(pThisCC->SinkCenterLFE.pMixSink, pDrv->CenterLFE.pMixStrm);
    2243         AudioMixerStreamDestroy(pDrv->CenterLFE.pMixStrm, pDevIns);
     2245        AudioMixerStreamDestroy(pDrv->CenterLFE.pMixStrm, pDevIns, true /*fImmediate*/);
    22442246        pDrv->CenterLFE.pMixStrm = NULL;
    22452247    }
     
    22482250    {
    22492251        AudioMixerSinkRemoveStream(pThisCC->SinkRear.pMixSink, pDrv->Rear.pMixStrm);
    2250         AudioMixerStreamDestroy(pDrv->Rear.pMixStrm, pDevIns);
     2252        AudioMixerStreamDestroy(pDrv->Rear.pMixStrm, pDevIns, true /*fImmediate*/);
    22512253        pDrv->Rear.pMixStrm = NULL;
    22522254    }
     
    23672369        }
    23682370        if (RT_FAILURE(rc))
    2369             AudioMixerStreamDestroy(pMixStrm, pDevIns);
     2371            AudioMixerStreamDestroy(pMixStrm, pDevIns, true /*fImmediate*/);
    23702372    }
    23712373
     
    24402442 * @interface_method_impl{HDACODECR3,pfnCbMixerRemoveStream}
    24412443 */
    2442 static DECLCALLBACK(int) hdaR3MixerRemoveStream(PPDMDEVINS pDevIns, PDMAUDIOMIXERCTL enmMixerCtl)
     2444static DECLCALLBACK(int) hdaR3MixerRemoveStream(PPDMDEVINS pDevIns, PDMAUDIOMIXERCTL enmMixerCtl, bool fImmediate)
    24432445{
    24442446    PHDASTATER3 pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PHDASTATER3);
     
    24922494            {
    24932495                AudioMixerSinkRemoveStream(pSink->pMixSink, pMixStream);
    2494                 AudioMixerStreamDestroy(pMixStream, pDevIns);
     2496                AudioMixerStreamDestroy(pMixStream, pDevIns, fImmediate);
    24952497
    24962498                pMixStream = NULL;
  • trunk/src/VBox/Devices/Audio/DevHdaCodec.cpp

    r88504 r89213  
    24712471}
    24722472
    2473 int hdaR3CodecRemoveStream(PHDACODECR3 pThisCC, PDMAUDIOMIXERCTL enmMixerCtl)
     2473int hdaR3CodecRemoveStream(PHDACODECR3 pThisCC, PDMAUDIOMIXERCTL enmMixerCtl, bool fImmediate)
    24742474{
    24752475    AssertPtrReturn(pThisCC, VERR_INVALID_POINTER);
    24762476
    2477     int rc = pThisCC->pfnCbMixerRemoveStream(pThisCC->pDevIns, enmMixerCtl);
     2477    int rc = pThisCC->pfnCbMixerRemoveStream(pThisCC->pDevIns, enmMixerCtl, fImmediate);
    24782478
    24792479    LogFlowFuncLeaveRC(rc);
     
    25722572    LogRel2(("HDA: Powering off codec ...\n"));
    25732573
    2574     int rc2 = hdaR3CodecRemoveStream(pThisCC, PDMAUDIOMIXERCTL_FRONT);
     2574    int rc2 = hdaR3CodecRemoveStream(pThisCC, PDMAUDIOMIXERCTL_FRONT, true /*fImmediate*/);
    25752575    AssertRC(rc2);
    25762576#ifdef VBOX_WITH_AUDIO_HDA_51_SURROUND
    2577     rc2 = hdaR3CodecRemoveStream(pThisCC, PDMAUDIOMIXERCTL_CENTER_LFE);
     2577    rc2 = hdaR3CodecRemoveStream(pThisCC, PDMAUDIOMIXERCTL_CENTER_LFE, true /*fImmediate*/);
    25782578    AssertRC(rc2);
    2579     rc2 = hdaR3CodecRemoveStream(pThisCC, PDMAUDIOMIXERCTL_REAR);
     2579    rc2 = hdaR3CodecRemoveStream(pThisCC, PDMAUDIOMIXERCTL_REAR, true /*fImmediate*/);
    25802580    AssertRC(rc2);
    25812581#endif
    25822582
    25832583#ifdef VBOX_WITH_AUDIO_HDA_MIC_IN
    2584     rc2 = hdaR3CodecRemoveStream(pThisCC, PDMAUDIOMIXERCTL_MIC_IN);
     2584    rc2 = hdaR3CodecRemoveStream(pThisCC, PDMAUDIOMIXERCTL_MIC_IN, true /*fImmediate*/);
    25852585    AssertRC(rc2);
    25862586#endif
    2587     rc2 = hdaR3CodecRemoveStream(pThisCC, PDMAUDIOMIXERCTL_LINE_IN);
     2587    rc2 = hdaR3CodecRemoveStream(pThisCC, PDMAUDIOMIXERCTL_LINE_IN, true /*fImmediate*/);
    25882588    AssertRC(rc2);
    25892589}
  • trunk/src/VBox/Devices/Audio/DevHdaCodec.h

    r88503 r89213  
    923923     * @param   pDevIns             The device instance.
    924924     * @param   enmMixerCtl         Mixer control to remove.
     925     * @param   fImmediate          Whether the backend should be allowed to
     926     *                              finished draining (@c false) or if it must be
     927     *                              destroyed immediately (@c true).
    925928     */
    926     DECLR3CALLBACKMEMBER(int,  pfnCbMixerRemoveStream, (PPDMDEVINS pDevIns, PDMAUDIOMIXERCTL enmMixerCtl));
     929    DECLR3CALLBACKMEMBER(int,  pfnCbMixerRemoveStream, (PPDMDEVINS pDevIns, PDMAUDIOMIXERCTL enmMixerCtl, bool fImmediate));
    927930    /**
    928931     * Controls an input / output converter widget, that is, which converter is
     
    952955int hdaR3CodecLoadState(PPDMDEVINS pDevIns, PHDACODEC pThis, PHDACODECR3 pThisCC, PSSMHANDLE pSSM, uint32_t uVersion);
    953956int hdaR3CodecAddStream(PHDACODECR3 pThisCC, PDMAUDIOMIXERCTL enmMixerCtl, PPDMAUDIOSTREAMCFG pCfg);
    954 int hdaR3CodecRemoveStream(PHDACODECR3 pThisCC, PDMAUDIOMIXERCTL enmMixerCtl);
     957int hdaR3CodecRemoveStream(PHDACODECR3 pThisCC, PDMAUDIOMIXERCTL enmMixerCtl, bool fImmediate);
    955958
    956959int hdaCodecSaveState(PPDMDEVINS pDevIns, PHDACODEC pThis, PSSMHANDLE pSSM);
  • trunk/src/VBox/Devices/Audio/DevIchAc97.cpp

    r89189 r89213  
    15471547            }
    15481548            if (RT_FAILURE(rc))
    1549                 AudioMixerStreamDestroy(pMixStrm, pDevIns);
     1549                AudioMixerStreamDestroy(pMixStrm, pDevIns, true /*fImmediate*/);
    15501550        }
    15511551
     
    16481648
    16491649        AudioMixerSinkRemoveStream(pThisCC->pSinkMicIn,  pDrv->MicIn.pMixStrm);
    1650         AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm, pDevIns);
     1650        AudioMixerStreamDestroy(pDrv->MicIn.pMixStrm, pDevIns, true /*fImmediate*/);
    16511651        pDrv->MicIn.pMixStrm = NULL;
    16521652    }
     
    16581658
    16591659        AudioMixerSinkRemoveStream(pThisCC->pSinkLineIn, pDrv->LineIn.pMixStrm);
    1660         AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm, pDevIns);
     1660        AudioMixerStreamDestroy(pDrv->LineIn.pMixStrm, pDevIns, true /*fImmediate*/);
    16611661        pDrv->LineIn.pMixStrm = NULL;
    16621662    }
     
    16651665    {
    16661666        AudioMixerSinkRemoveStream(pThisCC->pSinkOut,    pDrv->Out.pMixStrm);
    1667         AudioMixerStreamDestroy(pDrv->Out.pMixStrm, pDevIns);
     1667        AudioMixerStreamDestroy(pDrv->Out.pMixStrm, pDevIns, true /*fImmediate*/);
    16681668        pDrv->Out.pMixStrm = NULL;
    16691669    }
     
    16911691            AudioMixerSinkRemoveStream(pMixSink, pDrvStream->pMixStrm);
    16921692
    1693             AudioMixerStreamDestroy(pDrvStream->pMixStrm, pDevIns);
     1693            AudioMixerStreamDestroy(pDrvStream->pMixStrm, pDevIns, false /*fImmediate*/);
    16941694            pDrvStream->pMixStrm = NULL;
    16951695        }
  • trunk/src/VBox/Devices/Audio/DevSB16.cpp

    r88991 r89213  
    18151815                pDrvStream->pMixStrm = pMixStrm;
    18161816            else
    1817                 AudioMixerStreamDestroy(pMixStrm, pDevIns);
     1817                AudioMixerStreamDestroy(pMixStrm, pDevIns, true /*fImmediate*/);
    18181818        }
    18191819    }
     
    18831883            AudioMixerSinkRemoveStream(pMixSink, pDrvStream->pMixStrm);
    18841884
    1885             AudioMixerStreamDestroy(pDrvStream->pMixStrm, pDevIns);
     1885            AudioMixerStreamDestroy(pDrvStream->pMixStrm, pDevIns, false /*fImmediate*/);
    18861886            pDrvStream->pMixStrm = NULL;
    18871887        }
     
    19051905    PSB16DRIVER pDrv;
    19061906    RTListForEach(&pThis->lstDrv, pDrv, SB16DRIVER, Node)
     1907    {
    19071908        sb16RemoveDrvStream(pDevIns, pMixSink, enmDir, dstSrc, pDrv);
     1909    }
    19081910}
    19091911
     
    19531955    {
    19541956        AudioMixerSinkRemoveStream(pThis->pSinkOut, pDrv->Out.pMixStrm);
    1955         AudioMixerStreamDestroy(pDrv->Out.pMixStrm, pDevIns);
     1957        AudioMixerStreamDestroy(pDrv->Out.pMixStrm, pDevIns, true /*fImmediate*/);
    19561958        pDrv->Out.pMixStrm = NULL;
    19571959    }
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r89210 r89213  
    170170    /** Set if pfnStreamCreate returned VINF_AUDIO_STREAM_ASYNC_INIT_NEEDED. */
    171171    bool                    fNeedAsyncInit;
    172     bool                    afPadding[2];
     172    /** The fImmediate parameter value for pfnStreamDestroy. */
     173    bool                    fDestroyImmediate;
     174    bool                    fPadding;
    173175
    174176    /** Number of (re-)tries while re-initializing the stream. */
     
    18031805            {
    18041806                PPDMAUDIOBACKENDSTREAM pBackend = (PPDMAUDIOBACKENDSTREAM)(pStreamEx + 1);
    1805                 pBackend->uMagic            = PDMAUDIOBACKENDSTREAM_MAGIC;
    1806                 pBackend->pStream           = &pStreamEx->Core;
    1807 
    1808                 pStreamEx->pBackend         = pBackend;
    1809                 pStreamEx->Core.enmDir      = pCfgHost->enmDir;
    1810                 pStreamEx->Core.cbBackend   = (uint32_t)cbHstStrm;
    1811                 pStreamEx->fNoMixBufs       = RT_BOOL(fFlags & PDMAUDIOSTREAM_CREATE_F_NO_MIXBUF);
    1812                 pStreamEx->hReqInitAsync    = NIL_RTREQ;
    1813                 pStreamEx->uMagic           = DRVAUDIOSTREAM_MAGIC;
     1807                pBackend->uMagic                = PDMAUDIOBACKENDSTREAM_MAGIC;
     1808                pBackend->pStream               = &pStreamEx->Core;
     1809
     1810                pStreamEx->pBackend             = pBackend;
     1811                pStreamEx->Core.enmDir          = pCfgHost->enmDir;
     1812                pStreamEx->Core.cbBackend       = (uint32_t)cbHstStrm;
     1813                pStreamEx->fNoMixBufs           = RT_BOOL(fFlags & PDMAUDIOSTREAM_CREATE_F_NO_MIXBUF);
     1814                pStreamEx->fDestroyImmediate    = true;
     1815                pStreamEx->hReqInitAsync        = NIL_RTREQ;
     1816                pStreamEx->uMagic               = DRVAUDIOSTREAM_MAGIC;
    18141817
    18151818                /* Make a unqiue stream name including the host (backend) driver name. */
     
    19711974        RTCritSectRwEnterShared(&pThis->CritSectHotPlug); /** @todo needed? */
    19721975        if (pThis->pHostDrvAudio)
    1973             rc = pThis->pHostDrvAudio->pfnStreamDestroy(pThis->pHostDrvAudio, pStreamEx->pBackend);
     1976            rc = pThis->pHostDrvAudio->pfnStreamDestroy(pThis->pHostDrvAudio, pStreamEx->pBackend, pStreamEx->fDestroyImmediate);
    19741977        RTCritSectRwLeaveShared(&pThis->CritSectHotPlug);
    19751978
     
    20042007     * ...
    20052008     */
    2006     int rc = drvAudioStreamControlInternal(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE);
    2007     if (RT_SUCCESS(rc))
    2008         rc = drvAudioStreamDestroyInternalBackend(pThis, pStreamEx);
     2009    if (pStreamEx->fDestroyImmediate)
     2010        drvAudioStreamControlInternal(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE);
     2011    int rc = drvAudioStreamDestroyInternalBackend(pThis, pStreamEx);
    20092012
    20102013    /* Destroy mixing buffers. */
     
    21372140 * @param   pThis       Pointer to the DrvAudio instance data.
    21382141 * @param   pStreamEx   The stream.  One reference for us to release.
    2139  */
    2140 static DECLCALLBACK(void) drvAudioStreamDestroyAsync(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx)
    2141 {
    2142     LogFlowFunc(("pThis=%p pStreamEx=%p (%s)\n", pThis, pStreamEx, pStreamEx->Core.szName));
     2142 * @param   fImmediate  How to treat draining streams.
     2143 */
     2144static DECLCALLBACK(void) drvAudioStreamDestroyAsync(PDRVAUDIO pThis, PDRVAUDIOSTREAM pStreamEx, bool fImmediate)
     2145{
     2146    LogFlowFunc(("pThis=%p pStreamEx=%p (%s) fImmediate=%RTbool\n", pThis, pStreamEx, pStreamEx->Core.szName, fImmediate));
    21432147#ifdef LOG_ENABLED
    21442148    uint64_t const nsStart = RTTimeNanoTS();
    21452149#endif
    2146 
    21472150    RTCritSectEnter(&pStreamEx->Core.CritSect);
    21482151
    2149     /** @todo can we somehow drain it instead?
    2150      * Would need to know if the destroying is happening at runtime or when powering
    2151      * off the VM, as we don't care for draining the latter case. */
    2152     int rc2 = drvAudioStreamControlInternal(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE);
    2153     LogFlowFunc(("DISABLE done: %Rrc\n", rc2));
    2154     AssertRC(rc2);
     2152    pStreamEx->fDestroyImmediate = fImmediate; /* Do NOT adjust for draining status, just pass it as-is. CoreAudio needs this. */
     2153
     2154    if (!fImmediate && (pStreamEx->fStatus & PDMAUDIOSTREAM_STS_PENDING_DISABLE))
     2155        LogFlowFunc(("No DISABLE\n"));
     2156    else
     2157    {
     2158        int rc2 = drvAudioStreamControlInternal(pThis, pStreamEx, PDMAUDIOSTREAMCMD_DISABLE);
     2159        LogFlowFunc(("DISABLE done: %Rrc\n", rc2));
     2160        AssertRC(rc2);
     2161    }
    21552162
    21562163    RTCritSectLeave(&pStreamEx->Core.CritSect);
     
    21652172 * @interface_method_impl{PDMIAUDIOCONNECTOR,pfnStreamDestroy}
    21662173 */
    2167 static DECLCALLBACK(int) drvAudioStreamDestroy(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream)
     2174static DECLCALLBACK(int) drvAudioStreamDestroy(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream, bool fImmediate)
    21682175{
    21692176    PDRVAUDIO pThis = RT_FROM_MEMBER(pInterface, DRVAUDIO, IAudioConnector);
     
    21762183    PDRVAUDIOSTREAM pStreamEx = (PDRVAUDIOSTREAM)pStream;   /* Note! Do not touch pStream after this! */
    21772184    AssertPtrReturn(pStreamEx, VERR_INVALID_POINTER);
    2178     LogFlowFunc(("ENTER - %p %s\n", pStreamEx, pStreamEx->Core.szName));
     2185    LogFlowFunc(("ENTER - %p (%s) fImmediate=%RTbool\n", pStreamEx, pStreamEx->Core.szName, fImmediate));
    21792186    AssertReturn(pStreamEx->Core.uMagic == PDMAUDIOSTREAM_MAGIC, VERR_INVALID_MAGIC);
    21802187    AssertReturn(pStreamEx->uMagic == DRVAUDIOSTREAM_MAGIC, VERR_INVALID_MAGIC);
     
    22332240             */
    22342241            if (!(pThis->BackendCfg.fFlags & PDMAUDIOBACKEND_F_ASYNC_STREAM_DESTROY))
    2235                 drvAudioStreamDestroyAsync(pThis, pStreamEx);
     2242                drvAudioStreamDestroyAsync(pThis, pStreamEx, fImmediate);
    22362243            else
    22372244            {
    22382245                int rc2 = RTReqPoolCallEx(pThis->hReqPool, 0 /*cMillies*/, NULL /*phReq*/,
    22392246                                          RTREQFLAGS_VOID | RTREQFLAGS_NO_WAIT,
    2240                                           (PFNRT)drvAudioStreamDestroyAsync, 2, pThis, pStreamEx);
     2247                                          (PFNRT)drvAudioStreamDestroyAsync, 3, pThis, pStreamEx, fImmediate);
    22412248                LogFlowFunc(("hReqInitAsync=%p rc2=%Rrc\n", pStreamEx->hReqInitAsync, rc2));
    2242                 AssertRCStmt(rc2, drvAudioStreamDestroyAsync(pThis, pStreamEx));
     2249                AssertRCStmt(rc2, drvAudioStreamDestroyAsync(pThis, pStreamEx, fImmediate));
    22432250            }
    22442251        }
  • trunk/src/VBox/Devices/Audio/DrvHostAudioAlsa.cpp

    r89055 r89213  
    789789 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
    790790 */
    791 static DECLCALLBACK(int) drvHostAlsaAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     791static DECLCALLBACK(int) drvHostAlsaAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
     792                                                          bool fImmediate)
    792793{
    793794    RT_NOREF(pInterface);
    794795    PALSAAUDIOSTREAM pStreamALSA = (PALSAAUDIOSTREAM)pStream;
    795796    AssertPtrReturn(pStreamALSA, VERR_INVALID_POINTER);
     797    RT_NOREF(fImmediate);
    796798
    797799    /** @todo r=bird: It's not like we can do much with a bad status... Check
  • trunk/src/VBox/Devices/Audio/DrvHostAudioCoreAudio.cpp

    r89212 r89213  
    16421642 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
    16431643 */
    1644 static DECLCALLBACK(int) drvHostAudioCaHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1644static DECLCALLBACK(int) drvHostAudioCaHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
     1645                                                        bool fImmediate)
    16451646{
    16461647    RT_NOREF(pInterface);
    16471648    PCOREAUDIOSTREAM pStreamCA = (PCOREAUDIOSTREAM)pStream;
    16481649    AssertPtrReturn(pStreamCA, VERR_INVALID_POINTER);
    1649     LogFunc(("%p: %s\n", pStreamCA, pStreamCA->Cfg.szName));
     1650    LogFunc(("%p: %s fImmediate=%RTbool\n", pStreamCA, pStreamCA->Cfg.szName, fImmediate));
    16501651#ifdef LOG_ENABLED
    16511652    uint64_t const nsStart = RTTimeNanoTS();
     
    16681669        if (pStreamCA->hAudioQueue)
    16691670        {
    1670             orc = AudioQueueStop(pStreamCA->hAudioQueue, TRUE /*inImmediate/synchronously*/);
     1671            orc = AudioQueueStop(pStreamCA->hAudioQueue, fImmediate ? TRUE : FALSE /*inImmediate/synchronously*/);
    16711672            LogFlowFunc(("AudioQueueStop -> %#x\n", orc));
    16721673        }
     
    16911692#endif
    16921693
    1693         /* Resetting the queue helps prevent AudioQueueDispose from taking a long time. */
    1694         if (pStreamCA->hAudioQueue)
     1694#if 0 /* This seems to work even when doing a non-immediate stop&dispose. However, it doesn't make sense conceptually. */
     1695        if (pStreamCA->hAudioQueue /*&& fImmediate*/)
    16951696        {
    16961697            LogFlowFunc(("Calling AudioQueueReset ...\n"));
     
    16981699            LogFlowFunc(("AudioQueueReset -> %#x\n", orc));
    16991700        }
    1700 
    1701         if (pStreamCA->paBuffers)
     1701#endif
     1702
     1703        if (pStreamCA->paBuffers && fImmediate)
    17021704        {
    17031705            LogFlowFunc(("Freeing %u buffers ...\n", pStreamCA->cBuffers));
     
    17081710                pStreamCA->paBuffers[iBuf].pBuf = NULL;
    17091711            }
    1710             RTMemFree(pStreamCA->paBuffers);
    1711             pStreamCA->paBuffers = NULL;
    1712         }
    1713         pStreamCA->cBuffers = 0;
     1712        }
    17141713
    17151714        if (pStreamCA->hAudioQueue)
    17161715        {
    17171716            LogFlowFunc(("Disposing of the queue ...\n"));
    1718             orc = AudioQueueDispose(pStreamCA->hAudioQueue, TRUE /*inImmediate/synchronously*/); /* may take some time */
     1717            orc = AudioQueueDispose(pStreamCA->hAudioQueue, fImmediate ? TRUE : FALSE /*inImmediate/synchronously*/); /* may take some time */
    17191718            LogFlowFunc(("AudioQueueDispose -> %#x (%d)\n", orc, orc));
    17201719            AssertMsg(orc == noErr, ("AudioQueueDispose -> orc=%#x\n", orc));
    17211720            pStreamCA->hAudioQueue = NULL;
    17221721        }
     1722
     1723        /* We should get no further buffer callbacks at this point according to the docs. */
     1724        if (pStreamCA->paBuffers)
     1725        {
     1726            RTMemFree(pStreamCA->paBuffers);
     1727            pStreamCA->paBuffers = NULL;
     1728        }
     1729        pStreamCA->cBuffers = 0;
    17231730
    17241731#ifdef CORE_AUDIO_WITH_BREAKPOINT_TIMER
  • trunk/src/VBox/Devices/Audio/DrvHostAudioDSound.cpp

    r89089 r89213  
    17231723 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
    17241724 */
    1725 static DECLCALLBACK(int) drvHostDSoundHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1725static DECLCALLBACK(int) drvHostDSoundHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
     1726                                                       bool fImmediate)
    17261727{
    17271728    PDRVHOSTDSOUND pThis     = RT_FROM_MEMBER(pInterface, DRVHOSTDSOUND, IHostAudio);
     
    17291730    AssertPtrReturn(pStreamDS, VERR_INVALID_POINTER);
    17301731    LogFlowFunc(("Stream '%s' {%s}\n", pStreamDS->Cfg.szName, drvHostDSoundStreamStatusString(pStreamDS)));
     1732    RT_NOREF(fImmediate);
    17311733
    17321734    RTCritSectEnter(&pThis->CritSect);
  • trunk/src/VBox/Devices/Audio/DrvHostAudioDebug.cpp

    r89051 r89213  
    132132 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
    133133 */
    134 static DECLCALLBACK(int) drvHostDebugAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    135 {
    136     RT_NOREF(pInterface);
     134static DECLCALLBACK(int) drvHostDebugAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
     135                                                           bool fImmediate)
     136{
     137    RT_NOREF(pInterface, fImmediate);
    137138    PDEBUGAUDIOSTREAM pStreamDbg = (PDEBUGAUDIOSTREAM)pStream;
    138139    AssertPtrReturn(pStreamDbg, VERR_INVALID_POINTER);
  • trunk/src/VBox/Devices/Audio/DrvHostAudioNull.cpp

    r88887 r89213  
    9999 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
    100100 */
    101 static DECLCALLBACK(int) drvHostNullAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    102 {
    103     RT_NOREF(pInterface, pStream);
     101static DECLCALLBACK(int) drvHostNullAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
     102                                                          bool fImmediate)
     103{
     104    RT_NOREF(pInterface, pStream, fImmediate);
    104105    return VINF_SUCCESS;
    105106}
  • trunk/src/VBox/Devices/Audio/DrvHostAudioOss.cpp

    r89055 r89213  
    430430 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
    431431 */
    432 static DECLCALLBACK(int) drvHostOssAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    433 {
    434     RT_NOREF(pInterface);
     432static DECLCALLBACK(int) drvHostOssAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
     433                                                         bool fImmediate)
     434{
     435    RT_NOREF(pInterface, fImmediate);
    435436    POSSAUDIOSTREAM pStreamOSS = (POSSAUDIOSTREAM)pStream;
    436437    AssertPtrReturn(pStreamOSS, VERR_INVALID_POINTER);
  • trunk/src/VBox/Devices/Audio/DrvHostAudioPulseAudio.cpp

    r89055 r89213  
    11611161 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
    11621162 */
    1163 static DECLCALLBACK(int) drvHostAudioPaHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1163static DECLCALLBACK(int) drvHostAudioPaHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
     1164                                                        bool fImmediate)
    11641165{
    11651166    PDRVHOSTPULSEAUDIO pThis     = RT_FROM_MEMBER(pInterface, DRVHOSTPULSEAUDIO, IHostAudio);
    11661167    PPULSEAUDIOSTREAM  pStreamPA = (PPULSEAUDIOSTREAM)pStream;
    11671168    AssertPtrReturn(pStreamPA, VERR_INVALID_POINTER);
     1169    RT_NOREF(fImmediate);
    11681170
    11691171    if (pStreamPA->pStream)
  • trunk/src/VBox/Devices/Audio/DrvHostAudioValidationKit.cpp

    r89174 r89213  
    220220 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
    221221 */
    222 static DECLCALLBACK(int) drvHostValKitAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
    223 {
    224     RT_NOREF(pInterface); //PDRVHOSTVAKITAUDIO pThis     = RT_FROM_MEMBER(pInterface, DRVHOSTVAKITAUDIO, IHostAudio);
     222static DECLCALLBACK(int) drvHostValKitAudioHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
     223                                                            bool fImmediate)
     224{
     225    RT_NOREF(pInterface, fImmediate);
    225226    PVAKITAUDIOSTREAM  pStreamDbg = (PVAKITAUDIOSTREAM)pStream;
    226227    AssertPtrReturn(pStreamDbg, VERR_INVALID_POINTER);
  • trunk/src/VBox/Devices/Audio/DrvHostAudioWasApi.cpp

    r89129 r89213  
    19211921 * @interface_method_impl{PDMIHOSTAUDIO,pfnStreamDestroy}
    19221922 */
    1923 static DECLCALLBACK(int) drvHostAudioWasHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream)
     1923static DECLCALLBACK(int) drvHostAudioWasHA_StreamDestroy(PPDMIHOSTAUDIO pInterface, PPDMAUDIOBACKENDSTREAM pStream,
     1924                                                         bool fImmediate)
    19241925{
    19251926    PDRVHOSTAUDIOWAS        pThis      = RT_FROM_MEMBER(pInterface, DRVHOSTAUDIOWAS, IHostAudio);
     
    19271928    AssertPtrReturn(pStreamWas, VERR_INVALID_POINTER);
    19281929    LogFlowFunc(("Stream '%s'\n", pStreamWas->Cfg.szName));
     1930    RT_NOREF(fImmediate);
    19291931    HRESULT hrc;
    19301932
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