Changeset 88513 in vbox
- Timestamp:
- Apr 14, 2021 7:23:36 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DrvHostAudioPulseAudio.cpp
r88512 r88513 722 722 #ifdef DEBUG 723 723 724 /** 725 * Debug PA callback: Need data to output. 726 */ 724 727 static void drvHostAudioPaStreamReqWriteDebugCallback(pa_stream *pStream, size_t cbLen, void *pvContext) 725 728 { 726 729 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 */ 741 static void drvHostAudioPaStreamUnderflowDebugCallback(pa_stream *pStream, void *pvContext) 742 { 728 743 PPULSEAUDIOSTREAM pStrm = (PPULSEAUDIOSTREAM)pvContext; 729 744 AssertPtrReturnVoid(pStrm); 730 745 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 744 746 pStrm->cUnderflows++; 745 747 … … 747 749 748 750 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)); 754 755 755 756 pStrm->BufAttr.maxlength = pa_usec_to_bytes(pStrm->cUsLatency, &pStrm->SampleSpec); 756 757 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")); 759 763 760 764 pStrm->cUnderflows = 0; … … 762 766 763 767 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)); 767 771 768 772 # 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 } 779 783 # endif 780 784 } 781 785 782 786 787 /** 788 * Debug PA callback: Overflow. This may happen when draing/corking. 789 */ 783 790 static void drvHostAudioPaStreamOverflowDebugCallback(pa_stream *pStream, void *pvContext) 784 791 { 785 792 RT_NOREF(pStream, pvContext); 786 787 793 Log2Func(("Warning: Hit overflow\n")); 788 794 }
Note:
See TracChangeset
for help on using the changeset viewer.

