| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/webaudio/AudioContext.h" | 5 #include "modules/webaudio/AudioContext.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionMessages.h" | 7 #include "bindings/core/v8/ExceptionMessages.h" |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 if (isContextClosed()) { | 148 if (isContextClosed()) { |
| 149 return ScriptPromise::rejectWithDOMException( | 149 return ScriptPromise::rejectWithDOMException( |
| 150 scriptState, | 150 scriptState, |
| 151 DOMException::create(InvalidAccessError, | 151 DOMException::create(InvalidAccessError, |
| 152 "cannot resume a closed AudioContext")); | 152 "cannot resume a closed AudioContext")); |
| 153 } | 153 } |
| 154 | 154 |
| 155 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 155 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 156 ScriptPromise promise = resolver->promise(); | 156 ScriptPromise promise = resolver->promise(); |
| 157 | 157 |
| 158 // If we're already running, just resolve; nothing else needs to be |
| 159 // done. |
| 160 if (contextState() == Running) { |
| 161 resolver->resolve(); |
| 162 return promise; |
| 163 } |
| 158 // Restart the destination node to pull on the audio graph. | 164 // Restart the destination node to pull on the audio graph. |
| 159 if (destination()) { | 165 if (destination()) { |
| 160 maybeUnlockUserGesture(); | 166 maybeUnlockUserGesture(); |
| 161 if (isAllowedToStart()) { | 167 if (isAllowedToStart()) { |
| 162 // Do not set the state to running here. We wait for the | 168 // Do not set the state to running here. We wait for the |
| 163 // destination to start to set the state. | 169 // destination to start to set the state. |
| 164 startRendering(); | 170 startRendering(); |
| 165 } | 171 } |
| 166 } | 172 } |
| 167 | 173 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 setContextState(Suspended); | 260 setContextState(Suspended); |
| 255 deferredTaskHandler().clearHandlersToBeDeleted(); | 261 deferredTaskHandler().clearHandlersToBeDeleted(); |
| 256 } | 262 } |
| 257 } | 263 } |
| 258 | 264 |
| 259 double AudioContext::baseLatency() const { | 265 double AudioContext::baseLatency() const { |
| 260 return framesPerBuffer() * 2 / static_cast<double>(sampleRate()); | 266 return framesPerBuffer() * 2 / static_cast<double>(sampleRate()); |
| 261 } | 267 } |
| 262 | 268 |
| 263 } // namespace blink | 269 } // namespace blink |
| OLD | NEW |