| 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 callOnMainThread(&AudioScheduledSourceNode::notifyEndedDispatch, this); | 183 // |task| will keep the AudioScheduledSourceNode alive until the listene
r has been handled. |
| 184 OwnPtr<NotifyEndedTask> task = adoptPtr(new NotifyEndedTask(this)); |
| 185 callOnMainThread(&AudioScheduledSourceNode::notifyEndedDispatch, task.le
akPtr()); |
| 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 OwnPtr<NotifyEndedTask> task = adoptPtr(static_cast<NotifyEndedTask*>(userDa
ta)); |
| 192 |
| 193 task->notifyEnded(); |
| 189 } | 194 } |
| 190 | 195 |
| 191 void AudioScheduledSourceNode::notifyEnded() | 196 AudioScheduledSourceNode::NotifyEndedTask::NotifyEndedTask(PassRefPtr<AudioSched
uledSourceNode> sourceNode) |
| 197 : m_scheduledNode(sourceNode) |
| 198 { |
| 199 } |
| 200 |
| 201 void AudioScheduledSourceNode::NotifyEndedTask::notifyEnded() |
| 192 { | 202 { |
| 193 RefPtr<Event> event = Event::create(eventNames().endedEvent, FALSE, FALSE); | 203 RefPtr<Event> event = Event::create(eventNames().endedEvent, FALSE, FALSE); |
| 194 event->setTarget(this); | 204 event->setTarget(m_scheduledNode); |
| 195 dispatchEvent(event.get()); | 205 m_scheduledNode->dispatchEvent(event.get()); |
| 196 } | 206 } |
| 197 | 207 |
| 198 } // namespace WebCore | 208 } // namespace WebCore |
| 199 | 209 |
| 200 #endif // ENABLE(WEB_AUDIO) | 210 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |