Title: [276301] trunk/Source/WebCore
Revision
276301
Author
[email protected]
Date
2021-04-20 04:38:39 -0700 (Tue, 20 Apr 2021)

Log Message

AudioSourceProviderAVFObjC uses atomic variables but also locks with mutex
https://bugs.webkit.org/show_bug.cgi?id=224543

Patch by Kimmo Kinnunen <[email protected]> on 2021-04-20
Reviewed by Darin Adler.

Remove the use of std::atomic, the variables are already protected by the
mutex.

* platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h:
* platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
(WebCore::AudioSourceProviderAVFObjC::provideInput):
(WebCore::AudioSourceProviderAVFObjC::process):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (276300 => 276301)


--- trunk/Source/WebCore/ChangeLog	2021-04-20 11:29:33 UTC (rev 276300)
+++ trunk/Source/WebCore/ChangeLog	2021-04-20 11:38:39 UTC (rev 276301)
@@ -1,3 +1,18 @@
+2021-04-20  Kimmo Kinnunen  <[email protected]>
+
+        AudioSourceProviderAVFObjC uses atomic variables but also locks with mutex
+        https://bugs.webkit.org/show_bug.cgi?id=224543
+
+        Reviewed by Darin Adler.
+
+        Remove the use of std::atomic, the variables are already protected by the
+        mutex.
+
+        * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h:
+        * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
+        (WebCore::AudioSourceProviderAVFObjC::provideInput):
+        (WebCore::AudioSourceProviderAVFObjC::process):
+
 2021-04-20  Martin Robinson  <[email protected]>
 
         Re-land: Eliminate ScrollAnimatorGeneric::m_smoothAnimation

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h (276300 => 276301)


--- trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h	2021-04-20 11:29:33 UTC (rev 276300)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.h	2021-04-20 11:38:39 UTC (rev 276301)
@@ -28,7 +28,6 @@
 #if ENABLE(WEB_AUDIO) && USE(MEDIATOOLBOX)
 
 #include "AudioSourceProvider.h"
-#include <atomic>
 #include <wtf/MediaTime.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/ThreadSafeRefCounted.h>
@@ -101,10 +100,10 @@
 
     MediaTime m_startTimeAtLastProcess;
     MediaTime m_endTimeAtLastProcess;
-    std::atomic<uint64_t> m_writeAheadCount { 0 };
+    uint64_t m_writeAheadCount { 0 };
     uint64_t m_readCount { 0 };
     enum { NoSeek = std::numeric_limits<uint64_t>::max() };
-    std::atomic<uint64_t> m_seekTo { NoSeek };
+    uint64_t m_seekTo { NoSeek };
     bool m_paused { true };
     AudioSourceProviderClient* m_client { nullptr };
     WeakPtrFactory<AudioSourceProviderAVFObjC> m_weakFactory;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm (276300 => 276301)


--- trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm	2021-04-20 11:29:33 UTC (rev 276300)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm	2021-04-20 11:38:39 UTC (rev 276301)
@@ -110,8 +110,7 @@
 
     uint64_t startFrame = 0;
     uint64_t endFrame = 0;
-    uint64_t seekTo = m_seekTo.exchange(NoSeek);
-    uint64_t writeAheadCount = m_writeAheadCount.load();
+    uint64_t seekTo = std::exchange(m_seekTo, NoSeek);
     if (seekTo != NoSeek)
         m_readCount = seekTo;
 
@@ -120,7 +119,7 @@
     if (!m_readCount || m_readCount == seekTo) {
         // We have not started rendering yet. If there aren't enough frames in the buffer, then output
         // silence until there is.
-        if (endFrame <= m_readCount + writeAheadCount + framesToProcess) {
+        if (endFrame <= m_readCount + m_writeAheadCount + framesToProcess) {
             bus->zero();
             return;
         }
@@ -376,7 +375,7 @@
         // Only check the write-ahead time when playback begins.
         m_paused = false;
         MediaTime earlyBy = rangeStart - currentTime;
-        m_writeAheadCount.store(m_tapDescription->mSampleRate * earlyBy.toDouble());
+        m_writeAheadCount = m_tapDescription->mSampleRate * earlyBy.toDouble();
     }
 
     uint64_t startFrame = 0;
@@ -386,7 +385,7 @@
     // Check to see if the underlying media has seeked, which would require us to "flush"
     // our outstanding buffers.
     if (rangeStart != m_endTimeAtLastProcess)
-        m_seekTo.store(endFrame);
+        m_seekTo = endFrame;
 
     m_startTimeAtLastProcess = rangeStart;
     m_endTimeAtLastProcess = rangeStart + rangeDuration;
@@ -394,7 +393,7 @@
     // StartOfStream indicates a discontinuity, such as when an AVPlayerItem is re-added
     // to an AVPlayer, so "flush" outstanding buffers.
     if (flagsOut && *flagsOut & kMTAudioProcessingTapFlag_StartOfStream)
-        m_seekTo.store(endFrame);
+        m_seekTo = endFrame;
 
     m_ringBuffer->store(bufferListInOut, itemCount, endFrame);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to