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

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

Issue 23596014: Keep AudioScheduledSourceNode alive until onended is called. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Implement ActiveDOMObject::stop() Created 7 years, 3 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 | « Source/modules/webaudio/AudioScheduledSourceNode.h ('k') | Source/modules/webaudio/OscillatorNode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/AudioScheduledSourceNode.cpp
diff --git a/Source/modules/webaudio/AudioScheduledSourceNode.cpp b/Source/modules/webaudio/AudioScheduledSourceNode.cpp
index 39e06e752610f0a599276debad244fa76455983c..072873155ef241052f6f560a18a203b6418e440c 100644
--- a/Source/modules/webaudio/AudioScheduledSourceNode.cpp
+++ b/Source/modules/webaudio/AudioScheduledSourceNode.cpp
@@ -42,10 +42,12 @@ const double AudioScheduledSourceNode::UnknownTime = -1;
AudioScheduledSourceNode::AudioScheduledSourceNode(AudioContext* context, float sampleRate)
: AudioSourceNode(context, sampleRate)
+ , ActiveDOMObject(context->scriptExecutionContext())
, m_playbackState(UNSCHEDULED_STATE)
, m_startTime(0)
, m_endTime(UnknownTime)
, m_hasEndedListener(false)
+ , m_notifyingEndedListener(false)
{
}
@@ -144,7 +146,7 @@ void AudioScheduledSourceNode::start(double when)
m_playbackState = SCHEDULED_STATE;
}
-void AudioScheduledSourceNode::stop(double when)
+void AudioScheduledSourceNode::stopNote(double when)
{
ASSERT(isMainThread());
if (!(m_playbackState == SCHEDULED_STATE || m_playbackState == PLAYING_STATE))
@@ -161,7 +163,7 @@ void AudioScheduledSourceNode::noteOn(double when)
void AudioScheduledSourceNode::noteOff(double when)
{
- stop(when);
+ stopNote(when);
}
void AudioScheduledSourceNode::setOnended(PassRefPtr<EventListener> listener, DOMWrapperWorld* isolatedWorld)
@@ -180,8 +182,8 @@ void AudioScheduledSourceNode::finish()
}
if (m_hasEndedListener) {
- // Reference ourself so we don't accidentally get deleted before notifyEnded gets called.
- ref();
+ m_notifyingEndedListener = true;
+ setPendingActivity(this);
callOnMainThread(&AudioScheduledSourceNode::notifyEndedDispatch, this);
}
}
@@ -199,9 +201,19 @@ void AudioScheduledSourceNode::notifyEnded()
event->setTarget(this);
dispatchEvent(event.get());
}
+ m_notifyingEndedListener = false;
+ unsetPendingActivity(this);
+}
- // Deref to match the ref() call in finish();
- deref();
+ScriptExecutionContext* AudioScheduledSourceNode::scriptExecutionContext() const
+{
+ return context()->scriptExecutionContext();
+}
+
+void AudioScheduledSourceNode::stop()
+{
+ if (m_notifyingEndedListener)
haraken 2013/09/09 17:58:51 How about just using hasPendingActivity() instead
Raymond Toy (Google) 2013/09/09 18:23:45 Done. m_notifyingEndedListener removed.
+ unsetPendingActivity(this);
}
} // namespace WebCore
« no previous file with comments | « Source/modules/webaudio/AudioScheduledSourceNode.h ('k') | Source/modules/webaudio/OscillatorNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698