VirtualBox

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


Ignore:
Timestamp:
Dec 13, 2019 1:54:24 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
135459
Message:

Audio: Make sure to only set a new recording source if the backend in question is ready for it; otherwise stay with current settings. bugref:9625.

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

Legend:

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

    r82458 r82579  
    523523    {
    524524        rc = audioMixerStreamCtlInternal(pStream, PDMAUDIOSTREAMCMD_ENABLE, AUDMIXSTRMCTL_F_NONE);
     525        if (rc == VERR_AUDIO_STREAM_NOT_READY)
     526            rc = VINF_SUCCESS; /* Not fatal here, stream can become available at some later point in time. */
    525527    }
    526528
     
    576578        return VERR_NO_MEMORY;
    577579
    578     pMixStream->pszName = RTStrDup(pCfg->szName);
     580    PDMAUDIOBACKENDCFG BackendCfg;
     581    int rc = pConn->pfnGetConfig(pConn, &BackendCfg);
     582    if (RT_FAILURE(rc))
     583    {
     584        RTMemFree(pMixStream);
     585        return rc;
     586    }
     587
     588    /* Assign the backend's name to the mixer stream's name for easier identification in the (release) log. */
     589    pMixStream->pszName = RTStrAPrintf2("[%s] %s", pCfg->szName, BackendCfg.szName);
    579590    if (!pMixStream->pszName)
    580591    {
     
    583594    }
    584595
    585     int rc = RTCritSectEnter(&pSink->CritSect);
     596    rc = RTCritSectEnter(&pSink->CritSect);
    586597    if (RT_FAILURE(rc))
    587598        return rc;
     
    14801491    int rc;
    14811492
    1482     if (pSink->In.pStreamRecSource) /* Disable old recording source, if any set. */
     1493    if (pSink->In.pStreamRecSource) /* First, disable old recording source, if any set. */
    14831494    {
    14841495        const PPDMIAUDIOCONNECTOR pConn = pSink->In.pStreamRecSource->pConn;
     
    14951506            AssertPtr(pStream->pStream);
    14961507            AssertMsg(pStream->pStream->enmDir == PDMAUDIODIR_IN, ("Specified stream is not an input stream\n"));
    1497         }
    1498 
    1499         pSink->In.pStreamRecSource = pStream;
    1500 
    1501         if (pSink->In.pStreamRecSource)
    1502         {
    1503             const PPDMIAUDIOCONNECTOR pConn = pSink->In.pStreamRecSource->pConn;
    1504             AssertPtr(pConn);
    1505             rc = pConn->pfnEnable(pConn, PDMAUDIODIR_IN, true /* Enable */);
     1508            AssertPtr(pStream->pConn);
     1509            rc = pStream->pConn->pfnEnable(pStream->pConn, PDMAUDIODIR_IN, true /* Enable */);
     1510            if (RT_SUCCESS(rc))
     1511            {
     1512                pSink->In.pStreamRecSource = pStream;
     1513            }
     1514            else if (pSink->In.pStreamRecSource->pConn) /* Stay with the current recording source (if any) and re-enable it. */
     1515            {
     1516                const PPDMIAUDIOCONNECTOR pConn = pSink->In.pStreamRecSource->pConn;
     1517                AssertPtr(pConn);
     1518                rc = pConn->pfnEnable(pConn, PDMAUDIODIR_IN, true /* Enable */);
     1519            }
    15061520        }
    15071521    }
     
    15151529                pSink->pszName, pSink->In.pStreamRecSource ? pSink->In.pStreamRecSource->pszName : "<None>"));
    15161530    }
    1517     else
     1531    else if (rc != VERR_AUDIO_STREAM_NOT_READY)
     1532    {
    15181533        LogRel(("Mixer: Setting recording source of sink '%s' to '%s' failed with %Rrc\n",
    15191534                pSink->pszName, pSink->In.pStreamRecSource ? pSink->In.pStreamRecSource->pszName : "<None>", rc));
     1535    }
    15201536
    15211537    return rc;
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r82458 r82579  
    514514    {
    515515        if (   rc != VERR_NOT_IMPLEMENTED
    516             && rc != VERR_NOT_SUPPORTED)
     516            && rc != VERR_NOT_SUPPORTED
     517            && rc != VERR_AUDIO_STREAM_NOT_READY)
     518        {
    517519            LogRel(("Audio: %s stream '%s' failed with %Rrc\n", DrvAudioHlpStreamCmdToStr(enmStreamCmd), pStream->szName, rc));
     520        }
    518521
    519522        LogFunc(("[%s] %s failed with %Rrc\n", pStream->szName, DrvAudioHlpStreamCmdToStr(enmStreamCmd), rc));
     
    26642667                                                    fEnable ? PDMAUDIOSTREAMCMD_ENABLE : PDMAUDIOSTREAMCMD_DISABLE);
    26652668            if (RT_FAILURE(rc2))
    2666                 LogRel(("Audio: Failed to %s %s stream '%s', rc=%Rrc\n",
    2667                         fEnable ? "enable" : "disable", enmDir == PDMAUDIODIR_IN ? "input" : "output", pStream->szName, rc2));
     2669            {
     2670                if (rc2 == VERR_AUDIO_STREAM_NOT_READY)
     2671                {
     2672                    LogRel(("Audio: Stream '%s' not available\n", pStream->szName));
     2673                }
     2674                else
     2675                    LogRel(("Audio: Failed to %s %s stream '%s', rc=%Rrc\n",
     2676                            fEnable ? "enable" : "disable", enmDir == PDMAUDIODIR_IN ? "input" : "output", pStream->szName, rc2));
     2677            }
    26682678
    26692679            if (RT_SUCCESS(rc))
     
    32073217    LogFlowFunc(("[%s] cRefs=%RU32\n", pStream->szName, pStream->cRefs));
    32083218
    3209     if (pStream->cRefs > 1)
    3210         return VERR_WRONG_ORDER;
     3219    AssertMsgReturn(pStream->cRefs <= 1,
     3220                    ("Stream '%s' still has %RU32 references held when uninitializing\n", pStream->szName, pStream->cRefs),
     3221                    VERR_WRONG_ORDER);
    32113222
    32123223    int rc = drvAudioStreamControlInternal(pThis, pStream, PDMAUDIOSTREAMCMD_DISABLE);
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