VirtualBox

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


Ignore:
Timestamp:
Jul 7, 2016 4:16:01 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
108603
Message:

Audio: Bugfixes, logging.

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

Legend:

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

    r61887 r62117  
    829829    }
    830830
     831    /* Update last updated timestamp. */
     832    pSink->tsLastUpdatedMS = RTTimeMilliTS();
     833
    831834    /* Reset status. */
    832835    pSink->fStatus = AUDMIXSINK_STS_NONE;
     
    921924    uint8_t cStreamsDisabled = 0;
    922925
    923     /* Update last updated timestamp. */
    924     pSink->tsLastUpdatedNS = RTTimeNanoTS();
     926    /* Get the time delta and calculate the bytes that need to be processed. */
     927    uint64_t tsDeltaMS = RTTimeMilliTS() - pSink->tsLastUpdatedMS;
     928    uint32_t cbDelta   = (pSink->PCMProps.cbBitrate / 1000 /* s to ms */) * tsDeltaMS;
     929
     930    Log3Func(("[%s] Bitrate is %RU32 bytes/s -> %RU64ms / %RU32 bytes elapsed\n",
     931              pSink->pszName, pSink->PCMProps.cbBitrate, tsDeltaMS, cbDelta));
     932
     933    if (pSink->enmDir == AUDMIXSINKDIR_INPUT)
     934    {
     935        pSink->In.cbReadable  = cbDelta;
     936    }
     937    else if (pSink->enmDir == AUDMIXSINKDIR_OUTPUT)
     938    {
     939        pSink->Out.cbWritable = cbDelta;
     940    }
     941
     942    uint8_t uCurLUN = 0;
    925943
    926944    PAUDMIXSTREAM pMixStream, pMixStreamNext;
     
    9931011# error "Implement me!"
    9941012#else
    995                 pSink->In.cbReadable = pConn->pfnStreamGetReadable(pConn, pMixStream->pStream);
     1013                if (uCurLUN == 0)
     1014                {
     1015                    pSink->In.cbReadable = pConn->pfnStreamGetReadable(pConn, pMixStream->pStream);
     1016                    Log3Func(("\t%s: cbReadable=%RU32\n", pMixStream->pStream->szName, pSink->In.cbReadable));
     1017                    uCurLUN++;
     1018                }
    9961019#endif
    9971020            }
     
    10011024# error "Implement me!"
    10021025#else
    1003                 pSink->Out.cbWritable = pConn->pfnStreamGetWritable(pConn, pMixStream->pStream);
     1026                if (uCurLUN == 0)
     1027                {
     1028                    pSink->Out.cbWritable = pConn->pfnStreamGetWritable(pConn, pMixStream->pStream);
     1029                    Log3Func(("\t%s: cbWritable=%RU32\n", pMixStream->pStream->szName, pSink->Out.cbWritable));
     1030                    uCurLUN++;
     1031                }
    10041032#endif
    10051033            }
     
    10161044    }
    10171045
    1018     if (RT_FAILURE(rc))
    1019         LogFlowFunc(("Failed with rc=%Rrc\n", rc));
     1046    /* Update last updated timestamp. */
     1047    pSink->tsLastUpdatedMS = RTTimeMilliTS();
     1048
     1049    Log3Func(("[%s] cbReadable=%RU32, cbWritable=%RU32, rc=%Rrc\n",
     1050              pSink->pszName, pSink->In.cbReadable, pSink->Out.cbWritable, rc));
    10201051
    10211052    return rc;
     
    10251056{
    10261057    AssertPtrReturn(pSink, VERR_INVALID_POINTER);
    1027 
    1028     uint64_t tsElapsed = RTTimeNanoTS() - pSink->tsLastUpdatedNS;
    10291058
    10301059    /*
  • trunk/src/VBox/Devices/Audio/AudioMixer.h

    r61887 r62117  
    3737    /** The master volume of this mixer. */
    3838    PDMAUDIOVOLUME          VolMaster;
    39     /* List of audio mixer sinks. */
     39    /** List of audio mixer sinks. */
    4040    RTLISTANCHOR            lstSinks;
    4141    /** Number of used audio sinks. */
     
    9090typedef enum AUDMIXSINKDIR
    9191{
     92    /** Unknown direction. */
    9293    AUDMIXSINKDIR_UNKNOWN = 0,
     94    /** Input (capturing from a device). */
    9395    AUDMIXSINKDIR_INPUT,
     96    /** Output (playing to a device). */
    9497    AUDMIXSINKDIR_OUTPUT,
    9598    /** The usual 32-bit hack. */
     
    183186    /** The volume of this sink, combined with the last set  master volume. */
    184187    PDMAUDIOVOLUME          VolumeCombined;
    185     /** Timestamp (in ns) since last update. */
    186     uint64_t                tsLastUpdatedNS;
     188    /** Timestamp (in ms) since last update. */
     189    uint64_t                tsLastUpdatedMS;
    187190} AUDMIXSINK, *PAUDMIXSINK;
    188191
  • trunk/src/VBox/Devices/Audio/DevIchHda.cpp

    r61888 r62117  
    30673067            /* Also make sure to handle the DMA position enable bit. */
    30683068            pThis->fDMAPosition = RT_BOOL(pThis->u64DPBase & RT_BIT_64(0));
    3069             LogRel(("HDA: %s DMA position buffer\n", pThis->fDMAPosition ? "Enabled" : "Disabled"));
     3069            LogRel2(("HDA: %s DMA position buffer\n", pThis->fDMAPosition ? "Enabled" : "Disabled"));
    30703070            break;
    30713071        }
     
    37783778        PHDAMIXERSTREAM pStream = NULL;
    37793779
    3780         if (pCfg->enmDir == PDMAUDIODIR_IN)
     3780        PPDMAUDIOSTREAMCFG pStreamCfg = (PPDMAUDIOSTREAMCFG)RTMemDup(pCfg, sizeof(PDMAUDIOSTREAMCFG));
     3781        if (!pStreamCfg)
    37813782        {
    3782             LogFunc(("enmRecSource=%ld\n", pCfg->DestSource.Source));
    3783 
    3784             switch (pCfg->DestSource.Source)
     3783            rc = VERR_NO_MEMORY;
     3784            break;
     3785        }
     3786
     3787        /* Include the driver's LUN in the stream name for easier identification. */
     3788        RTStrPrintf(pStreamCfg->szName, RT_ELEMENTS(pStreamCfg->szName), "[LUN#%RU8] %s", pDrv->uLUN, pCfg->szName);
     3789
     3790        if (pStreamCfg->enmDir == PDMAUDIODIR_IN)
     3791        {
     3792            LogFunc(("enmRecSource=%ld\n", pStreamCfg->DestSource.Source));
     3793
     3794            switch (pStreamCfg->DestSource.Source)
    37853795            {
    37863796                case PDMAUDIORECSOURCE_LINE:
     
    37973807            }
    37983808        }
    3799         else if (pCfg->enmDir == PDMAUDIODIR_OUT)
     3809        else if (pStreamCfg->enmDir == PDMAUDIODIR_OUT)
    38003810        {
    3801             LogFunc(("enmPlaybackDest=%ld\n", pCfg->DestSource.Dest));
    3802 
    3803             switch (pCfg->DestSource.Dest)
     3811            LogFunc(("enmPlaybackDest=%ld\n", pStreamCfg->DestSource.Dest));
     3812
     3813            switch (pStreamCfg->DestSource.Dest)
    38043814            {
    38053815                case PDMAUDIOPLAYBACKDEST_FRONT:
     
    38323842
    38333843            PAUDMIXSTREAM pMixStrm;
    3834             rc2 = AudioMixerSinkCreateStream(pSink->pMixSink, pDrv->pConnector, pCfg, 0 /* fFlags */, &pMixStrm);
     3844            rc2 = AudioMixerSinkCreateStream(pSink->pMixSink, pDrv->pConnector, pStreamCfg, 0 /* fFlags */, &pMixStrm);
    38353845            if (RT_SUCCESS(rc2))
    38363846            {
    38373847                rc2 = AudioMixerSinkAddStream(pSink->pMixSink, pMixStrm);
    3838                 LogFlowFunc(("LUN#%RU8: Added \"%s\" to sink, rc=%Rrc\n", pDrv->uLUN, pCfg->szName , rc2));
     3848                LogFlowFunc(("LUN#%RU8: Added \"%s\" to sink, rc=%Rrc\n", pDrv->uLUN, pStreamCfg->szName , rc2));
    38393849            }
    38403850
     
    38453855        if (RT_SUCCESS(rc))
    38463856            rc = rc2;
     3857
     3858        if (pStreamCfg)
     3859        {
     3860            RTMemFree(pStreamCfg);
     3861            pStreamCfg = NULL;
     3862        }
    38473863    }
    38483864
  • trunk/src/VBox/Devices/Audio/DrvAudio.cpp

    r62068 r62117  
    657657    if (rc == VINF_BUFFER_OVERFLOW)
    658658    {
    659         LogRel2(("Audio: Lost audio samples from guest stream '%s' (only %zu / %zu bytes written), expect stuttering audio output\n",
    660                  pGstStream->szName, AUDIOMIXBUF_S2B(&pGstStream->MixBuf, cWritten), cbBuf));
     659        LogRel2(("Audio: Lost audio samples from guest stream '%s', expect stuttering audio output\n", pGstStream->szName));
    661660        rc = VINF_SUCCESS;
    662661    }
     
    825824}
    826825
    827 static DECLCALLBACK(int) drvAudioStreamPlay(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream,
    828                                             uint32_t *pcSamplesPlayed)
     826static DECLCALLBACK(int) drvAudioStreamPlay(PPDMIAUDIOCONNECTOR pInterface,
     827                                            PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesPlayed)
    829828{
    830829    AssertPtrReturn(pInterface, VERR_INVALID_POINTER);
     
    851850        if (pThis->pHostDrvAudio->pfnGetStatus(pThis->pHostDrvAudio, PDMAUDIODIR_OUT) != PDMAUDIOBACKENDSTS_RUNNING)
    852851        {
     852            /* Pull the new config from the backend and check again. */
    853853            rc = pThis->pHostDrvAudio->pfnGetConfig(pThis->pHostDrvAudio, &pThis->BackendCfg);
    854854            AssertRC(rc);
     
    927927}
    928928
    929 static DECLCALLBACK(int) drvAudioStreamCapture(PPDMIAUDIOCONNECTOR pInterface, PPDMAUDIOSTREAM pStream,
    930                                                uint32_t *pcSamplesCaptured)
     929static DECLCALLBACK(int) drvAudioStreamCapture(PPDMIAUDIOCONNECTOR pInterface,
     930                                               PPDMAUDIOSTREAM pStream, uint32_t *pcSamplesCaptured)
    931931{
    932932    PDRVAUDIO pThis = PDMIAUDIOCONNECTOR_2_DRVAUDIO(pInterface);
  • trunk/src/VBox/Devices/Audio/DrvAudioCommon.cpp

    r61177 r62117  
    459459        pProps->cShift      = (pCfg->cChannels == 2) + cShift;
    460460        pProps->uAlign      = (1 << pProps->cShift) - 1;
    461         pProps->cbPerSec    = pProps->uHz << pProps->cShift;
     461        pProps->cbBitrate   = (pProps->cBits * pProps->uHz * pProps->cChannels) / 8;
    462462        pProps->fSwapEndian = pCfg->enmEndianness != PDMAUDIOHOSTENDIANNESS;
    463463    }
  • trunk/src/VBox/Devices/Audio/DrvHostCoreAudio.cpp

    r62071 r62117  
    18551855        /* Move offset. */
    18561856        cbRead += cbToRead;
    1857         Assert(pBufData->mBuffers[0].mDataByteSize >= cbRead);
     1857
     1858        /* Check if we're lagging behind. */
     1859        if (cbRead > pBufData->mBuffers[0].mDataByteSize)
     1860        {
     1861            LogRel2(("CoreAudio: Host output lagging behind, expect stuttering guest audio output\n"));
     1862            cbRead = pBufData->mBuffers[0].mDataByteSize;
     1863            break;
     1864        }
    18581865
    18591866        Assert(cbToRead <= cbLeft);
     
    18611868    }
    18621869
    1863     /* Write the bytes to the core audio buffer which where really written. */
     1870    /* Write the bytes to the core audio buffer which were really written. */
     1871    Assert(pBufData->mBuffers[0].mDataByteSize >= cbRead);
    18641872    pBufData->mBuffers[0].mDataByteSize = cbRead;
    18651873
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