Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) |
| OLD | NEW |