Title: [212715] trunk/Source/WebCore
Revision
212715
Author
[email protected]
Date
2017-02-21 09:24:34 -0800 (Tue, 21 Feb 2017)

Log Message

Pulling too quickly from an AudioSampleDataSource should increase the pre-buffer amount
https://bugs.webkit.org/show_bug.cgi?id=168645

Reviewed by Eric Carlson.

If a pull operation runs past the end of the buffered range of a CARingBuffer, the underrun
is zero-filled, causing an audible glitch.  In this case, bias m_outputSampleOffset by the
amount of the underrun, which should keep the underrun from reoccurring.

* platform/audio/mac/AudioSampleDataSource.cpp:
(WebCore::AudioSampleDataSource::pullSamplesInternal):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (212714 => 212715)


--- trunk/Source/WebCore/ChangeLog	2017-02-21 17:19:10 UTC (rev 212714)
+++ trunk/Source/WebCore/ChangeLog	2017-02-21 17:24:34 UTC (rev 212715)
@@ -1,5 +1,19 @@
 2017-02-21  Jer Noble  <[email protected]>
 
+        Pulling too quickly from an AudioSampleDataSource should increase the pre-buffer amount
+        https://bugs.webkit.org/show_bug.cgi?id=168645
+
+        Reviewed by Eric Carlson.
+
+        If a pull operation runs past the end of the buffered range of a CARingBuffer, the underrun
+        is zero-filled, causing an audible glitch.  In this case, bias m_outputSampleOffset by the
+        amount of the underrun, which should keep the underrun from reoccurring.
+
+        * platform/audio/mac/AudioSampleDataSource.cpp:
+        (WebCore::AudioSampleDataSource::pullSamplesInternal):
+
+2017-02-21  Jer Noble  <[email protected]>
+
         AudioSampleBufferList::zeroABL() takes a byte-count, not a sample-count.
         https://bugs.webkit.org/show_bug.cgi?id=168635
 

Modified: trunk/Source/WebCore/platform/audio/mac/AudioSampleDataSource.cpp (212714 => 212715)


--- trunk/Source/WebCore/platform/audio/mac/AudioSampleDataSource.cpp	2017-02-21 17:19:10 UTC (rev 212714)
+++ trunk/Source/WebCore/platform/audio/mac/AudioSampleDataSource.cpp	2017-02-21 17:24:34 UTC (rev 212715)
@@ -253,7 +253,7 @@
 
     LOG(MediaCaptureSamples, "** pullSamples: asking for %ld samples at time = %lld (was %lld)", sampleCount, timeStamp, timeStamp - m_outputSampleOffset);
 
-    int64_t framesAvailable = sampleCount;
+    uint64_t framesAvailable = sampleCount;
     if (timeStamp < startFrame || timeStamp + sampleCount > endFrame) {
         if (timeStamp + sampleCount < startFrame || timeStamp > endFrame)
             framesAvailable = 0;
@@ -264,6 +264,14 @@
 
         LOG(MediaCaptureSamples, "** pullSamplesInternal: sample %lld is not completely in range [%lld .. %lld], returning %lld frames", timeStamp, startFrame, endFrame, framesAvailable);
 
+        if (framesAvailable < sampleCount) {
+            const double twentyMS = .02;
+            double sampleRate = m_outputDescription->sampleRate();
+            auto delta = static_cast<int64_t>(timeStamp) - endFrame;
+            if (delta > 0 && delta < sampleRate * twentyMS)
+                m_outputSampleOffset -= delta;
+        }
+
         if (!framesAvailable) {
             AudioSampleBufferList::zeroABL(buffer, byteCount);
             return false;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to