Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Unified Diff: third_party/WebKit/Source/platform/audio/Biquad.cpp

Issue 2033503004: Avoid slow AudioParam automation path when possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/GainNode.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/audio/Biquad.cpp
diff --git a/third_party/WebKit/Source/platform/audio/Biquad.cpp b/third_party/WebKit/Source/platform/audio/Biquad.cpp
index f29e77aa3d5091f16176b7036447c38c9bbd7920..ca587bb77b960b106735217f5d4c452105888014 100644
--- a/third_party/WebKit/Source/platform/audio/Biquad.cpp
+++ b/third_party/WebKit/Source/platform/audio/Biquad.cpp
@@ -74,6 +74,8 @@ Biquad::~Biquad()
void Biquad::process(const float* sourceP, float* destP, size_t framesToProcess)
{
+ // WARNING: sourceP and destP may be pointing to the same area of memory!
+ // Be sure to read from sourceP before writing to destP!
if (hasSampleAccurateValues()) {
int n = framesToProcess;
@@ -120,14 +122,28 @@ void Biquad::process(const float* sourceP, float* destP, size_t framesToProcess)
// how to update them anyway.
} else {
#if OS(MACOSX)
+ double* inputP = m_inputBuffer.data();
+ double* outputP = m_outputBuffer.data();
+
+ // Set up filter state. This is needed in case we're switching from
+ // filtering with variable coefficients (i.e., with automations) to
+ // fixed coefficients (without automations).
+ inputP[0] = m_x2;
+ inputP[1] = m_x1;
+ outputP[0] = m_y2;
+ outputP[1] = m_y1;
+
// Use vecLib if available
processFast(sourceP, destP, framesToProcess);
- // Copy the last inputs and outputs to the filter memory variables. This is needed because
- // the next rendering quantum might be an automation which needs the history to continue
- // correctly.
- m_x1 = sourceP[framesToProcess - 1];
- m_x2 = sourceP[framesToProcess - 2];
+ // Copy the last inputs and outputs to the filter memory variables.
+ // This is needed because the next rendering quantum might be an
+ // automation which needs the history to continue correctly. Because
+ // sourceP and destP can be the same block of memory, we can't read from
+ // sourceP to get the last inputs. Fortunately, processFast has put the
+ // last inputs in input[0] and input[1].
+ m_x1 = inputP[1];
+ m_x2 = inputP[0];
m_y1 = destP[framesToProcess - 1];
m_y2 = destP[framesToProcess - 2];
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/GainNode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698