VirtualBox

Ignore:
Timestamp:
May 24, 2016 3:26:06 PM (9 years ago)
Author:
vboxsync
Message:

Audio: Implemented ability to specify two different audio formats via PDMIAUDIOCONNECTOR::CreateStream, renamed AudioMixerCreateStream() to AudioMixerSinkCreateStream().

File:
1 edited

Legend:

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

    r61157 r61166  
    105105}
    106106
    107 int AudioMixerCreateStream(PAUDIOMIXER pMixer,
    108                            PPDMIAUDIOCONNECTOR pConn, PPDMAUDIOSTREAMCFG pCfg, uint32_t fFlags, PAUDMIXSTREAM *ppStream)
    109 {
    110     AssertPtrReturn(pMixer, VERR_INVALID_POINTER);
    111     AssertPtrReturn(pConn,  VERR_INVALID_POINTER);
    112     AssertPtrReturn(pCfg,   VERR_INVALID_POINTER);
    113     /** @todo Validate fFlags. */
    114     /* ppStream is optional. */
    115 
    116     PAUDMIXSTREAM pMixStream = (PAUDMIXSTREAM)RTMemAllocZ(sizeof(AUDMIXSTREAM));
    117     if (!pMixStream)
    118         return VERR_NO_MEMORY;
    119 
    120     pMixStream->pszName = RTStrDup(pCfg->szName);
    121     if (!pMixStream->pszName)
    122     {
    123         RTMemFree(pMixStream);
    124         return VERR_NO_MEMORY;
    125     }
    126 
    127     LogFlowFunc(("[%s]: fFlags=0x%x (enmDir=%ld, %s, %RU8 channels, %RU32Hz)\n",
    128                  pMixer->pszName, fFlags, pCfg->enmDir, DrvAudioAudFmtToStr(pCfg->enmFormat), pCfg->cChannels, pCfg->uHz));
    129 
    130     PPDMAUDIOSTREAM pStream;
    131     int rc = pConn->pfnStreamCreate(pConn, pCfg, &pStream);
    132     if (RT_SUCCESS(rc))
    133     {
    134         /* Save the audio stream pointer to this mixing stream. */
    135         pMixStream->pStream = pStream;
    136 
    137         /* Increase the stream's reference count to let others know
    138          * we're reyling on it to be around now. */
    139         pConn->pfnStreamAddRef(pConn, pStream);
    140     }
    141 
    142     if (RT_SUCCESS(rc))
    143     {
    144         pMixStream->fFlags = fFlags;
    145         pMixStream->pConn  = pConn;
    146 
    147         if (ppStream)
    148             *ppStream = pMixStream;
    149     }
    150     else if (pMixStream)
    151     {
    152         RTStrFree(pMixStream->pszName);
    153         pMixStream->pszName = NULL;
    154 
    155         RTMemFree(pMixStream);
    156         pMixStream = NULL;
    157     }
    158 
    159     return rc;
    160 }
    161 
    162107int AudioMixerCreate(const char *pszName, uint32_t uFlags, PAUDIOMIXER *ppMixer)
    163108{
     
    417362
    418363    LogFlowFunc(("[%s]: cStreams=%RU8, rc=%Rrc\n", pSink->pszName, pSink->cStreams, rc));
     364    return rc;
     365}
     366
     367int AudioMixerSinkCreateStream(PAUDMIXSINK pSink,
     368                               PPDMIAUDIOCONNECTOR pConn, PPDMAUDIOSTREAMCFG pCfg, uint32_t fFlags, PAUDMIXSTREAM *ppStream)
     369{
     370    AssertPtrReturn(pSink,  VERR_INVALID_POINTER);
     371    AssertPtrReturn(pConn,  VERR_INVALID_POINTER);
     372    AssertPtrReturn(pCfg,   VERR_INVALID_POINTER);
     373    /** @todo Validate fFlags. */
     374    /* ppStream is optional. */
     375
     376    PAUDMIXSTREAM pMixStream = (PAUDMIXSTREAM)RTMemAllocZ(sizeof(AUDMIXSTREAM));
     377    if (!pMixStream)
     378        return VERR_NO_MEMORY;
     379
     380    pMixStream->pszName = RTStrDup(pCfg->szName);
     381    if (!pMixStream->pszName)
     382    {
     383        RTMemFree(pMixStream);
     384        return VERR_NO_MEMORY;
     385    }
     386
     387    LogFlowFunc(("[%s]: fFlags=0x%x (enmDir=%ld, %s, %RU8 channels, %RU32Hz)\n",
     388                 pSink->pszName, fFlags, pCfg->enmDir, DrvAudioAudFmtToStr(pCfg->enmFormat), pCfg->cChannels, pCfg->uHz));
     389
     390    PDMAUDIOSTREAMCFG CfgSink;
     391    int rc = DrvAudioPCMPropsToStreamCfg(&pSink->PCMProps, &CfgSink);
     392    AssertRCReturn(rc, rc);
     393
     394    /* Always use the sink's PCM audio format as the host side when creating a stream for it. */
     395    PPDMAUDIOSTREAM pStream;
     396    rc = pConn->pfnStreamCreate(pConn, &CfgSink, pCfg, &pStream);
     397    if (RT_SUCCESS(rc))
     398    {
     399        /* Save the audio stream pointer to this mixing stream. */
     400        pMixStream->pStream = pStream;
     401
     402        /* Increase the stream's reference count to let others know
     403         * we're reyling on it to be around now. */
     404        pConn->pfnStreamAddRef(pConn, pStream);
     405    }
     406
     407    if (RT_SUCCESS(rc))
     408    {
     409        pMixStream->fFlags = fFlags;
     410        pMixStream->pConn  = pConn;
     411
     412        if (ppStream)
     413            *ppStream = pMixStream;
     414    }
     415    else if (pMixStream)
     416    {
     417        RTStrFree(pMixStream->pszName);
     418        pMixStream->pszName = NULL;
     419
     420        RTMemFree(pMixStream);
     421        pMixStream = NULL;
     422    }
     423
    419424    return rc;
    420425}
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