VirtualBox

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


Ignore:
Timestamp:
Nov 6, 2015 12:26:32 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
103968
Message:

Audio: Introduced reference counting for guest audio streams; this should prevent that the audio connector interface is destroying streams which still are being used by other parties, e.g. the audio mixer (bugref:8054).

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

Legend:

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

    r58573 r58600  
    107107                     pSink->pszName, pMixStream, pSink->cStreams));
    108108
     109        /* Increase the stream's reference count to let others know
     110         * we're reyling on it to be around now. */
     111        pStream->State.cRefs++;
     112
    109113        if (ppStream)
    110114            *ppStream = pMixStream;
     
    145149                     pSink->pszName, pMixStream, pSink->cStreams));
    146150
     151        /* Increase the stream's reference count to let others know
     152         * we're reyling on it to be around now. */
     153        pStream->State.cRefs++;
     154
    147155        if (ppStream)
    148156            *ppStream = pMixStream;
     
    201209void AudioMixerDestroy(PAUDIOMIXER pMixer)
    202210{
    203     if (pMixer)
    204     {
    205         LogFlowFunc(("Destroying %s ...\n", pMixer->pszName));
    206 
    207         PAUDMIXSINK pSink = RTListGetFirst(&pMixer->lstSinks, AUDMIXSINK, Node);
    208         while (pSink)
    209         {
    210             PAUDMIXSINK pNext = RTListNodeGetNext(&pSink->Node, AUDMIXSINK, Node);
    211             bool fLast = RTListNodeIsLast(&pMixer->lstSinks, &pSink->Node);
    212 
    213             AudioMixerRemoveSink(pMixer, pSink);
    214 
    215             if (fLast)
    216                 break;
    217 
    218             pSink = pNext;
    219         }
    220 
    221         Assert(pMixer->cSinks == 0);
    222 
     211    if (!pMixer)
     212        return;
     213
     214    LogFlowFunc(("Destroying %s ...\n", pMixer->pszName));
     215
     216    PAUDMIXSINK pSink, pSinkNext;
     217    RTListForEachSafe(&pMixer->lstSinks, pSink, pSinkNext, AUDMIXSINK, Node)
     218        AudioMixerRemoveSink(pMixer, pSink);
     219
     220    Assert(pMixer->cSinks == 0);
     221
     222    if (pMixer->pszName)
     223    {
    223224        RTStrFree(pMixer->pszName);
    224 
    225         RTMemFree(pMixer);
    226     }
     225        pMixer->pszName = NULL;
     226    }
     227
     228    RTMemFree(pMixer);
    227229}
    228230
     
    233235        return;
    234236
    235     RTStrFree(pSink->pszName);
     237    if (pSink->pszName)
     238        RTStrFree(pSink->pszName);
    236239
    237240    RTMemFree(pSink);
     
    383386#endif
    384387
     388    /* Decrease the reference count again. */
     389    switch (pSink->enmDir)
     390    {
     391        case AUDMIXSINKDIR_INPUT:
     392        {
     393            Assert(pStream->pIn->State.cRefs);
     394            pStream->pIn->State.cRefs--;
     395            break;
     396        }
     397
     398        case AUDMIXSINKDIR_OUTPUT:
     399        {
     400            Assert(pStream->pOut->State.cRefs);
     401            pStream->pOut->State.cRefs--;
     402            break;
     403        }
     404
     405        default:
     406            AssertMsgFailed(("Not implemented\n"));
     407            break;
     408    }
     409
    385410    audioMixerDestroyStream(pStream);
    386411}
  • trunk/src/VBox/Devices/Audio/DevIchAc97.cpp

    r58443 r58600  
    555555                    }
    556556
    557                     rc = pDrv->pConnector->pfnOpenIn(pDrv->pConnector,
    558                                                      pszDesc, PDMAUDIORECSOURCE_LINE_IN, &streamCfg, &pDrv->LineIn.pStrmIn);
    559                     LogFlowFunc(("LUN#%RU8: Opened line input with rc=%Rrc\n", uLUN, rc));
     557                    rc = pDrv->pConnector->pfnCreateIn(pDrv->pConnector,
     558                                                       pszDesc, PDMAUDIORECSOURCE_LINE_IN, &streamCfg, &pDrv->LineIn.pStrmIn);
     559                    LogFlowFunc(("LUN#%RU8: Created line input with rc=%Rrc\n", uLUN, rc));
    560560                    if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    561561                    {
     
    583583                    }
    584584
    585                     rc = pDrv->pConnector->pfnOpenOut(pDrv->pConnector, pszDesc, &streamCfg, &pDrv->Out.pStrmOut);
    586                     LogFlowFunc(("LUN#%RU8: Opened output with rc=%Rrc\n", uLUN, rc));
     585                    rc = pDrv->pConnector->pfnCreateOut(pDrv->pConnector, pszDesc, &streamCfg, &pDrv->Out.pStrmOut);
     586                    LogFlowFunc(("LUN#%RU8: Created output with rc=%Rrc\n", uLUN, rc));
    587587                    if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    588588                    {
     
    610610                    }
    611611
    612                     rc = pDrv->pConnector->pfnOpenIn(pDrv->pConnector,
    613                                                      pszDesc, PDMAUDIORECSOURCE_MIC, &streamCfg, &pDrv->MicIn.pStrmIn);
    614                     LogFlowFunc(("LUN#%RU8: Opened mic input with rc=%Rrc\n", uLUN, rc));
     612                    rc = pDrv->pConnector->pfnCreateIn(pDrv->pConnector,
     613                                                       pszDesc, PDMAUDIORECSOURCE_MIC, &streamCfg, &pDrv->MicIn.pStrmIn);
     614                    LogFlowFunc(("LUN#%RU8: Created mic input with rc=%Rrc\n", uLUN, rc));
    615615                    if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    616616                    {
     
    642642                RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    643643                {
    644                     pDrv->pConnector->pfnCloseIn(pDrv->pConnector, pDrv->LineIn.pStrmIn);
     644                    pDrv->pConnector->pfnDestroyIn(pDrv->pConnector, pDrv->LineIn.pStrmIn);
    645645                    AudioMixerRemoveStream(pThis->pSinkLineIn, pDrv->LineIn.phStrmIn);
    646646
     
    657657                RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    658658                {
    659                     pDrv->pConnector->pfnCloseOut(pDrv->pConnector, pDrv->Out.pStrmOut);
     659                    pDrv->pConnector->pfnDestroyOut(pDrv->pConnector, pDrv->Out.pStrmOut);
    660660                    AudioMixerRemoveStream(pThis->pSinkOutput, pDrv->Out.phStrmOut);
    661661
     
    672672                RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    673673                {
    674                     pDrv->pConnector->pfnCloseIn(pDrv->pConnector, pDrv->MicIn.pStrmIn);
     674                    pDrv->pConnector->pfnDestroyIn(pDrv->pConnector, pDrv->MicIn.pStrmIn);
    675675                    AudioMixerRemoveStream(pThis->pSinkMicIn, pDrv->MicIn.phStrmIn);
    676676
     
    844844}
    845845
    846 static void ichac97MixerReset(PAC97STATE pThis)
    847 {
     846static int ichac97MixerReset(PAC97STATE pThis)
     847{
     848    AssertPtrReturn(pThis, VERR_INVALID_PARAMETER);
     849
    848850    LogFlowFuncEnter();
    849851
    850852    RT_ZERO(pThis->mixer_data);
     853
     854    /*
     855     * Tear down mixer and streams.
     856     */
     857    if (pThis->pMixer)
     858    {
     859        AudioMixerDestroy(pThis->pMixer);
     860        pThis->pMixer = NULL;
     861    }
     862
     863    pThis->pSinkLineIn = NULL;
     864    pThis->pSinkMicIn  = NULL;
     865    pThis->pSinkOutput = NULL;
    851866
    852867    PAC97DRIVER pDrv;
    853868    RTListForEach(&pThis->lstDrv, pDrv, AC97DRIVER, Node)
    854869    {
    855         pDrv->Out.phStrmOut   = NULL;
    856         pDrv->pConnector->pfnCloseOut(pDrv->pConnector, pDrv->Out.pStrmOut);
    857         pDrv->Out.pStrmOut    = NULL;
    858         pDrv->LineIn.phStrmIn = NULL;
    859         pDrv->pConnector->pfnCloseIn(pDrv->pConnector, pDrv->LineIn.pStrmIn);
    860         pDrv->LineIn.pStrmIn  = NULL;
    861         pDrv->MicIn.phStrmIn  = NULL;
    862         pDrv->pConnector->pfnCloseIn(pDrv->pConnector, pDrv->MicIn.pStrmIn);
    863         pDrv->MicIn.pStrmIn   = NULL;
    864     }
    865 
    866     pThis->pSinkOutput = NULL;
    867     pThis->pSinkLineIn = NULL;
    868     pThis->pSinkMicIn  = NULL;
    869 
    870     if (pThis->pMixer)
    871     {
    872         AudioMixerDestroy(pThis->pMixer);
    873         pThis->pMixer = NULL;
    874     }
    875 
    876     int rc2 = AudioMixerCreate("AC'97 Mixer", 0 /* uFlags */, &pThis->pMixer);
    877     if (RT_SUCCESS(rc2))
     870        pDrv->pConnector->pfnDestroyIn (pDrv->pConnector, pDrv->LineIn.pStrmIn);
     871        RT_ZERO(pDrv->LineIn);
     872
     873        pDrv->pConnector->pfnDestroyIn (pDrv->pConnector, pDrv->MicIn.pStrmIn);
     874        RT_ZERO(pDrv->MicIn);
     875
     876        pDrv->pConnector->pfnDestroyOut(pDrv->pConnector, pDrv->Out.pStrmOut);
     877        RT_ZERO(pDrv->Out);
     878    }
     879
     880    /*
     881     * (Re-)Create the mixer. The streams will be created on demand later.
     882     */
     883    int rc = AudioMixerCreate("AC'97 Mixer", 0 /* uFlags */, &pThis->pMixer);
     884    if (RT_FAILURE(rc))
     885        return rc;
     886
     887    do
    878888    {
    879889        /* Set a default audio format for our mixer. */
     
    884894        streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;
    885895
    886         rc2 = AudioMixerSetDeviceFormat(pThis->pMixer, &streamCfg);
    887         AssertRC(rc2);
     896        rc = AudioMixerSetDeviceFormat(pThis->pMixer, &streamCfg);
     897        if (RT_FAILURE(rc))
     898            break;
    888899
    889900        /* Add all required audio sinks. */
    890         rc2 = AudioMixerAddSink(pThis->pMixer, "[Playback] PCM Output",
    891                                AUDMIXSINKDIR_OUTPUT, &pThis->pSinkOutput);
    892         AssertRC(rc2);
    893 
    894         rc2 = AudioMixerAddSink(pThis->pMixer, "[Recording] Line In",
    895                                 AUDMIXSINKDIR_INPUT, &pThis->pSinkLineIn);
    896         AssertRC(rc2);
    897 
    898         rc2 = AudioMixerAddSink(pThis->pMixer, "[Recording] Microphone In",
    899                                 AUDMIXSINKDIR_INPUT, &pThis->pSinkMicIn);
    900         AssertRC(rc2);
    901     }
     901        rc = AudioMixerAddSink(pThis->pMixer, "[Playback] PCM Output", AUDMIXSINKDIR_OUTPUT, &pThis->pSinkOutput);
     902        if (RT_FAILURE(rc))
     903            break;
     904
     905        rc = AudioMixerAddSink(pThis->pMixer, "[Recording] Line In", AUDMIXSINKDIR_INPUT, &pThis->pSinkLineIn);
     906        if (RT_FAILURE(rc))
     907            break;
     908
     909        rc = AudioMixerAddSink(pThis->pMixer, "[Recording] Microphone In", AUDMIXSINKDIR_INPUT, &pThis->pSinkMicIn);
     910        if (RT_FAILURE(rc))
     911            break;
     912
     913    } while (0);
     914
     915    /* Note: Make sure to reset all registers first before bailing out on error. */
    902916
    903917    ichac97MixerStore(pThis, AC97_Reset                   , 0x0000); /* 6940 */
     
    951965    uint8_t active[LAST_INDEX] = { 0 };
    952966    ichac97ResetStreams(pThis, active);
     967
     968    return rc;
    953969}
    954970
     
    19461962    if (pThis->uCodecModel == Codec_AD1980)
    19471963        if (ichac97MixerLoad(pThis, AC97_AD_Misc) & AD_MISC_HPSEL)
    1948             ichac97SetVolume(pThis, AC97_Headphone_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME, 
     1964            ichac97SetVolume(pThis, AC97_Headphone_Volume_Mute, PDMAUDIOMIXERCTL_VOLUME,
    19491965                             ichac97MixerLoad(pThis, AC97_Headphone_Volume_Mute));
    19501966
     
    22622278        AssertPtr(pCon);
    22632279        if (   !pCon->pfnIsInputOK (pCon, pDrv->LineIn.pStrmIn)
    2264             && !pCon->pfnIsOutputOK(pCon, pDrv->Out.pStrmOut)
    2265             && !pCon->pfnIsInputOK (pCon, pDrv->MicIn.pStrmIn))
    2266         {
    2267             LogRel(("AC97: Falling back to NULL driver\n"));
     2280            && !pCon->pfnIsInputOK (pCon, pDrv->MicIn.pStrmIn)
     2281            && !pCon->pfnIsOutputOK(pCon, pDrv->Out.pStrmOut))
     2282        {
     2283            LogRel(("AC97: Falling back to NULL driver (no sound audible)\n"));
     2284
     2285            ac97Reset(pDevIns);
    22682286
    22692287            /* Was not able initialize *any* stream.
    22702288             * Select the NULL audio driver instead. */
    2271             pCon->pfnCloseIn (pCon, pDrv->LineIn.pStrmIn);
    2272             pCon->pfnCloseOut(pCon, pDrv->Out.pStrmOut);
    2273             pCon->pfnCloseIn (pCon, pDrv->MicIn.pStrmIn);
    2274 
    2275             pDrv->Out.pStrmOut = NULL;
    2276             pDrv->LineIn.pStrmIn = NULL;
    2277             pDrv->MicIn.pStrmIn = NULL;
    2278 
    22792289            pCon->pfnInitNull(pCon);
    2280             ac97Reset(pDevIns);
    22812290
    22822291            PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "HostAudioNotResponding",
     
    22852294        }
    22862295        else if (   !pCon->pfnIsInputOK (pCon, pDrv->LineIn.pStrmIn)
    2287                  || !pCon->pfnIsOutputOK(pCon, pDrv->Out.pStrmOut)
    2288                  || !pCon->pfnIsInputOK (pCon, pDrv->MicIn.pStrmIn))
     2296                 || !pCon->pfnIsInputOK (pCon, pDrv->MicIn.pStrmIn)
     2297                 || !pCon->pfnIsOutputOK(pCon, pDrv->Out.pStrmOut))
    22892298        {
    22902299            char   szMissingStreams[255];
  • trunk/src/VBox/Devices/Audio/DevIchHda.cpp

    r58170 r58600  
    23032303}
    23042304
    2305 static DECLCALLBACK(void) hdaCloseIn(PHDASTATE pThis, PDMAUDIORECSOURCE enmRecSource)
     2305static DECLCALLBACK(void) hdaDestroyIn(PHDASTATE pThis, PDMAUDIORECSOURCE enmRecSource)
    23062306{
    23072307    NOREF(pThis);
     
    23102310}
    23112311
    2312 static DECLCALLBACK(void) hdaCloseOut(PHDASTATE pThis)
     2312static DECLCALLBACK(void) hdaDestroyOut(PHDASTATE pThis)
    23132313{
    23142314    NOREF(pThis);
     
    23162316}
    23172317
    2318 static DECLCALLBACK(int) hdaOpenIn(PHDASTATE pThis,
    2319                                    const char *pszName, PDMAUDIORECSOURCE enmRecSource,
    2320                                    PPDMAUDIOSTREAMCFG pCfg)
     2318static DECLCALLBACK(int) hdaCreateIn(PHDASTATE pThis,
     2319                                     const char *pszName, PDMAUDIORECSOURCE enmRecSource,
     2320                                     PPDMAUDIOSTREAMCFG pCfg)
    23212321{
    23222322    PAUDMIXSINK pSink;
     
    23492349        }
    23502350
    2351         rc = pDrv->pConnector->pfnOpenIn(pDrv->pConnector, pszDesc, enmRecSource, pCfg, &pDrv->LineIn.pStrmIn);
    2352         LogFlowFunc(("LUN#%RU8: Opened input \"%s\", with rc=%Rrc\n", pDrv->uLUN, pszDesc, rc));
     2351        rc = pDrv->pConnector->pfnCreateIn(pDrv->pConnector, pszDesc, enmRecSource, pCfg, &pDrv->LineIn.pStrmIn);
     2352        LogFlowFunc(("LUN#%RU8: Created input \"%s\", with rc=%Rrc\n", pDrv->uLUN, pszDesc, rc));
    23532353        if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    23542354        {
     
    23662366}
    23672367
    2368 static DECLCALLBACK(int) hdaOpenOut(PHDASTATE pThis,
    2369                                     const char *pszName, PPDMAUDIOSTREAMCFG pCfg)
     2368static DECLCALLBACK(int) hdaCreateOut(PHDASTATE pThis,
     2369                                      const char *pszName, PPDMAUDIOSTREAMCFG pCfg)
    23702370{
    23712371    int rc = VINF_SUCCESS;
     
    23812381        }
    23822382
    2383         rc = pDrv->pConnector->pfnOpenOut(pDrv->pConnector, pszDesc, pCfg, &pDrv->Out.pStrmOut);
    2384         LogFlowFunc(("LUN#%RU8: Opened output \"%s\", with rc=%Rrc\n", pDrv->uLUN, pszDesc, rc));
     2383        rc = pDrv->pConnector->pfnCreateOut(pDrv->pConnector, pszDesc, pCfg, &pDrv->Out.pStrmOut);
     2384        LogFlowFunc(("LUN#%RU8: Created output \"%s\", with rc=%Rrc\n", pDrv->uLUN, pszDesc, rc));
    23852385        if (rc == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    23862386        {
     
    37613761
    37623762        /* Audio driver callbacks for multiplexing. */
    3763         pThis->pCodec->pfnCloseIn   = hdaCloseIn;
    3764         pThis->pCodec->pfnCloseOut  = hdaCloseOut;
    3765         pThis->pCodec->pfnOpenIn    = hdaOpenIn;
    3766         pThis->pCodec->pfnOpenOut   = hdaOpenOut;
    3767         pThis->pCodec->pfnReset     = hdaCodecReset;
    3768         pThis->pCodec->pfnSetVolume = hdaSetVolume;
     3763        pThis->pCodec->pfnDestroyIn  = hdaDestroyIn;
     3764        pThis->pCodec->pfnDestroyOut = hdaDestroyOut;
     3765        pThis->pCodec->pfnCreateIn   = hdaCreateIn;
     3766        pThis->pCodec->pfnCreateOut  = hdaCreateOut;
     3767        pThis->pCodec->pfnReset      = hdaCodecReset;
     3768        pThis->pCodec->pfnSetVolume  = hdaSetVolume;
    37693769
    37703770        pThis->pCodec->pHDAState = pThis; /* Assign HDA controller state to codec. */
  • trunk/src/VBox/Devices/Audio/DevIchHdaCodec.cpp

    r57393 r58600  
    26112611    {
    26122612        case PI_INDEX:
    2613             rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.in", PDMAUDIORECSOURCE_LINE_IN, pCfg);
     2613            rc = pThis->pfnCreateIn(pThis->pHDAState, "hda.in", PDMAUDIORECSOURCE_LINE_IN, pCfg);
    26142614            break;
    26152615
    26162616        case PO_INDEX:
    2617             rc = pThis->pfnOpenOut(pThis->pHDAState, "hda.out", pCfg);
     2617            rc = pThis->pfnCreateOut(pThis->pHDAState, "hda.out", pCfg);
    26182618            break;
    26192619
    26202620#ifdef VBOX_WITH_HDA_MIC_IN
    26212621        case MC_INDEX:
    2622             rc = pThis->pfnOpenIn(pThis->pHDAState, "hda.mc", PDMAUDIORECSOURCE_MIC, pCfg);
     2622            rc = pThis->pfnCreateIn(pThis->pHDAState, "hda.mc", PDMAUDIORECSOURCE_MIC, pCfg);
    26232623            break;
    26242624#endif
  • trunk/src/VBox/Devices/Audio/DevIchHdaCodec.h

    r58132 r58600  
    111111#endif
    112112    /** Callbacks to the HDA controller, mostly used for multiplexing to the various host backends. */
    113     DECLR3CALLBACKMEMBER(void, pfnCloseIn, (PHDASTATE pThis, PDMAUDIORECSOURCE enmRecSource));
    114     DECLR3CALLBACKMEMBER(void, pfnCloseOut, (PHDASTATE pThis));
    115     DECLR3CALLBACKMEMBER(int, pfnOpenIn, (PHDASTATE pThis, const char *pszName, PDMAUDIORECSOURCE enmRecSource, PPDMAUDIOSTREAMCFG pCfg));
    116     DECLR3CALLBACKMEMBER(int, pfnOpenOut, (PHDASTATE pThis, const char *pszName, PPDMAUDIOSTREAMCFG pCfg));
     113    DECLR3CALLBACKMEMBER(void, pfnDestroyIn, (PHDASTATE pThis, PDMAUDIORECSOURCE enmRecSource));
     114    DECLR3CALLBACKMEMBER(void, pfnDestroyOut, (PHDASTATE pThis));
     115    DECLR3CALLBACKMEMBER(int, pfnCreateIn, (PHDASTATE pThis, const char *pszName, PDMAUDIORECSOURCE enmRecSource, PPDMAUDIOSTREAMCFG pCfg));
     116    DECLR3CALLBACKMEMBER(int, pfnCreateOut, (PHDASTATE pThis, const char *pszName, PPDMAUDIOSTREAMCFG pCfg));
    117117    DECLR3CALLBACKMEMBER(int, pfnSetVolume, (PHDASTATE pThis, ENMSOUNDSOURCE enmSource, bool fMute, uint8_t uVolLeft, uint8_t uVolRight));
    118118    /** Callbacks by codec implementation. */
  • trunk/src/VBox/Devices/Audio/DevSB16.cpp

    r56838 r58600  
    19461946        }
    19471947
    1948         int rc2 = pDrv->pConnector->pfnOpenOut(pDrv->pConnector, pszDesc, pCfg, &pDrv->Out.pStrmOut);
    1949         LogFlowFunc(("LUN#%RU8: Opened output with rc=%Rrc\n", uLUN, rc));
     1948        int rc2 = pDrv->pConnector->pfnCreateOut(pDrv->pConnector, pszDesc, pCfg, &pDrv->Out.pStrmOut);
     1949        LogFlowFunc(("LUN#%RU8: Created output with rc=%Rrc\n", uLUN, rc));
    19501950        if (rc2 == VINF_SUCCESS) /* Note: Could return VWRN_ALREADY_EXISTS. */
    19511951        {
     
    21932193            LogRel(("SB16: Warning: Unable to enable/use output for LUN#%RU8\n", uLUN));
    21942194
    2195             pCon->pfnCloseOut(pCon, pDrv->Out.pStrmOut);
     2195            pCon->pfnDestroyOut(pCon, pDrv->Out.pStrmOut);
    21962196            pDrv->Out.pStrmOut = NULL;
    21972197
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r58378 r58600  
    574574    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
    575575
    576     if (pGstStrmOut)
    577     {
    578         drvAudioGstOutFreeRes(pGstStrmOut);
    579 
    580         if (pGstStrmOut->pHstStrmOut)
    581         {
    582             /* Unregister from parent first. */
    583             RTListNodeRemove(&pGstStrmOut->Node);
    584 
    585             /* Try destroying the associated host output stream. This could
    586              * be skipped if there are other guest output streams with this
    587              * host stream. */
    588             drvAudioDestroyHstOut(pThis, pGstStrmOut->pHstStrmOut);
    589         }
    590 
    591         RTMemFree(pGstStrmOut);
    592     }
     576    if (!pGstStrmOut)
     577        return VINF_SUCCESS;
     578
     579    if (pGstStrmOut->State.cRefs > 1) /* Do other objects still have a reference to it? Bail out. */
     580        return VERR_WRONG_ORDER;
     581
     582    drvAudioGstOutFreeRes(pGstStrmOut);
     583
     584    if (pGstStrmOut->pHstStrmOut)
     585    {
     586        /* Unregister from parent first. */
     587        RTListNodeRemove(&pGstStrmOut->Node);
     588
     589        /* Try destroying the associated host output stream. This could
     590         * be skipped if there are other guest output streams with this
     591         * host stream. */
     592        drvAudioDestroyHstOut(pThis, pGstStrmOut->pHstStrmOut);
     593    }
     594
     595    RTMemFree(pGstStrmOut);
    593596
    594597    return VINF_SUCCESS;
     
    666669        if (RT_SUCCESS(rc))
    667670        {
     671            pGstStrmOut->State.cRefs   = 1;
    668672            pGstStrmOut->State.fActive = false;
    669673            pGstStrmOut->State.fEmpty  = true;
     
    921925            drvAudioStreamCfgPrint(pCfg);
    922926#endif
     927            pGstStrmIn->State.cRefs   = 1;
    923928            pGstStrmIn->State.fActive = false;
    924929            pGstStrmIn->State.fEmpty  = true;
     
    11581163    LogFlowFunc(("%s\n", pGstStrmIn->MixBuf.pszName));
    11591164
    1160     if (pGstStrmIn)
    1161     {
    1162         drvAudioGstInFreeRes(pGstStrmIn);
    1163 
    1164         if (pGstStrmIn->pHstStrmIn)
    1165         {
    1166             /* Unlink child. */
    1167             pGstStrmIn->pHstStrmIn->pGstStrmIn = NULL;
    1168 
    1169             /* Try destroying the associated host input stream. This could
    1170              * be skipped if there are other guest input streams with this
    1171              * host stream. */
    1172             drvAudioDestroyHstIn(pThis, pGstStrmIn->pHstStrmIn);
    1173         }
    1174 
    1175         RTMemFree(pGstStrmIn);
    1176     }
     1165    if (!pGstStrmIn)
     1166        return VINF_SUCCESS;
     1167
     1168    if (pGstStrmIn->State.cRefs > 1) /* Do other objects still have a reference to it? Bail out. */
     1169        return VERR_WRONG_ORDER;
     1170
     1171    drvAudioGstInFreeRes(pGstStrmIn);
     1172
     1173    if (pGstStrmIn->pHstStrmIn)
     1174    {
     1175        /* Unlink child. */
     1176        pGstStrmIn->pHstStrmIn->pGstStrmIn = NULL;
     1177
     1178        /* Try destroying the associated host input stream. This could
     1179         * be skipped if there are other guest input streams with this
     1180         * host stream. */
     1181        drvAudioDestroyHstIn(pThis, pGstStrmIn->pHstStrmIn);
     1182    }
     1183
     1184    RTMemFree(pGstStrmIn);
    11771185
    11781186    return VINF_SUCCESS;
     
    17201728}
    17211729
    1722 static DECLCALLBACK(int) drvAudioOpenIn(PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
    1723                                         PDMAUDIORECSOURCE enmRecSource, PPDMAUDIOSTREAMCFG pCfg,
    1724                                         PPDMAUDIOGSTSTRMIN *ppGstStrmIn)
     1730static DECLCALLBACK(int) drvAudioCreateIn(PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
     1731                                          PDMAUDIORECSOURCE enmRecSource, PPDMAUDIOSTREAMCFG pCfg,
     1732                                          PPDMAUDIOGSTSTRMIN *ppGstStrmIn)
    17251733{
    17261734    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    17861794}
    17871795
    1788 static DECLCALLBACK(int) drvAudioOpenOut(PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
    1789                                          PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOGSTSTRMOUT *ppGstStrmOut)
     1796static DECLCALLBACK(int) drvAudioCreateOut(PPDMIAUDIOCONNECTOR pInterface, const char *pszName,
     1797                                           PPDMAUDIOSTREAMCFG pCfg, PPDMAUDIOGSTSTRMOUT *ppGstStrmOut)
    17901798{
    17911799    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    18911899}
    18921900
    1893 static DECLCALLBACK(void) drvAudioCloseIn(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMIN pGstStrmIn)
     1901static DECLCALLBACK(void) drvAudioDestroyIn(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMIN pGstStrmIn)
    18941902{
    18951903    PDRVAUDIO pThis = PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface);
     
    18981906}
    18991907
    1900 static DECLCALLBACK(void) drvAudioCloseOut(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut)
     1908static DECLCALLBACK(void) drvAudioDestroyOut(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOGSTSTRMOUT pGstStrmOut)
    19011909{
    19021910    PDRVAUDIO pThis = PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface);
     
    19821990    pThis->IAudioConnector.pfnRead                   = drvAudioRead;
    19831991    pThis->IAudioConnector.pfnWrite                  = drvAudioWrite;
     1992    pThis->IAudioConnector.pfnIsActiveIn             = drvAudioIsActiveIn;
     1993    pThis->IAudioConnector.pfnIsActiveOut            = drvAudioIsActiveOut;
    19841994    pThis->IAudioConnector.pfnIsInputOK              = drvAudioIsInputOK;
    19851995    pThis->IAudioConnector.pfnIsOutputOK             = drvAudioIsOutputOK;
     
    19871997    pThis->IAudioConnector.pfnEnableOut              = drvAudioEnableOut;
    19881998    pThis->IAudioConnector.pfnEnableIn               = drvAudioEnableIn;
    1989     pThis->IAudioConnector.pfnCloseIn                = drvAudioCloseIn;
    1990     pThis->IAudioConnector.pfnCloseOut               = drvAudioCloseOut;
    1991     pThis->IAudioConnector.pfnOpenIn                 = drvAudioOpenIn;
    1992     pThis->IAudioConnector.pfnOpenOut                = drvAudioOpenOut;
     1999    pThis->IAudioConnector.pfnDestroyIn              = drvAudioDestroyIn;
     2000    pThis->IAudioConnector.pfnDestroyOut             = drvAudioDestroyOut;
     2001    pThis->IAudioConnector.pfnCreateIn               = drvAudioCreateIn;
     2002    pThis->IAudioConnector.pfnCreateOut              = drvAudioCreateOut;
    19932003    pThis->IAudioConnector.pfnPlayOut                = drvAudioPlayOut;
    1994     pThis->IAudioConnector.pfnIsActiveIn             = drvAudioIsActiveIn;
    1995     pThis->IAudioConnector.pfnIsActiveOut            = drvAudioIsActiveOut;
    19962004
    19972005    /*
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