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)); |
} |
} |