Title: [274432] trunk/Source/WebCore
Revision
274432
Author
cdu...@apple.com
Date
2021-03-15 12:51:21 -0700 (Mon, 15 Mar 2021)

Log Message

Avoid doing a heap allocation in AudioParam::calculateFinalValues() on the audio thread
https://bugs.webkit.org/show_bug.cgi?id=223197
<rdar://60700260>

Reviewed by Jer Noble.

Avoid doing a heap allocation in AudioParam::calculateFinalValues() on the audio thread, for
performance reasons.

* Modules/webaudio/AudioParam.cpp:
(WebCore::AudioParam::AudioParam):
(WebCore::AudioParam::calculateFinalValues):
* Modules/webaudio/AudioParam.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (274431 => 274432)


--- trunk/Source/WebCore/ChangeLog	2021-03-15 19:34:59 UTC (rev 274431)
+++ trunk/Source/WebCore/ChangeLog	2021-03-15 19:51:21 UTC (rev 274432)
@@ -1,5 +1,21 @@
 2021-03-15  Chris Dumez  <cdu...@apple.com>
 
+        Avoid doing a heap allocation in AudioParam::calculateFinalValues() on the audio thread
+        https://bugs.webkit.org/show_bug.cgi?id=223197
+        <rdar://60700260>
+
+        Reviewed by Jer Noble.
+
+        Avoid doing a heap allocation in AudioParam::calculateFinalValues() on the audio thread, for
+        performance reasons.
+
+        * Modules/webaudio/AudioParam.cpp:
+        (WebCore::AudioParam::AudioParam):
+        (WebCore::AudioParam::calculateFinalValues):
+        * Modules/webaudio/AudioParam.h:
+
+2021-03-15  Chris Dumez  <cdu...@apple.com>
+
         Stop calling [NSHTTPCookieStorage sharedHTTPCookieStorage] in the WebProcess
         https://bugs.webkit.org/show_bug.cgi?id=223186
         <rdar://75018105>

Modified: trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp (274431 => 274432)


--- trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp	2021-03-15 19:34:59 UTC (rev 274431)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp	2021-03-15 19:51:21 UTC (rev 274432)
@@ -49,6 +49,7 @@
     , m_automationRate(automationRate)
     , m_automationRateMode(automationRateMode)
     , m_smoothedValue(defaultValue)
+    , m_summingBus(AudioBus::create(1, AudioUtilities::renderQuantumSize, false).releaseNonNull())
 #if !RELEASE_LOG_DISABLED
     , m_logger(context.logger())
     , m_logIdentifier(context.nextAudioParameterLogIdentifier())
@@ -274,12 +275,11 @@
 
     // Now sum all of the audio-rate connections together (unity-gain summing junction).
     // Note that connections would normally be mono, but we mix down to mono if necessary.
-    auto summingBus = AudioBus::create(1, numberOfValues, false);
-
     // If we're not sample accurate, we only need one value, so make the summing
     // bus have length 1. When the connections are added in, only the first
     // value will be added. Which is exactly what we want.
-    summingBus->setChannelMemory(0, values, sampleAccurate ? numberOfValues : 1);
+    ASSERT(numberOfValues <= AudioUtilities::renderQuantumSize);
+    m_summingBus->setChannelMemory(0, values, sampleAccurate ? numberOfValues : 1);
 
     for (auto& output : m_renderingOutputs) {
         ASSERT(output);
@@ -288,7 +288,7 @@
         AudioBus* connectionBus = output->pull(0, AudioUtilities::renderQuantumSize);
 
         // Sum, with unity-gain.
-        summingBus->sumFrom(*connectionBus);
+        m_summingBus->sumFrom(*connectionBus);
     }
 
     // If we're not sample accurate, duplicate the first element of |values| to all of the elements.

Modified: trunk/Source/WebCore/Modules/webaudio/AudioParam.h (274431 => 274432)


--- trunk/Source/WebCore/Modules/webaudio/AudioParam.h	2021-03-15 19:34:59 UTC (rev 274431)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParam.h	2021-03-15 19:51:21 UTC (rev 274432)
@@ -143,6 +143,7 @@
     float m_smoothedValue;
     
     AudioParamTimeline m_timeline;
+    Ref<AudioBus> m_summingBus;
 
 #if !RELEASE_LOG_DISABLED
     mutable Ref<const Logger> m_logger;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to