| 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 10 matching lines...) Expand all Loading... |
| 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 | 26 |
| 27 #if ENABLE(WEB_AUDIO) | 27 #if ENABLE(WEB_AUDIO) |
| 28 | 28 |
| 29 #include "modules/webaudio/AudioScheduledSourceNode.h" | 29 #include "modules/webaudio/AudioScheduledSourceNode.h" |
| 30 | 30 |
| 31 #include "bindings/v8/ExceptionMessages.h" | |
| 32 #include "bindings/v8/ExceptionState.h" | 31 #include "bindings/v8/ExceptionState.h" |
| 33 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
| 34 #include "core/events/Event.h" | 33 #include "core/events/Event.h" |
| 35 #include "platform/audio/AudioUtilities.h" | 34 #include "platform/audio/AudioUtilities.h" |
| 36 #include "modules/webaudio/AudioContext.h" | 35 #include "modules/webaudio/AudioContext.h" |
| 37 #include <algorithm> | 36 #include <algorithm> |
| 38 #include "wtf/MathExtras.h" | 37 #include "wtf/MathExtras.h" |
| 39 | 38 |
| 40 using namespace std; | 39 using namespace std; |
| 41 | 40 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 138 } |
| 140 | 139 |
| 141 | 140 |
| 142 void AudioScheduledSourceNode::start(double when, ExceptionState& exceptionState
) | 141 void AudioScheduledSourceNode::start(double when, ExceptionState& exceptionState
) |
| 143 { | 142 { |
| 144 ASSERT(isMainThread()); | 143 ASSERT(isMainThread()); |
| 145 | 144 |
| 146 if (m_playbackState != UNSCHEDULED_STATE) { | 145 if (m_playbackState != UNSCHEDULED_STATE) { |
| 147 exceptionState.throwDOMException( | 146 exceptionState.throwDOMException( |
| 148 InvalidStateError, | 147 InvalidStateError, |
| 149 ExceptionMessages::failedToExecute( | 148 "cannot call start more than once."); |
| 150 "start", | |
| 151 "OscillatorNode", | |
| 152 "cannot call start more than once.")); | |
| 153 return; | 149 return; |
| 154 } | 150 } |
| 155 | 151 |
| 156 m_startTime = when; | 152 m_startTime = when; |
| 157 m_playbackState = SCHEDULED_STATE; | 153 m_playbackState = SCHEDULED_STATE; |
| 158 } | 154 } |
| 159 | 155 |
| 160 void AudioScheduledSourceNode::stop(double when, ExceptionState& exceptionState) | 156 void AudioScheduledSourceNode::stop(double when, ExceptionState& exceptionState) |
| 161 { | 157 { |
| 162 ASSERT(isMainThread()); | 158 ASSERT(isMainThread()); |
| 163 | 159 |
| 164 if (m_stopCalled) { | 160 if (m_stopCalled) { |
| 165 exceptionState.throwDOMException( | 161 exceptionState.throwDOMException( |
| 166 InvalidStateError, | 162 InvalidStateError, |
| 167 ExceptionMessages::failedToExecute( | 163 "cannot call stop more than once."); |
| 168 "stop", | |
| 169 "OscillatorNode", | |
| 170 "cannot call stop more than once.")); | |
| 171 } else if (m_playbackState == UNSCHEDULED_STATE) { | 164 } else if (m_playbackState == UNSCHEDULED_STATE) { |
| 172 exceptionState.throwDOMException( | 165 exceptionState.throwDOMException( |
| 173 InvalidStateError, | 166 InvalidStateError, |
| 174 ExceptionMessages::failedToExecute( | 167 "cannot call stop without calling start first."); |
| 175 "stop", | |
| 176 "OscillatorNode", | |
| 177 "cannot call stop without calling start first.")); | |
| 178 } else { | 168 } else { |
| 179 // This can only happen from the SCHEDULED_STATE or PLAYING_STATE. The U
NSCHEDULED_STATE is | 169 // This can only happen from the SCHEDULED_STATE or PLAYING_STATE. The U
NSCHEDULED_STATE is |
| 180 // handled above, and the FINISHED_STATE is only reachable after stop()
has been called, and | 170 // handled above, and the FINISHED_STATE is only reachable after stop()
has been called, and |
| 181 // hence m_stopCalled is true. But that case is handled above. | 171 // hence m_stopCalled is true. But that case is handled above. |
| 182 when = max(0.0, when); | 172 when = max(0.0, when); |
| 183 m_endTime = when; | 173 m_endTime = when; |
| 184 m_stopCalled = true; | 174 m_stopCalled = true; |
| 185 } | 175 } |
| 186 } | 176 } |
| 187 | 177 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 void AudioScheduledSourceNode::NotifyEndedTask::notifyEnded() | 212 void AudioScheduledSourceNode::NotifyEndedTask::notifyEnded() |
| 223 { | 213 { |
| 224 RefPtr<Event> event = Event::create(EventTypeNames::ended); | 214 RefPtr<Event> event = Event::create(EventTypeNames::ended); |
| 225 event->setTarget(m_scheduledNode); | 215 event->setTarget(m_scheduledNode); |
| 226 m_scheduledNode->dispatchEvent(event.get()); | 216 m_scheduledNode->dispatchEvent(event.get()); |
| 227 } | 217 } |
| 228 | 218 |
| 229 } // namespace WebCore | 219 } // namespace WebCore |
| 230 | 220 |
| 231 #endif // ENABLE(WEB_AUDIO) | 221 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |