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

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

Issue 210973002: Supporting a playbackTime attribute on AudioprocessingEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 9 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
Index: Source/modules/webaudio/ScriptProcessorNode.cpp
diff --git a/Source/modules/webaudio/ScriptProcessorNode.cpp b/Source/modules/webaudio/ScriptProcessorNode.cpp
index 79c446c96f432d7f6cfed6d71feae697b7e15993..45bf3a74226b8e3bb4a8d7f328c8a530a99806e9 100644
--- a/Source/modules/webaudio/ScriptProcessorNode.cpp
+++ b/Source/modules/webaudio/ScriptProcessorNode.cpp
@@ -265,8 +265,12 @@ void ScriptProcessorNode::fireProcessEvent()
// Let the audio thread know we've gotten to the point where it's OK for it to make another request.
m_isRequestOutstanding = false;
+ // Calculate a playbackTime with the buffersize which needs to be processed each time onaudioprocess is called.
+ // The outputBuffer being passed to JS will be played after exhuasting previous outputBuffer by double-buffering.
+ double playbackTime = (context()->currentSampleFrame() + m_bufferSize) / static_cast<double>(context()->sampleRate());
+
// Call the JavaScript event handler which will do the audio processing.
- dispatchEvent(AudioProcessingEvent::create(inputBuffer, outputBuffer));
+ dispatchEvent(AudioProcessingEvent::create(inputBuffer, outputBuffer, playbackTime));
}
}

Powered by Google App Engine
This is Rietveld 408576698