Title: [278264] trunk/Source/WebCore
Revision
278264
Author
cdu...@apple.com
Date
2021-05-30 19:02:22 -0700 (Sun, 30 May 2021)

Log Message

Remove some dead code from BaseAudioContext / AudioContext
https://bugs.webkit.org/show_bug.cgi?id=226441

Reviewed by Sam Weinig.

* Modules/webaudio/AudioContext.h:
* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::connect):
* Modules/webaudio/AudioScheduledSourceNode.cpp:
(WebCore::AudioScheduledSourceNode::updateSchedulingInfo):
(WebCore::AudioScheduledSourceNode::finish):
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::sourceNodeWillBeginPlayback):
(WebCore::BaseAudioContext::refSourceNode): Deleted.
(WebCore::BaseAudioContext::derefSourceNode): Deleted.
(WebCore::BaseAudioContext::incrementActiveSourceCount): Deleted.
(WebCore::BaseAudioContext::decrementActiveSourceCount): Deleted.
* Modules/webaudio/BaseAudioContext.h:
(WebCore::BaseAudioContext::sampleRate const):
(WebCore::BaseAudioContext::activeSourceCount const): Deleted.
(WebCore::BaseAudioContext::incrementConnectionCount): Deleted.
(WebCore::BaseAudioContext::connectionCount const): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (278263 => 278264)


--- trunk/Source/WebCore/ChangeLog	2021-05-31 00:57:49 UTC (rev 278263)
+++ trunk/Source/WebCore/ChangeLog	2021-05-31 02:02:22 UTC (rev 278264)
@@ -1,5 +1,30 @@
 2021-05-30  Chris Dumez  <cdu...@apple.com>
 
+        Remove some dead code from BaseAudioContext / AudioContext
+        https://bugs.webkit.org/show_bug.cgi?id=226441
+
+        Reviewed by Sam Weinig.
+
+        * Modules/webaudio/AudioContext.h:
+        * Modules/webaudio/AudioNode.cpp:
+        (WebCore::AudioNode::connect):
+        * Modules/webaudio/AudioScheduledSourceNode.cpp:
+        (WebCore::AudioScheduledSourceNode::updateSchedulingInfo):
+        (WebCore::AudioScheduledSourceNode::finish):
+        * Modules/webaudio/BaseAudioContext.cpp:
+        (WebCore::BaseAudioContext::sourceNodeWillBeginPlayback):
+        (WebCore::BaseAudioContext::refSourceNode): Deleted.
+        (WebCore::BaseAudioContext::derefSourceNode): Deleted.
+        (WebCore::BaseAudioContext::incrementActiveSourceCount): Deleted.
+        (WebCore::BaseAudioContext::decrementActiveSourceCount): Deleted.
+        * Modules/webaudio/BaseAudioContext.h:
+        (WebCore::BaseAudioContext::sampleRate const):
+        (WebCore::BaseAudioContext::activeSourceCount const): Deleted.
+        (WebCore::BaseAudioContext::incrementConnectionCount): Deleted.
+        (WebCore::BaseAudioContext::connectionCount const): Deleted.
+
+2021-05-30  Chris Dumez  <cdu...@apple.com>
+
         Unreviewed, tweak slightly incorrect assertion added in r278233.
 
         The assertion was hitting flakily on the bots.

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.h (278263 => 278264)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2021-05-31 00:57:49 UTC (rev 278263)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.h	2021-05-31 02:02:22 UTC (rev 278264)
@@ -107,8 +107,8 @@
 
     void constructCommon();
 
-    bool userGestureRequiredForAudioStart() const { return !isOfflineContext() && m_restrictions & RequireUserGestureForAudioStartRestriction; }
-    bool pageConsentRequiredForAudioStart() const { return !isOfflineContext() && m_restrictions & RequirePageConsentForAudioStartRestriction; }
+    bool userGestureRequiredForAudioStart() const { return m_restrictions & RequireUserGestureForAudioStartRestriction; }
+    bool pageConsentRequiredForAudioStart() const { return m_restrictions & RequirePageConsentForAudioStartRestriction; }
 
     bool willPausePlayback();
 

Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp (278263 => 278264)


--- trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp	2021-05-31 00:57:49 UTC (rev 278263)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp	2021-05-31 02:02:22 UTC (rev 278264)
@@ -203,9 +203,6 @@
 
     input->connect(output);
 
-    // Let context know that a connection has been made.
-    context().incrementConnectionCount();
-
     updatePullStatus();
 
     return { };

Modified: trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp (278263 => 278264)


--- trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp	2021-05-31 00:57:49 UTC (rev 278263)
+++ trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp	2021-05-31 02:02:22 UTC (rev 278264)
@@ -100,7 +100,6 @@
         // NOTE: startFrameOffset is usually negative, but may not be because of
         // the rounding that may happen in computing |startFrame| above.
         startFrameOffset = m_startTime * sampleRate - startFrame;
-        context().incrementActiveSourceCount();
     }
 
     quantumFrameOffset = startFrame > quantumStartFrame ? startFrame - quantumStartFrame : 0;
@@ -197,7 +196,6 @@
     // Let the context dereference this AudioNode.
     context().sourceNodeDidFinishPlayback(*this);
     m_playbackState = FINISHED_STATE;
-    context().decrementActiveSourceCount();
 
     // Heap allocations are forbidden on the audio thread for performance reasons so we need to
     // explicitly allow the following allocation(s).

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp (278263 => 278264)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2021-05-31 00:57:49 UTC (rev 278263)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2021-05-31 02:02:22 UTC (rev 278264)
@@ -523,24 +523,6 @@
     m_hasFinishedAudioSourceNodes = false;
 }
 
-void BaseAudioContext::refSourceNode(AudioNode& node)
-{
-    ASSERT(isMainThread());
-    Locker locker { graphLock() };
-
-    ASSERT(!m_referencedSourceNodes.contains(&node));
-    // Reference source node to keep it alive and playing even if its JS wrapper gets garbage collected.
-    m_referencedSourceNodes.append(&node);
-}
-
-void BaseAudioContext::derefSourceNode(AudioNode& node)
-{
-    ASSERT(isGraphOwner());
-    
-    ASSERT(m_referencedSourceNodes.contains(&node));
-    m_referencedSourceNodes.removeFirst(&node);
-}
-
 void BaseAudioContext::derefUnfinishedSourceNodes()
 {
     ASSERT(isMainThread() && isAudioThreadFinished());
@@ -877,16 +859,6 @@
     return ActiveDOMObject::scriptExecutionContext();
 }
 
-void BaseAudioContext::incrementActiveSourceCount()
-{
-    ++m_activeSourceCount;
-}
-
-void BaseAudioContext::decrementActiveSourceCount()
-{
-    --m_activeSourceCount;
-}
-
 void BaseAudioContext::postTask(Function<void()>&& task)
 {
     ASSERT(isMainThread());
@@ -952,7 +924,12 @@
 
 void BaseAudioContext::sourceNodeWillBeginPlayback(AudioNode& node)
 {
-    refSourceNode(node);
+    ASSERT(isMainThread());
+    Locker locker { graphLock() };
+
+    ASSERT(!m_referencedSourceNodes.contains(&node));
+    // Reference source node to keep it alive and playing even if its JS wrapper gets garbage collected.
+    m_referencedSourceNodes.append(&node);
 }
 
 void BaseAudioContext::sourceNodeDidFinishPlayback(AudioNode& node)

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h (278263 => 278264)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h	2021-05-31 00:57:49 UTC (rev 278263)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.h	2021-05-31 02:02:22 UTC (rev 278264)
@@ -110,11 +110,7 @@
     size_t currentSampleFrame() const { return destination().currentSampleFrame(); }
     double currentTime() const { return destination().currentTime(); }
     float sampleRate() const { return destination().sampleRate(); }
-    unsigned long activeSourceCount() const { return static_cast<unsigned long>(m_activeSourceCount); }
 
-    void incrementActiveSourceCount();
-    void decrementActiveSourceCount();
-
     // Asynchronous audio file data decoding.
     void decodeAudioData(Ref<ArrayBuffer>&&, RefPtr<AudioBufferCallback>&&, RefPtr<AudioBufferCallback>&&, std::optional<Ref<DeferredPromise>>&& = std::nullopt);
 
@@ -171,15 +167,6 @@
     // Called right before handlePostRenderTasks() to handle nodes which need to be pulled even when they are not connected to anything.
     void processAutomaticPullNodes(size_t framesToProcess);
 
-    // Keeps track of the number of connections made.
-    void incrementConnectionCount()
-    {
-        ASSERT(isMainThread());
-        ++m_connectionCount;
-    }
-
-    unsigned connectionCount() const { return m_connectionCount; }
-
     //
     // Thread Safety and Graph Locking:
     //
@@ -259,13 +246,6 @@
     void scheduleNodeDeletion();
     void workletIsReady();
 
-    // When source nodes begin playing, the BaseAudioContext keeps them alive inside m_referencedSourceNodes.
-    // When the nodes stop playing, a flag gets set on the AudioNode accordingly. After each rendering quantum,
-    // we call derefFinishedSourceNodes() to remove those nodes from m_referencedSourceNodes since we no longer
-    // need to keep them alive.
-    void refSourceNode(AudioNode&);
-    void derefSourceNode(AudioNode&);
-
     // Called periodically at the end of each render quantum to dereference finished source nodes.
     void derefFinishedSourceNodes();
 
@@ -379,10 +359,6 @@
     RefPtr<PeriodicWave> m_cachedPeriodicWaveSawtooth;
     RefPtr<PeriodicWave> m_cachedPeriodicWaveTriangle;
 
-    // Number of AudioBufferSourceNodes that are active (playing).
-    std::atomic<int> m_activeSourceCount;
-
-    unsigned m_connectionCount { 0 };
     State m_state { State::Suspended };
     bool m_isDeletionScheduled { false };
     bool m_disableOutputsForTailProcessingScheduled { false };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to