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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012, Google Inc. All rights reserved. 2 * Copyright (C) 2012, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 void AudioScheduledSourceNode::finish() 173 void AudioScheduledSourceNode::finish()
174 { 174 {
175 if (m_playbackState != FINISHED_STATE) { 175 if (m_playbackState != FINISHED_STATE) {
176 // Let the context dereference this AudioNode. 176 // Let the context dereference this AudioNode.
177 context()->notifyNodeFinishedProcessing(this); 177 context()->notifyNodeFinishedProcessing(this);
178 m_playbackState = FINISHED_STATE; 178 m_playbackState = FINISHED_STATE;
179 context()->decrementActiveSourceCount(); 179 context()->decrementActiveSourceCount();
180 } 180 }
181 181
182 if (m_hasEndedListener) 182 if (m_hasEndedListener) {
183 // Reference ourself so we don't accidentally get deleted before notifyE nded gets called.
184 ref();
haraken 2013/09/05 23:42:44 You can just set m_playing to true, and...
183 callOnMainThread(&AudioScheduledSourceNode::notifyEndedDispatch, this); 185 callOnMainThread(&AudioScheduledSourceNode::notifyEndedDispatch, this);
186 }
184 } 187 }
185 188
186 void AudioScheduledSourceNode::notifyEndedDispatch(void* userData) 189 void AudioScheduledSourceNode::notifyEndedDispatch(void* userData)
187 { 190 {
188 static_cast<AudioScheduledSourceNode*>(userData)->notifyEnded(); 191 static_cast<AudioScheduledSourceNode*>(userData)->notifyEnded();
189 } 192 }
190 193
191 void AudioScheduledSourceNode::notifyEnded() 194 void AudioScheduledSourceNode::notifyEnded()
192 { 195 {
193 RefPtr<Event> event = Event::create(eventNames().endedEvent); 196 // Avoid firing the event if the document has already gone away.
194 event->setTarget(this); 197 if (context()->scriptExecutionContext()) {
195 dispatchEvent(event.get()); 198 RefPtr<Event> event = Event::create(eventNames().endedEvent);
199 event->setTarget(this);
200 dispatchEvent(event.get());
201 }
202
203 // Deref to match the ref() call in finish();
204 deref();
haraken 2013/09/05 23:42:44 ... set m_playing to false here. Then you can imp
196 } 205 }
197 206
198 } // namespace WebCore 207 } // namespace WebCore
199 208
200 #endif // ENABLE(WEB_AUDIO) 209 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698