| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 { | 138 { |
| 139 ASSERT(isMainThread()); | 139 ASSERT(isMainThread()); |
| 140 | 140 |
| 141 if (m_playbackState != UNSCHEDULED_STATE) { | 141 if (m_playbackState != UNSCHEDULED_STATE) { |
| 142 exceptionState.throwDOMException( | 142 exceptionState.throwDOMException( |
| 143 InvalidStateError, | 143 InvalidStateError, |
| 144 "cannot call start more than once."); | 144 "cannot call start more than once."); |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 | 147 |
| 148 if (!std::isfinite(when) || (when < 0)) { | 148 if (when < 0) { |
| 149 exceptionState.throwDOMException( | 149 exceptionState.throwDOMException( |
| 150 InvalidAccessError, | 150 InvalidAccessError, |
| 151 "Start time must be a finite non-negative number: " + String::number
(when)); | 151 "Start time must be a finite non-negative number: " + String::number
(when)); |
| 152 return; | 152 return; |
| 153 } | 153 } |
| 154 | 154 |
| 155 // The node is started. Add a reference to keep us alive so that audio will
eventually get | 155 // The node is started. Add a reference to keep us alive so that audio will
eventually get |
| 156 // played even if Javascript should drop all references to this node. The re
ference will get | 156 // played even if Javascript should drop all references to this node. The re
ference will get |
| 157 // dropped when the source has finished playing. | 157 // dropped when the source has finished playing. |
| 158 context()->refNode(this); | 158 context()->refNode(this); |
| 159 | 159 |
| 160 m_startTime = when; | 160 m_startTime = when; |
| 161 m_playbackState = SCHEDULED_STATE; | 161 m_playbackState = SCHEDULED_STATE; |
| 162 } | 162 } |
| 163 | 163 |
| 164 void AudioScheduledSourceNode::stop(double when, ExceptionState& exceptionState) | 164 void AudioScheduledSourceNode::stop(double when, ExceptionState& exceptionState) |
| 165 { | 165 { |
| 166 ASSERT(isMainThread()); | 166 ASSERT(isMainThread()); |
| 167 | 167 |
| 168 if (m_playbackState == UNSCHEDULED_STATE) { | 168 if (m_playbackState == UNSCHEDULED_STATE) { |
| 169 exceptionState.throwDOMException( | 169 exceptionState.throwDOMException( |
| 170 InvalidStateError, | 170 InvalidStateError, |
| 171 "cannot call stop without calling start first."); | 171 "cannot call stop without calling start first."); |
| 172 return; | 172 return; |
| 173 } | 173 } |
| 174 | 174 |
| 175 if (!std::isfinite(when) || (when < 0)) { | 175 if (when < 0) { |
| 176 exceptionState.throwDOMException( | 176 exceptionState.throwDOMException( |
| 177 InvalidAccessError, | 177 InvalidAccessError, |
| 178 "Stop time must be a finite non-negative number: " + String::number(
when)); | 178 "Stop time must be a non-negative number: " + String::number(when)); |
| 179 return; | 179 return; |
| 180 } | 180 } |
| 181 | 181 |
| 182 // stop() can be called more than once, with the last call to stop taking ef
fect, unless the | 182 // stop() can be called more than once, with the last call to stop taking ef
fect, unless the |
| 183 // source has already stopped due to earlier calls to stop. No exceptions ar
e thrown in any | 183 // source has already stopped due to earlier calls to stop. No exceptions ar
e thrown in any |
| 184 // case. | 184 // case. |
| 185 when = std::max(0.0, when); | 185 when = std::max(0.0, when); |
| 186 m_endTime = when; | 186 m_endTime = when; |
| 187 } | 187 } |
| 188 | 188 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 210 } | 210 } |
| 211 | 211 |
| 212 void AudioScheduledSourceNode::notifyEnded() | 212 void AudioScheduledSourceNode::notifyEnded() |
| 213 { | 213 { |
| 214 dispatchEvent(Event::create(EventTypeNames::ended)); | 214 dispatchEvent(Event::create(EventTypeNames::ended)); |
| 215 } | 215 } |
| 216 | 216 |
| 217 } // namespace blink | 217 } // namespace blink |
| 218 | 218 |
| 219 #endif // ENABLE(WEB_AUDIO) | 219 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |