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

Unified Diff: third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp

Issue 2582443004: ScriptProcessor buffer size should be consistent with callback size (Closed)
Patch Set: Make callbackBufferSize pure virtual Created 4 years 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
Index: third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp b/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp
index d6cf6f581e305199816c5fc51889de243c528396..316d05224f01b60ab90ad59ddaa6fd176b235338 100644
--- a/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/ScriptProcessorNode.cpp
@@ -343,14 +343,13 @@ ScriptProcessorNode::ScriptProcessorNode(BaseAudioContext& context,
numberOfOutputChannels));
}
-static size_t chooseBufferSize() {
+static size_t chooseBufferSize(size_t callbackBufferSize) {
// Choose a buffer size based on the audio hardware buffer size. Arbitarily
// make it a power of two that is 4 times greater than the hardware buffer
// size.
// FIXME: What is the best way to choose this?
- size_t hardwareBufferSize = Platform::current()->audioHardwareBufferSize();
size_t bufferSize =
- 1 << static_cast<unsigned>(log2(4 * hardwareBufferSize) + 0.5);
+ 1 << static_cast<unsigned>(log2(4 * callbackBufferSize) + 0.5);
if (bufferSize < 256)
return 256;
@@ -432,7 +431,14 @@ ScriptProcessorNode* ScriptProcessorNode::create(
// Check for valid buffer size.
switch (bufferSize) {
case 0:
- bufferSize = chooseBufferSize();
+ // Choose an appropriate size. For an AudioContext, we need to
+ // choose an appropriate size based on the callback buffer size.
+ // For OfflineAudioContext, there's no callback buffer size, so
+ // just use the minimum valid buffer size.
+ bufferSize =
+ context.hasRealtimeConstraint()
+ ? chooseBufferSize(context.destination()->callbackBufferSize())
+ : 256;
break;
case 256:
case 512:

Powered by Google App Engine
This is Rietveld 408576698