Index: Source/modules/webaudio/AudioScheduledSourceNode.cpp |
diff --git a/Source/modules/webaudio/AudioScheduledSourceNode.cpp b/Source/modules/webaudio/AudioScheduledSourceNode.cpp |
index d853761f1b983b2da6e9abf08075d2c58e9f99da..7c3db4dd361cfdcf38500906d5ed6d6338e4e7ea 100644 |
--- a/Source/modules/webaudio/AudioScheduledSourceNode.cpp |
+++ b/Source/modules/webaudio/AudioScheduledSourceNode.cpp |
@@ -41,9 +41,9 @@ const double AudioScheduledSourceHandler::UnknownTime = -1; |
AudioScheduledSourceHandler::AudioScheduledSourceHandler(NodeType nodeType, AudioNode& node, float sampleRate) |
: AudioHandler(nodeType, node, sampleRate) |
+ , m_hasEndedListener(false) |
, m_startTime(0) |
, m_endTime(UnknownTime) |
- , m_hasEndedListener(false) |
, m_playbackState(UNSCHEDULED_STATE) |
{ |
} |
@@ -67,11 +67,12 @@ void AudioScheduledSourceHandler::updateSchedulingInfo( |
// endFrame : End frame for this source. |
size_t quantumStartFrame = context()->currentSampleFrame(); |
size_t quantumEndFrame = quantumStartFrame + quantumFrameSize; |
- size_t startFrame = AudioUtilities::timeToSampleFrame(m_startTime, sampleRate); |
- size_t endFrame = m_endTime == UnknownTime ? 0 : AudioUtilities::timeToSampleFrame(m_endTime, sampleRate); |
+ size_t startFrame = AudioUtilities::timeToSampleFrame(startTime(), sampleRate); |
+ double currentEndTime = endTime(); |
+ size_t endFrame = currentEndTime == UnknownTime ? 0 : AudioUtilities::timeToSampleFrame(currentEndTime, sampleRate); |
// If we know the end time and it's already passed, then don't bother doing any more rendering this cycle. |
- if (m_endTime != UnknownTime && endFrame <= quantumStartFrame) |
+ if (currentEndTime != UnknownTime && endFrame <= quantumStartFrame) |
finish(); |
PlaybackState state = playbackState(); |
@@ -109,7 +110,7 @@ void AudioScheduledSourceHandler::updateSchedulingInfo( |
// Handle silence after we're done playing. |
// If the end time is somewhere in the middle of this time quantum, then zero out the |
// frames from the end time to the very end of the quantum. |
- if (m_endTime != UnknownTime && endFrame >= quantumStartFrame && endFrame < quantumEndFrame) { |
+ if (currentEndTime != UnknownTime && endFrame >= quantumStartFrame && endFrame < quantumEndFrame) { |
size_t zeroStartFrame = endFrame - quantumStartFrame; |
size_t framesToZero = quantumFrameSize - zeroStartFrame; |
@@ -160,7 +161,7 @@ void AudioScheduledSourceHandler::start(double when, ExceptionState& exceptionSt |
// If |when| < currentTime, the source must start now according to the spec. |
// So just set startTime to currentTime in this case to start the source now. |
- m_startTime = std::max(when, context()->currentTime()); |
+ setStartTime(std::max(when, context()->currentTime())); |
setPlaybackState(SCHEDULED_STATE); |
} |
@@ -190,7 +191,7 @@ void AudioScheduledSourceHandler::stop(double when, ExceptionState& exceptionSta |
// source has already stopped due to earlier calls to stop. No exceptions are thrown in any |
// case. |
when = std::max(0.0, when); |
- m_endTime = when; |
+ setEndTime(when); |
} |
void AudioScheduledSourceHandler::finishWithoutOnEnded() |