VirtualBox

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


Ignore:
Timestamp:
Aug 31, 2016 9:32:01 AM (8 years ago)
Author:
vboxsync
Message:

Audio/DrvAudio: Renamed drvAudioStreamDestroyInternal() -> drvAudioStreamUninitInternal() and made the stream destruction independent of that function. Added a couple more (verbose) release logging / assertions.

File:
1 edited

Legend:

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

    r63624 r63671  
    4444static int drvAudioStreamControlInternalBackend(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd);
    4545static int drvAudioStreamControlInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream, PDMAUDIOSTREAMCMD enmStreamCmd);
    46 static int drvAudioStreamDestroyInternalBackend(PDRVAUDIO pThis, PPDMAUDIOSTREAM pHstStream);
    47 static int drvAudioStreamDestroyInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream);
     46static int drvAudioStreamDestroyInBackendInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pHstStream);
     47static int drvAudioStreamUninitInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream);
    4848static int drvAudioStreamInitInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfgHost, PPDMAUDIOSTREAMCFG pCfgGuest);
    4949static int drvAudioStreamIterateInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream);
     
    150150    if (pHstStream)
    151151    {
    152         Assert(pHstStream->enmCtx == PDMAUDIOSTREAMCTX_HOST);
     152        AssertReleaseMsg(pHstStream->enmCtx == PDMAUDIOSTREAMCTX_HOST,
     153                         ("Stream '%s' resolved as host part is not marked as such (enmCtx=%RU32)\n",
     154                          pHstStream->szName, pHstStream->enmCtx));
     155
     156        AssertReleaseMsg(pHstStream->pPair != NULL,
     157                         ("Stream '%s' resolved as host part has no guest part (anymore)\n", pHstStream->szName));
    153158    }
    154159    else
    155         LogFlowFunc(("%s: Warning: Does not have a host stream (anymore)\n", pStream->szName));
     160        AssertReleaseMsgFailed(("Stream '%s' does not have a host pair (anymore)\n",
     161                                pStream->szName));
    156162
    157163    return pHstStream;
     
    528534    DrvAudioHlpStreamCfgPrint(pCfgHost);
    529535#else
     536    LogRel2(("Audio: Creating stream '%s'\n", pStream->szName));
    530537    LogRel2(("Audio: Requested %s host format for '%s': %RU32Hz, %s, %RU8 %s\n",
    531              pCfgGuest->enmDir == PDMAUDIODIR_IN ? "recording" : "playback",  pStream->szName,
     538             pCfgGuest->enmDir == PDMAUDIODIR_IN ? "recording" : "playback", pStream->szName,
    532539             pCfgHost->uHz, DrvAudioHlpAudFmtToStr(pCfgHost->enmFormat),
    533540             pCfgHost->cChannels, pCfgHost->cChannels == 0 ? "Channel" : "Channels"));
     
    538545    if (RT_FAILURE(rc))
    539546    {
    540         LogFlowFunc(("[%s] Initializing stream in host backend failed with rc=%Rrc\n", pStream->szName, rc));
     547        LogRel2(("Audio: Creating stream '%s' in backend failed with %Rrc\n", pStream->szName, rc));
    541548        return rc;
    542549    }
     
    639646    /* Make a copy of the host stream configuration. */
    640647    memcpy(&pGstStream->Cfg, pCfgGuest, sizeof(PDMAUDIOSTREAMCFG));
     648
     649    if (RT_FAILURE(rc))
     650        LogRel2(("Audio: Creating stream '%s' failed with %Rrc\n", pStream->szName, rc));
    641651
    642652    LogFlowFunc(("[%s] Returning %Rrc\n", pStream->szName, rc));
     
    14451455    AssertPtrReturn(pDrvIns,    VERR_INVALID_POINTER);
    14461456
     1457    LogRel2(("Audio: Verbose logging enabled\n"));
     1458
    14471459    PDRVAUDIO pThis = PDMINS_2_DATA(pDrvIns, PDRVAUDIO);
    14481460    LogFlowFunc(("pThis=%p, pDrvIns=%p\n", pThis, pDrvIns));
     
    16871699        if (pGstStrm)
    16881700        {
    1689             drvAudioStreamDestroyInternal(pThis, pGstStrm);
    1690             pGstStrm = NULL;
     1701            int rc2 = drvAudioStreamUninitInternal(pThis, pGstStrm);
     1702            if (RT_SUCCESS(rc2))
     1703            {
     1704                RTMemFree(pGstStrm);
     1705                pGstStrm = NULL;
     1706            }
    16911707        }
    16921708
    16931709        if (pHstStrm)
    16941710        {
    1695             drvAudioStreamDestroyInternal(pThis, pHstStrm);
    1696             pHstStrm = NULL;
     1711            int rc2 = drvAudioStreamUninitInternal(pThis, pHstStrm);
     1712            if (RT_SUCCESS(rc2))
     1713            {
     1714                RTMemFree(pHstStrm);
     1715                pHstStrm = NULL;
     1716            }
    16971717        }
    16981718    }
     
    19461966        PPDMAUDIOSTREAM pGstStream = pHstStream ? pHstStream->pPair : pStream;
    19471967
    1948         LogFlowFunc(("\tHost : %s\n", pHstStream ? pHstStream->szName : "<None>"));
    1949         LogFlowFunc(("\tGuest: %s\n", pGstStream ? pGstStream->szName : "<None>"));
     1968        LogRel2(("Audio: Destroying host stream '%s' (guest stream '%s')\n",
     1969                 pHstStream ? pHstStream->szName : "<None>",
     1970                 pGstStream ? pGstStream->szName : "<None>"));
    19501971
    19511972        /* Should prevent double frees. */
     
    19541975        if (pHstStream)
    19551976        {
    1956             pHstStream->pPair = NULL;
    1957             RTListNodeRemove(&pHstStream->Node);
    1958         }
    1959 
    1960         if (pGstStream)
    1961         {
    1962             pGstStream->pPair = NULL;
    1963             RTListNodeRemove(&pGstStream->Node);
    1964         }
    1965 
    1966         if (pHstStream)
    1967         {
    1968             rc = drvAudioStreamDestroyInternal(pThis, pHstStream);
    1969             AssertRC(rc);
    1970 
    1971             pHstStream = NULL;
    1972         }
    1973 
    1974         if (pGstStream)
    1975         {
    1976             rc = drvAudioStreamDestroyInternal(pThis, pGstStream);
    1977             AssertRC(rc);
    1978 
    1979             pGstStream = NULL;
     1977            rc = drvAudioStreamUninitInternal(pThis, pHstStream);
     1978            if (RT_SUCCESS(rc))
     1979            {
     1980                RTListNodeRemove(&pHstStream->Node);
     1981
     1982                RTMemFree(pHstStream);
     1983                pHstStream = NULL;
     1984            }
     1985            else
     1986                LogRel2(("Audio: Uninitializing host stream '%s' failed with %Rrc\n", pHstStream->szName, rc));
     1987        }
     1988
     1989        if (   RT_SUCCESS(rc)
     1990            && pGstStream)
     1991        {
     1992            rc = drvAudioStreamUninitInternal(pThis, pGstStream);
     1993            if (RT_SUCCESS(rc))
     1994            {
     1995                RTListNodeRemove(&pGstStream->Node);
     1996
     1997                RTMemFree(pGstStream);
     1998                pGstStream = NULL;
     1999            }
     2000            else
     2001                LogRel2(("Audio: Uninitializing guest stream '%s' failed with %Rrc\n", pGstStream->szName, rc));
    19802002        }
    19812003    }
     
    20082030 * @param   pHstStream          Host audio stream to call the backend destruction for.
    20092031 */
    2010 static int drvAudioStreamDestroyInternalBackend(PDRVAUDIO pThis, PPDMAUDIOSTREAM pHstStream)
     2032static int drvAudioStreamDestroyInBackendInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pHstStream)
    20112033{
    20122034    AssertPtrReturn(pThis,      VERR_INVALID_POINTER);
     
    20352057
    20362058/**
    2037  * Destroys an audio stream.
     2059 * Uninitializes an audio stream.
    20382060 *
    20392061 * @returns IPRT status code.
    20402062 * @param   pThis               Pointer to driver instance.
    2041  * @param   pStream             Pointer to audio stream to destroy.
    2042  *                              That pointer will be invalid after successful destruction.
    2043  */
    2044 static int drvAudioStreamDestroyInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream)
     2063 * @param   pStream             Pointer to audio stream to uninitialize.
     2064 */
     2065static int drvAudioStreamUninitInternal(PDRVAUDIO pThis, PPDMAUDIOSTREAM pStream)
    20452066{
    20462067    AssertPtrReturn(pThis,   VERR_INVALID_POINTER);
     
    20802101    else if (pStream->enmCtx == PDMAUDIOSTREAMCTX_HOST)
    20812102    {
    2082         rc = drvAudioStreamDestroyInternalBackend(pThis, pStream);
     2103        rc = drvAudioStreamDestroyInBackendInternal(pThis, pStream);
    20832104
    20842105        if (pStream->enmDir == PDMAUDIODIR_IN)
     
    21002121    if (RT_SUCCESS(rc))
    21012122    {
     2123        /* Make sure that the pair (if any) knows that we're not valid anymore. */
     2124        if (pStream->pPair)
     2125            pStream->pPair->pPair = NULL;
     2126
     2127        /* Reset status. */
     2128        pStream->fStatus = PDMAUDIOSTRMSTS_FLAG_NONE;
     2129
     2130        /* Clear name. */
     2131        pStream->szName[0] = '\0';
     2132
    21022133        /* Destroy mixing buffer. */
    21032134        AudioMixBufDestroy(&pStream->MixBuf);
    2104 
    2105         if (pStream)
    2106         {
    2107             RTMemFree(pStream);
    2108             pStream = NULL;
    2109         }
    21102135    }
    21112136
     
    21482173    PPDMAUDIOSTREAM pStream;
    21492174    RTListForEach(&pThis->lstHstStreams, pStream, PDMAUDIOSTREAM, Node)
    2150         drvAudioStreamDestroyInternalBackend(pThis, pStream);
     2175        drvAudioStreamDestroyInBackendInternal(pThis, pStream);
    21512176
    21522177    /*
     
    22832308    PPDMAUDIOSTREAM pStream, pStreamNext;
    22842309    RTListForEachSafe(&pThis->lstHstStreams, pStream, pStreamNext, PDMAUDIOSTREAM, Node)
    2285         drvAudioStreamDestroyInternal(pThis, pStream);
     2310    {
     2311        rc2 = drvAudioStreamUninitInternal(pThis, pStream);
     2312        if (RT_SUCCESS(rc2))
     2313        {
     2314            RTListNodeRemove(&pStream->Node);
     2315
     2316            RTMemFree(pStream);
     2317            pStream = NULL;
     2318        }
     2319    }
     2320
     2321    /* Sanity. */
     2322    Assert(RTListIsEmpty(&pThis->lstHstStreams));
    22862323
    22872324    RTListForEachSafe(&pThis->lstGstStreams, pStream, pStreamNext, PDMAUDIOSTREAM, Node)
    2288         drvAudioStreamDestroyInternal(pThis, pStream);
     2325    {
     2326        rc2 = drvAudioStreamUninitInternal(pThis, pStream);
     2327        if (RT_SUCCESS(rc2))
     2328        {
     2329            RTListNodeRemove(&pStream->Node);
     2330
     2331            RTMemFree(pStream);
     2332            pStream = NULL;
     2333        }
     2334    }
     2335
     2336    /* Sanity. */
     2337    Assert(RTListIsEmpty(&pThis->lstGstStreams));
    22892338
    22902339#ifdef VBOX_WITH_AUDIO_CALLBACKS
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