VirtualBox

Changeset 61723 in vbox


Ignore:
Timestamp:
Jun 15, 2016 3:21:15 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
108093
Message:

Audio: Fixes for recording on Windows hosts.

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

Legend:

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

    r61668 r61723  
    385385                 pSink->pszName, fFlags, pCfg->enmDir, DrvAudioHlpAudFmtToStr(pCfg->enmFormat), pCfg->cChannels, pCfg->uHz));
    386386
    387     PDMAUDIOSTREAMCFG CfgSink;
    388     int rc = DrvAudioHlpPCMPropsToStreamCfg(&pSink->PCMProps, &CfgSink);
     387    /*
     388     * Initialize the host-side configuration for the stream to be created.
     389     * Always use the sink's PCM audio format as the host side when creating a stream for it.
     390     */
     391    PDMAUDIOSTREAMCFG CfgHost;
     392    int rc = DrvAudioHlpPCMPropsToStreamCfg(&pSink->PCMProps, &CfgHost);
    389393    AssertRCReturn(rc, rc);
    390394
     
    393397    if (pSink->enmDir == AUDMIXSINKDIR_INPUT)
    394398    {
    395         CfgSink.DestSource.Source = PDMAUDIORECSOURCE_UNKNOWN;
    396         CfgSink.enmDir            = PDMAUDIODIR_IN;
     399        CfgHost.DestSource.Source = pCfg->DestSource.Source;
     400        CfgHost.enmDir            = PDMAUDIODIR_IN;
    397401    }
    398402    else
    399403    {
    400         CfgSink.DestSource.Dest = PDMAUDIOPLAYBACKDEST_UNKNOWN;
    401         CfgSink.enmDir          = PDMAUDIODIR_OUT;
    402     }
    403 
    404     RTStrPrintf(CfgSink.szName, sizeof(CfgSink.szName), "%s", pCfg->szName);
    405 
    406     /* Always use the sink's PCM audio format as the host side when creating a stream for it. */
     404        CfgHost.DestSource.Dest = pCfg->DestSource.Dest;
     405        CfgHost.enmDir          = PDMAUDIODIR_OUT;
     406    }
     407
     408    RTStrPrintf(CfgHost.szName, sizeof(CfgHost.szName), "%s", pCfg->szName);
     409
    407410    PPDMAUDIOSTREAM pStream;
    408     rc = pConn->pfnStreamCreate(pConn, &CfgSink, pCfg, &pStream);
     411    rc = pConn->pfnStreamCreate(pConn, &CfgHost, pCfg, &pStream);
    409412    if (RT_SUCCESS(rc))
    410413    {
     
    10611064    LogFlowFunc(("%s: enmOp=%ld, cbBuf=%RU32\n", pSink->pszName, enmOp, cbBuf));
    10621065
    1063     uint32_t cPlayed;
    10641066    uint32_t cbProcessed;
    10651067
     
    11791181
    11801182    bool fIsActive =
    1181         (pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream) & PDMAUDIOSTRMSTS_FLAG_ENABLED);
     1183        RT_BOOL(pMixStream->pConn->pfnStreamGetStatus(pMixStream->pConn, pMixStream->pStream) & PDMAUDIOSTRMSTS_FLAG_ENABLED);
    11821184
    11831185    return fIsActive;
  • trunk/src/VBox/Devices/Audio/DevIchHda.cpp

    r61668 r61723  
    26872687        if (fUseFront)
    26882688        {
    2689             if (!RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Front"))
    2690             {
    2691                 rc = VERR_BUFFER_OVERFLOW;
    2692                 break;
    2693             }
    2694 
     2689            RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Front");
    26952690            pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_FRONT;
    26962691            pCfg->cChannels       = 2;
     2692
    26972693            rc = hdaCodecRemoveStream(pThis->pCodec,  PDMAUDIOMIXERCTL_FRONT);
    26982694            if (RT_SUCCESS(rc))
     
    27042700            && (fUseCenter || fUseLFE))
    27052701        {
    2706             if (!RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Center/LFE"))
    2707             {
    2708                 rc = VERR_BUFFER_OVERFLOW;
    2709                 break;
    2710             }
    2711 
     2702            RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Center/LFE");
    27122703            pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_CENTER_LFE;
    27132704            pCfg->cChannels       = (fUseCenter && fUseLFE) ? 2 : 1;
     2705
    27142706            rc = hdaCodecRemoveStream(pThis->pCodec,  PDMAUDIOMIXERCTL_CENTER_LFE);
    27152707            if (RT_SUCCESS(rc))
     
    27202712            && fUseRear)
    27212713        {
    2722             if (!RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Rear"))
    2723             {
    2724                 rc = VERR_BUFFER_OVERFLOW;
    2725                 break;
    2726             }
    2727 
     2714            RTStrPrintf(pCfg->szName, RT_ELEMENTS(pCfg->szName), "Rear");
    27282715            pCfg->DestSource.Dest = PDMAUDIOPLAYBACKDEST_REAR;
    27292716            pCfg->cChannels       = 2;
     2717
    27302718            rc = hdaCodecRemoveStream(pThis->pCodec,  PDMAUDIOMIXERCTL_REAR);
    27312719            if (RT_SUCCESS(rc))
     
    28122800#else
    28132801            strmCfg.DestSource.Source = PDMAUDIORECSOURCE_LINE;
     2802            RTStrPrintf(strmCfg.szName, RT_ELEMENTS(strmCfg.szName), "Line In");
    28142803#endif
    28152804            break;
     
    37873776    {
    37883777        int rc2 = VINF_SUCCESS;
    3789         PHDAMIXERSTREAM pStream;
     3778        PHDAMIXERSTREAM pStream = NULL;
    37903779
    37913780        if (pCfg->enmDir == PDMAUDIODIR_IN)
    37923781        {
     3782            LogFunc(("enmRecSource=%ld\n", pCfg->DestSource.Source));
     3783
    37933784            switch (pCfg->DestSource.Source)
    37943785            {
     
    38083799        else if (pCfg->enmDir == PDMAUDIODIR_OUT)
    38093800        {
     3801            LogFunc(("enmPlaybackDest=%ld\n", pCfg->DestSource.Dest));
     3802
    38103803            switch (pCfg->DestSource.Dest)
    38113804            {
     
    38313824        if (RT_SUCCESS(rc2))
    38323825        {
     3826            AssertPtr(pStream);
     3827
    38333828            AudioMixerSinkRemoveStream(pSink->pMixSink, pStream->pMixStrm);
    38343829
  • trunk/src/VBox/Devices/Audio/DrvHostDSound.cpp

    r61609 r61723  
    894894    AssertPtrReturn(pDSoundStream, NULL);
    895895
     896    int rc = VINF_SUCCESS;
     897
    896898    LPCGUID pGUID = pThis->cfg.pGuidCapture;
    897 
    898899    if (!pGUID)
    899900    {
    900         PDSOUNDDEV  pDev = NULL;
     901        PDSOUNDDEV pDev = NULL;
    901902
    902903        switch (pDSoundStream->enmRecSource)
    903904        {
     905            case PDMAUDIORECSOURCE_LINE:
     906                /*
     907                 * At the moment we're only supporting line-in in the HDA emulation,
     908                 * and line-in + mic-in in the AC'97 emulation both are expected
     909                 * to use the host's mic-in as well.
     910                 *
     911                 * So the fall through here is intentional for now.
     912                 */
    904913            case PDMAUDIORECSOURCE_MIC:
    905914            {
     
    909918                        break;
    910919                }
     920
    911921                if (RTListNodeIsDummy(&pThis->lstDevInput, pDev, DSOUNDDEV, Node))
    912                     pDev = NULL;    /* Found nothing. */
     922                    pDev = NULL; /* Found nothing. */
    913923
    914924                break;
    915925            }
    916926
    917             case PDMAUDIORECSOURCE_LINE:
    918927            default:
    919                 /* Try opening the default device (NULL). */
     928                AssertFailedStmt(rc = VERR_NOT_SUPPORTED);
    920929                break;
    921930        }
    922931
    923         if (pDev)
    924         {
    925             DSLOG(("DSound: Guest \"%s\" is using host \"%s\"\n",
     932        if (   RT_SUCCESS(rc)
     933            && pDev)
     934        {
     935            DSLOG(("DSound: Guest source '%s' is using host recording device '%s'\n",
    926936                   DrvAudioHlpRecSrcToStr(pDSoundStream->enmRecSource), pDev->pszName));
    927937
     
    930940    }
    931941
     942    if (RT_FAILURE(rc))
     943    {
     944        LogRel(("DSound: Selecting recording device failed with %Rrc\n", rc));
     945        return NULL;
     946    }
     947
    932948    char *pszGUID = dsoundGUIDToUtf8StrA(pGUID);
     949
    933950    /* This always has to be in the release log. */
    934     LogRel(("DSound: Guest \"%s\" is using host device with GUID: %s\n",
     951    LogRel(("DSound: Guest source '%s' is using host recording device with GUID '%s'\n",
    935952            DrvAudioHlpRecSrcToStr(pDSoundStream->enmRecSource), pszGUID ? pszGUID: "{?}"));
    936     RTStrFree(pszGUID);
     953
     954    if (pszGUID)
     955    {
     956        RTStrFree(pszGUID);
     957        pszGUID = NULL;
     958    }
    937959
    938960    return pGUID;
     
    14231445    LogFlowFunc(("pStream=%p, pCfg=%p\n", pStream, pCfg));
    14241446
    1425     PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
     1447    PDRVHOSTDSOUND   pThis        = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
    14261448    PDSOUNDSTREAMOUT pDSoundStream = (PDSOUNDSTREAMOUT)pStream;
    14271449
     
    16631685static int dsoundDestroyStreamOut(PPDMIHOSTAUDIO pInterface, PPDMAUDIOSTREAM pStream)
    16641686{
    1665     PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
     1687    PDRVHOSTDSOUND   pThis        = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
    16661688    PDSOUNDSTREAMOUT pDSoundStream = (PDSOUNDSTREAMOUT)pStream;
    16671689
    16681690    directSoundPlayClose(pThis, pDSoundStream);
    16691691
    1670     pDSoundStream->cbPlayWritePos = 0;
    1671     pDSoundStream->fRestartPlayback = true;
     1692    pDSoundStream->cbPlayWritePos       = 0;
     1693    pDSoundStream->fRestartPlayback     = true;
    16721694    pDSoundStream->csPlaybackBufferSize = 0;
    16731695
     
    16801702                                PPDMAUDIOSTREAM pStream, PPDMAUDIOSTREAMCFG pCfg, uint32_t *pcSamples)
    16811703{
    1682     PDRVHOSTDSOUND pThis = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
     1704    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     1705    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
     1706    AssertPtrReturn(pCfg,       VERR_INVALID_POINTER);
     1707
     1708    PDRVHOSTDSOUND  pThis         = PDMIHOSTAUDIO_2_DRVHOSTDSOUND(pInterface);
    16831709    PDSOUNDSTREAMIN pDSoundStream = (PDSOUNDSTREAMIN)pStream;
    16841710
    1685     LogFlowFunc(("pStream=%p, pAudioSettings=%p, enmRecSource=%ld\n",
    1686                  pStream, pCfg, pCfg->DestSource.Source));
    1687 
    1688     pDSoundStream->streamCfg = *pCfg;
    1689     pDSoundStream->streamCfg.enmEndianness = PDMAUDIOHOSTENDIANNESS;
     1711    LogFlowFunc(("pStream=%p, pCfg=%p, enmRecSource=%ld\n", pStream, pCfg, pCfg->DestSource.Source));
     1712
     1713    memcpy(&pDSoundStream->streamCfg, pCfg, sizeof(PDMAUDIOSTREAMCFG));
    16901714
    16911715    /** @todo caller should already init Props? */
     
    17201744{
    17211745    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
    1722     AssertPtrReturn(pStream, VERR_INVALID_POINTER);
     1746    AssertPtrReturn(pStream,    VERR_INVALID_POINTER);
    17231747
    17241748    LogFlowFunc(("pStream=%p, enmStreamCmd=%ld\n", pStream, enmStreamCmd));
     
    18211845            break;
    18221846
    1823         /* Using as an intermediate not circular buffer. */
    1824         AudioMixBufReset(&pStream->MixBuf);
    1825 
    18261847        /* Get number of free samples in the mix buffer and check that is has free space */
    18271848        uint32_t csMixFree = AudioMixBufFree(&pStream->MixBuf);
     
    18591880        if (pv1 && len1)
    18601881        {
    1861             rc = AudioMixBufWriteAt(&pStream->MixBuf, 0 /* offWrite */,
    1862                                     pv1, cb1, &csWritten);
     1882            rc = AudioMixBufWriteCirc(&pStream->MixBuf, pv1, cb1, &csWritten);
    18631883            if (RT_SUCCESS(rc))
    18641884                csWrittenTotal += csWritten;
     
    18691889            && pv2 && len2)
    18701890        {
    1871             rc = AudioMixBufWriteAt(&pStream->MixBuf, csWrittenTotal,
    1872                                     pv2, cb2, &csWritten);
     1891            rc = AudioMixBufWriteCirc(&pStream->MixBuf, pv2, cb2, &csWritten);
    18731892            if (RT_SUCCESS(rc))
    18741893                csWrittenTotal += csWritten;
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