VirtualBox

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


Ignore:
Timestamp:
Mar 25, 2015 3:01:04 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99189
Message:

DrvAudio.cpp: Guest/Host audio stream tagging.

File:
1 edited

Legend:

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

    r54491 r54941  
    7373static int drvAudioDestroyGstIn(PDRVAUDIO pThis, PPDMAUDIOGSTSTRMIN pGstStrmIn);
    7474
    75 static int drvAudioAllocHstIn(PDRVAUDIO pThis, PPDMAUDIOSTREAMCFG pCfg, PDMAUDIORECSOURCE enmRecSource, PPDMAUDIOHSTSTRMIN *ppHstStrmIn);
     75static int drvAudioAllocHstIn(PDRVAUDIO pThis, const char *pszName, PPDMAUDIOSTREAMCFG pCfg, PDMAUDIORECSOURCE enmRecSource, PPDMAUDIOHSTSTRMIN *ppHstStrmIn);
    7676static int drvAudioDestroyHstIn(PDRVAUDIO pThis, PPDMAUDIOHSTSTRMIN pHstStrmIn);
    7777
     
    479479}
    480480
    481 static int drvAudioHstInAdd(PDRVAUDIO pThis, PPDMAUDIOSTREAMCFG pCfg, PDMAUDIORECSOURCE enmRecSource,
     481static int drvAudioHstInAdd(PDRVAUDIO pThis, const char *pszName, PPDMAUDIOSTREAMCFG pCfg, PDMAUDIORECSOURCE enmRecSource,
    482482                            PPDMAUDIOHSTSTRMIN *ppHstStrmIn)
    483483{
     
    487487
    488488    PPDMAUDIOHSTSTRMIN pHstStrmIn;
    489     int rc = drvAudioAllocHstIn(pThis, pCfg, enmRecSource, &pHstStrmIn);
     489    int rc = drvAudioAllocHstIn(pThis, pszName, pCfg, enmRecSource, &pHstStrmIn);
    490490    if (RT_SUCCESS(rc))
    491491        *ppHstStrmIn = pHstStrmIn;
     
    501501    if (RT_SUCCESS(rc))
    502502    {
    503         rc = audioMixBufInit(&pGstStrmOut->MixBuf, pszName, &pGstStrmOut->Props,
     503        char *pszTemp;
     504        if (RTStrAPrintf(&pszTemp, "%s (Guest)", pszName) <= 0)
     505            return VERR_NO_MEMORY;
     506
     507        rc = audioMixBufInit(&pGstStrmOut->MixBuf, pszTemp, &pGstStrmOut->Props,
    504508                             audioMixBufSize(&pHostStrmOut->MixBuf));
    505509        if (RT_SUCCESS(rc))
    506510            rc = audioMixBufLinkTo(&pGstStrmOut->MixBuf, &pHostStrmOut->MixBuf);
    507511
     512        RTStrFree(pszTemp);
     513
    508514        if (RT_SUCCESS(rc))
    509515        {
     
    542548    }
    543549
    544     PPDMAUDIOHSTSTRMOUT pHstStrmOut =
    545         (PPDMAUDIOHSTSTRMOUT)RTMemAllocZ(pThis->BackendCfg.cbStreamOut);
     550    PPDMAUDIOHSTSTRMOUT pHstStrmOut = (PPDMAUDIOHSTSTRMOUT)RTMemAllocZ(pThis->BackendCfg.cbStreamOut);
    546551    if (!pHstStrmOut)
    547552    {
     
    559564
    560565        uint32_t cSamples;
    561         rc = pThis->pHostDrvAudio->pfnInitOut(pThis->pHostDrvAudio, pHstStrmOut, pCfg,
    562                                               &cSamples);
     566        rc = pThis->pHostDrvAudio->pfnInitOut(pThis->pHostDrvAudio, pHstStrmOut, pCfg, &cSamples);
    563567        if (RT_FAILURE(rc))
    564568        {
     
    569573        fInitialized = true;
    570574
    571         rc = audioMixBufInit(&pHstStrmOut->MixBuf, pszName, &pHstStrmOut->Props, cSamples);
     575        char *pszTemp;
     576        if (RTStrAPrintf(&pszTemp, "%s (Host)", pszName) <= 0)
     577        {
     578            rc = VERR_NO_MEMORY;
     579            break;
     580        }
     581
     582        rc = audioMixBufInit(&pHstStrmOut->MixBuf, pszTemp, &pHstStrmOut->Props, cSamples);
    572583        if (RT_SUCCESS(rc))
    573584        {
     
    576587        }
    577588
     589        RTStrFree(pszTemp);
     590
    578591    } while (0);
    579592
     
    582595        if (fInitialized)
    583596        {
    584             int rc2 = pThis->pHostDrvAudio->pfnFiniOut(pThis->pHostDrvAudio,
    585                                                        pHstStrmOut);
     597            int rc2 = pThis->pHostDrvAudio->pfnFiniOut(pThis->pHostDrvAudio, pHstStrmOut);
    586598            AssertRC(rc2);
    587599        }
     
    665677    AssertPtrReturn(pThisCfg, VERR_INVALID_POINTER);
    666678
    667     PPDMAUDIOGSTSTRMIN pGstStrmIn =
    668         (PPDMAUDIOGSTSTRMIN)RTMemAllocZ(sizeof(PDMAUDIOGSTSTRMIN));
     679    PPDMAUDIOGSTSTRMIN pGstStrmIn = (PPDMAUDIOGSTSTRMIN)RTMemAllocZ(sizeof(PDMAUDIOGSTSTRMIN));
    669680    if (!pGstStrmIn)
    670681        return VERR_NO_MEMORY;
    671682
     683
    672684    PPDMAUDIOHSTSTRMIN pHstStrmIn;
    673     int rc = drvAudioHstInAdd(pThis, pThisCfg, enmRecSource, &pHstStrmIn);
     685    int rc = drvAudioHstInAdd(pThis, pszName, pThisCfg, enmRecSource, &pHstStrmIn);
    674686    if (RT_FAILURE(rc))
    675687    {
    676         LogFunc(("Failed to add host audio input stream \"%s\", rc=%Rrc\n",
    677                  pszName, rc));
     688        LogFunc(("Failed to add host audio input stream \"%s\", rc=%Rrc\n", pszName, rc));
    678689
    679690        RTMemFree(pGstStrmIn);
     
    717728    if (RT_SUCCESS(rc))
    718729    {
    719         rc = audioMixBufInit(&pGstStrmIn->MixBuf, pszName, &pHstStrmIn->Props,
     730        char *pszTemp;
     731        if (RTStrAPrintf(&pszTemp, "%s (Guest)", pszName) <= 0)
     732            return VERR_NO_MEMORY;
     733
     734        rc = audioMixBufInit(&pGstStrmIn->MixBuf, pszTemp, &pHstStrmIn->Props,
    720735                             audioMixBufSize(&pHstStrmIn->MixBuf));
    721736        if (RT_SUCCESS(rc))
    722737            rc = audioMixBufLinkTo(&pHstStrmIn->MixBuf, &pGstStrmIn->MixBuf);
    723738
     739        RTStrFree(pszTemp);
     740
    724741        if (RT_SUCCESS(rc))
    725742        {
    726     #ifdef DEBUG
     743#ifdef DEBUG
    727744            drvAudioStreamCfgPrint(pCfg);
    728     #endif
     745#endif
    729746            pGstStrmIn->State.fActive = false;
    730747            pGstStrmIn->State.fEmpty  = true;
     
    742759}
    743760
    744 static int drvAudioAllocHstIn(PDRVAUDIO pThis, PPDMAUDIOSTREAMCFG pCfg,
     761static int drvAudioAllocHstIn(PDRVAUDIO pThis, const char *pszName, PPDMAUDIOSTREAMCFG pCfg,
    745762                              PDMAUDIORECSOURCE enmRecSource, PPDMAUDIOHSTSTRMIN *ppHstStrmIn)
    746763{
     
    783800        fInitialized = true;
    784801
    785         rc = audioMixBufInit(&pHstStrmIn->MixBuf, "HostIn", &pHstStrmIn->Props,
    786                              cSamples);
     802        char *pszTemp;
     803        if (RTStrAPrintf(&pszTemp, "%s (Host)", pszName) <= 0)
     804        {
     805            rc = VERR_NO_MEMORY;
     806            break;
     807        }
     808
     809        rc = audioMixBufInit(&pHstStrmIn->MixBuf, pszTemp, &pHstStrmIn->Props, cSamples);
    787810        if (RT_SUCCESS(rc))
    788811        {
     
    790813            pThis->cFreeInputStreams--;
    791814        }
     815
     816        RTStrFree(pszTemp);
    792817
    793818    } while (0);
     
    13821407            *pcbRead = 0;
    13831408        return VINF_SUCCESS;
    1384     } 
     1409    }
    13851410
    13861411    PPDMAUDIOHSTSTRMIN pHstStrmIn = pGstStrmIn->pHstStrmIn;
     
    16121637
    16131638        drvAudioGstInFreeRes(pGstStrmIn);
     1639
     1640        char *pszTemp;
     1641        if (RTStrAPrintf(&pszTemp, "%s (Guest)", pszName) <= 0)
     1642        {
     1643            RTMemFree(pGstStrmIn);
     1644            return VERR_NO_MEMORY;
     1645        }
     1646
    16141647        rc = drvAudioGstInInit(pGstStrmIn, pHstStrmIn, pszName, pCfg);
     1648
     1649        RTStrFree(pszTemp);
    16151650    }
    16161651    else
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