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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 "cannot call startRendering more than once")); | 205 "cannot call startRendering more than once")); |
| 206 } | 206 } |
| 207 | 207 |
| 208 DCHECK(!is_rendering_started_); | 208 DCHECK(!is_rendering_started_); |
| 209 | 209 |
| 210 complete_resolver_ = ScriptPromiseResolver::Create(script_state); | 210 complete_resolver_ = ScriptPromiseResolver::Create(script_state); |
| 211 | 211 |
| 212 // Start rendering and return the promise. | 212 // Start rendering and return the promise. |
| 213 is_rendering_started_ = true; | 213 is_rendering_started_ = true; |
| 214 SetContextState(kRunning); | 214 SetContextState(kRunning); |
| 215 DestinationHandler().InitializeOfflineRenderThread(); | |
| 215 DestinationHandler().StartRendering(); | 216 DestinationHandler().StartRendering(); |
| 216 | 217 |
| 217 return complete_resolver_->Promise(); | 218 return complete_resolver_->Promise(); |
| 218 } | 219 } |
| 219 | 220 |
| 220 ScriptPromise OfflineAudioContext::suspendContext(ScriptState* script_state) { | 221 ScriptPromise OfflineAudioContext::suspendContext(ScriptState* script_state) { |
| 221 LOG(FATAL) << "This CANNOT be called on OfflineAudioContext; this is only to " | 222 LOG(FATAL) << "This CANNOT be called on OfflineAudioContext; this is only to " |
| 222 "implement the pure virtual interface from BaseAudioContext."; | 223 "implement the pure virtual interface from BaseAudioContext."; |
| 223 return ScriptPromise(); | 224 return ScriptPromise(); |
| 224 } | 225 } |
| 225 | 226 |
| 226 ScriptPromise OfflineAudioContext::suspendContext(ScriptState* script_state, | 227 ScriptPromise OfflineAudioContext::suspendContext(ScriptState* script_state, |
| 227 double when) { | 228 double when) { |
| 228 DCHECK(IsMainThread()); | 229 DCHECK(IsMainThread()); |
| 229 | 230 |
| 230 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); | 231 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); |
| 231 ScriptPromise promise = resolver->Promise(); | 232 ScriptPromise promise = resolver->Promise(); |
| 232 | 233 |
| 233 // The render thread does not exist; reject the promise. | 234 // If the rendering is finished, reject the promise. |
| 234 if (!DestinationHandler().OfflineRenderThread()) { | 235 if (ContextState() == AudioContextState::kClosed) { |
|
Raymond Toy
2017/05/23 20:37:34
Still need a test for this.
hongchan
2017/05/23 20:55:46
https://cs.chromium.org/chromium/src/third_party/W
| |
| 235 resolver->Reject(DOMException::Create(kInvalidStateError, | 236 resolver->Reject(DOMException::Create(kInvalidStateError, |
| 236 "the rendering is already finished")); | 237 "the rendering is already finished")); |
| 237 return promise; | 238 return promise; |
| 238 } | 239 } |
| 239 | 240 |
| 240 // The specified suspend time is negative; reject the promise. | 241 // The specified suspend time is negative; reject the promise. |
| 241 if (when < 0) { | 242 if (when < 0) { |
| 242 resolver->Reject(DOMException::Create( | 243 resolver->Reject(DOMException::Create( |
| 243 kInvalidStateError, | 244 kInvalidStateError, |
| 244 "negative suspend time (" + String::Number(when) + ") is not allowed")); | 245 "negative suspend time (" + String::Number(when) + ") is not allowed")); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 | 453 |
| 453 // Note that the GraphLock is required before this check. Since this needs | 454 // Note that the GraphLock is required before this check. Since this needs |
| 454 // to run on the audio thread, OfflineGraphAutoLocker must be used. | 455 // to run on the audio thread, OfflineGraphAutoLocker must be used. |
| 455 if (scheduled_suspends_.Contains(CurrentSampleFrame())) | 456 if (scheduled_suspends_.Contains(CurrentSampleFrame())) |
| 456 return true; | 457 return true; |
| 457 | 458 |
| 458 return false; | 459 return false; |
| 459 } | 460 } |
| 460 | 461 |
| 461 } // namespace blink | 462 } // namespace blink |
| OLD | NEW |