VirtualBox

Changeset 88513 in vbox


Ignore:
Timestamp:
Apr 14, 2021 7:23:36 PM (3 years ago)
Author:
vboxsync
Message:

DrvHostAudioPulseAudio: Freshed up the debug callbacks a little. bugref:9890

File:
1 edited

Legend:

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

    r88512 r88513  
    722722#ifdef DEBUG
    723723
     724/**
     725 * Debug PA callback: Need data to output.
     726 */
    724727static void drvHostAudioPaStreamReqWriteDebugCallback(pa_stream *pStream, size_t cbLen, void *pvContext)
    725728{
    726729    RT_NOREF(cbLen, pvContext);
    727 
     730    pa_usec_t cUsLatency = 0;
     731    int       fNegative  = 0;
     732    int       rcPa = pa_stream_get_latency(pStream, &cUsLatency, &fNegative);
     733    Log2Func(("Requesting %zu bytes; Latency: %'RU64 us%s\n",
     734              cbLen, cUsLatency, rcPa == 0 ? " - pa_stream_get_latency failed!" : ""));
     735}
     736
     737
     738/**
     739 * Debug PA callback: Underflow.  This may happen when draing/corking.
     740 */
     741static void drvHostAudioPaStreamUnderflowDebugCallback(pa_stream *pStream, void *pvContext)
     742{
    728743    PPULSEAUDIOSTREAM pStrm = (PPULSEAUDIOSTREAM)pvContext;
    729744    AssertPtrReturnVoid(pStrm);
    730745
    731     pa_usec_t usec = 0;
    732     int neg = 0;
    733     pa_stream_get_latency(pStream, &usec, &neg);
    734 
    735     Log2Func(("Requested %zu bytes -- Current latency is %RU64ms\n", cbLen, usec / 1000));
    736 }
    737 
    738 
    739 static void drvHostAudioPaStreamUnderflowDebugCallback(pa_stream *pStream, void *pvContext)
    740 {
    741     PPULSEAUDIOSTREAM pStrm = (PPULSEAUDIOSTREAM)pvContext;
    742     AssertPtrReturnVoid(pStrm);
    743 
    744746    pStrm->cUnderflows++;
    745747
     
    747749
    748750    if (   pStrm->cUnderflows >= 6                /** @todo Make this check configurable. */
    749         && pStrm->cUsLatency  < 2000000 /* 2s */)
    750     {
    751         pStrm->cUsLatency = (pStrm->cUsLatency * 3) / 2;
    752 
    753         LogRel2(("PulseAudio: Output latency increased to %RU64 us\n", pStrm->cUsLatency));
     751        && pStrm->cUsLatency  < 2U*RT_US_1SEC)
     752    {
     753        pStrm->cUsLatency = pStrm->cUsLatency * 3 / 2;
     754        LogRel2(("PulseAudio: Increasing output latency to %'RU64 us\n", pStrm->cUsLatency));
    754755
    755756        pStrm->BufAttr.maxlength = pa_usec_to_bytes(pStrm->cUsLatency, &pStrm->SampleSpec);
    756757        pStrm->BufAttr.tlength   = pa_usec_to_bytes(pStrm->cUsLatency, &pStrm->SampleSpec);
    757 
    758         pa_stream_set_buffer_attr(pStream, &pStrm->BufAttr, NULL, NULL);
     758        pa_operation *pOperation = pa_stream_set_buffer_attr(pStream, &pStrm->BufAttr, NULL, NULL);
     759        if (pOperation)
     760            pa_operation_unref(pOperation);
     761        else
     762            LogRel2(("pa_stream_set_buffer_attr failed!\n"));
    759763
    760764        pStrm->cUnderflows = 0;
     
    762766
    763767    pa_usec_t cUsLatency = 0;
    764     pa_stream_get_latency(pStream, &cUsLatency, NULL /* Neg */);
    765 
    766     LogRel2(("PulseAudio: Latency now is %RU64 us\n", cUsLatency));
     768    int       fNegative  = 0;
     769    pa_stream_get_latency(pStream, &cUsLatency, &fNegative);
     770    LogRel2(("PulseAudio: Latency now is %'RU64 us\n", cUsLatency));
    767771
    768772# ifdef LOG_ENABLED
    769     const pa_timing_info *pTInfo = pa_stream_get_timing_info(pStream);
    770     const pa_sample_spec *pSpec  = pa_stream_get_sample_spec(pStream);
    771 
    772     pa_usec_t curPosWritesUs = pa_bytes_to_usec(pTInfo->write_index, pSpec);
    773     pa_usec_t curPosReadsUs  = pa_bytes_to_usec(pTInfo->read_index, pSpec);
    774     pa_usec_t curTsUs        = pa_rtclock_now() - pStrm->tsStartUs;
    775 
    776     Log2Func(("curPosWrite=%RU64ms, curPosRead=%RU64ms, curTs=%RU64ms, curLatency=%RU64ms (%RU32Hz, %RU8 channels)\n",
    777               curPosWritesUs / RT_US_1MS_64, curPosReadsUs / RT_US_1MS_64,
    778               curTsUs / RT_US_1MS_64, cUsLatency / RT_US_1MS_64, pSpec->rate, pSpec->channels));
     773    if (LogIs2Enabled())
     774    {
     775        const pa_timing_info *pTInfo = pa_stream_get_timing_info(pStream);
     776        AssertReturnVoid(pTInfo);
     777        const pa_sample_spec *pSpec  = pa_stream_get_sample_spec(pStream);
     778        AssertReturnVoid(pSpec);
     779        Log2Func(("writepos=%'RU64 us, readpost=%'RU64 us, age=%'RU64 us, latency=%'RU64 us (%RU32Hz %RU8ch)\n",
     780                  pa_bytes_to_usec(pTInfo->write_index, pSpec), pa_bytes_to_usec(pTInfo->read_index, pSpec),
     781                  pa_rtclock_now() - pStrm->tsStartUs, cUsLatency, pSpec->rate, pSpec->channels));
     782    }
    779783# endif
    780784}
    781785
    782786
     787/**
     788 * Debug PA callback: Overflow.  This may happen when draing/corking.
     789 */
    783790static void drvHostAudioPaStreamOverflowDebugCallback(pa_stream *pStream, void *pvContext)
    784791{
    785792    RT_NOREF(pStream, pvContext);
    786 
    787793    Log2Func(("Warning: Hit overflow\n"));
    788794}
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