Title: [278453] trunk/Source/WebCore
Revision
278453
Author
[email protected]
Date
2021-06-04 05:04:59 -0700 (Fri, 04 Jun 2021)

Log Message

Reintroduce logging useful for debugging in AudioSampleDataSource
https://bugs.webkit.org/show_bug.cgi?id=226578

Reviewed by Eric Carlson.

Removed logging was actually useful for debugging audio issues.
Reintroduce it by restrict logging to ensure we do not introduce too much audio glitches by doing so:
- If we pull samples and do not have enough data, enter more-data-needed mode, and log once that data is missing.
- If we pull samples and do not have enough data and we are already in more-data-needed mode, do not log anything.
- If we push samples and are in more-data-needed mode, reset mode to none and log this information.
The mode check happens in two different threads so might be a bit racy but at worst, this reduces accuracy of the logging.

No change of behavior.

* platform/audio/cocoa/AudioSampleDataSource.h:
* platform/audio/cocoa/AudioSampleDataSource.mm:
(WebCore::AudioSampleDataSource::pushSamplesInternal):
(WebCore::AudioSampleDataSource::pullSamplesInternal):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (278452 => 278453)


--- trunk/Source/WebCore/ChangeLog	2021-06-04 11:05:02 UTC (rev 278452)
+++ trunk/Source/WebCore/ChangeLog	2021-06-04 12:04:59 UTC (rev 278453)
@@ -1,3 +1,24 @@
+2021-06-04  Youenn Fablet  <[email protected]>
+
+        Reintroduce logging useful for debugging in AudioSampleDataSource
+        https://bugs.webkit.org/show_bug.cgi?id=226578
+
+        Reviewed by Eric Carlson.
+
+        Removed logging was actually useful for debugging audio issues.
+        Reintroduce it by restrict logging to ensure we do not introduce too much audio glitches by doing so:
+        - If we pull samples and do not have enough data, enter more-data-needed mode, and log once that data is missing.
+        - If we pull samples and do not have enough data and we are already in more-data-needed mode, do not log anything.
+        - If we push samples and are in more-data-needed mode, reset mode to none and log this information.
+        The mode check happens in two different threads so might be a bit racy but at worst, this reduces accuracy of the logging.
+
+        No change of behavior.
+
+        * platform/audio/cocoa/AudioSampleDataSource.h:
+        * platform/audio/cocoa/AudioSampleDataSource.mm:
+        (WebCore::AudioSampleDataSource::pushSamplesInternal):
+        (WebCore::AudioSampleDataSource::pullSamplesInternal):
+
 2021-05-27  Sergio Villar Senin  <[email protected]>
 
         [css-flexbox] Sanitize the aspect ratio handling code

Modified: trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.h (278452 => 278453)


--- trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.h	2021-06-04 11:05:02 UTC (rev 278452)
+++ trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.h	2021-06-04 12:04:59 UTC (rev 278453)
@@ -116,6 +116,8 @@
     bool m_shouldComputeOutputSampleOffset { true };
     uint64_t m_endFrameWhenNotEnoughData { 0 };
 
+    bool m_isInNeedOfMoreData { false };
+
 #if !RELEASE_LOG_DISABLED
     Ref<const Logger> m_logger;
     const void* m_logIdentifier;

Modified: trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.mm (278452 => 278453)


--- trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.mm	2021-06-04 11:05:02 UTC (rev 278452)
+++ trunk/Source/WebCore/platform/audio/cocoa/AudioSampleDataSource.mm	2021-06-04 12:04:59 UTC (rev 278453)
@@ -170,6 +170,13 @@
     m_ringBuffer->getCurrentFrameBounds(startFrame1, endFrame1);
 #endif
 
+    if (m_isInNeedOfMoreData) {
+        m_isInNeedOfMoreData = false;
+        DisableMallocRestrictionsForCurrentThreadScope disableMallocRestrictions;
+        RunLoop::main().dispatch([logIdentifier = LOGIDENTIFIER, sampleCount, this, protectedThis = makeRefPtr(*this)] {
+            ALWAYS_LOG(logIdentifier, "needed more data, pushing ", sampleCount, " samples");
+        });
+    }
     m_ringBuffer->store(sampleBufferList, sampleCount, sampleTime.timeValue());
     m_lastPushedSampleCount = sampleCount;
 }
@@ -255,6 +262,13 @@
     timeStamp += m_outputSampleOffset;
 
     if (timeStamp < startFrame || timeStamp + sampleCount > endFrame) {
+        if (!m_isInNeedOfMoreData) {
+            m_isInNeedOfMoreData = true;
+            DisableMallocRestrictionsForCurrentThreadScope disableMallocRestrictions;
+            RunLoop::main().dispatch([logIdentifier = LOGIDENTIFIER, timeStamp, startFrame, endFrame, sampleCount, outputSampleOffset = m_outputSampleOffset, this, protectedThis = makeRefPtr(*this)] {
+                ERROR_LOG(logIdentifier, "need more data, sample ", timeStamp, " with offset ", outputSampleOffset, ", trying to get ", sampleCount, " samples, but not completely in range [", startFrame, " .. ", endFrame, "]");
+            });
+        }
         if (timeStamp < startFrame || timeStamp >= endFrame) {
             // We are out of the window, let's restart the offset computation.
             m_shouldComputeOutputSampleOffset = true;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to