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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 return ScriptPromise(); | 223 return ScriptPromise(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 ScriptPromise OfflineAudioContext::suspendContext(ScriptState* script_state, | 226 ScriptPromise OfflineAudioContext::suspendContext(ScriptState* script_state, |
| 227 double when) { | 227 double when) { |
| 228 DCHECK(IsMainThread()); | 228 DCHECK(IsMainThread()); |
| 229 | 229 |
| 230 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); | 230 ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state); |
| 231 ScriptPromise promise = resolver->Promise(); | 231 ScriptPromise promise = resolver->Promise(); |
| 232 | 232 |
| 233 // The render thread does not exist; reject the promise. | |
| 234 if (!DestinationHandler().OfflineRenderThread()) { | |
| 235 resolver->Reject(DOMException::Create(kInvalidStateError, | |
| 236 "the rendering is already finished")); | |
| 237 return promise; | |
| 238 } | |
| 239 | |
|
hongchan
2017/05/19 17:35:06
The existence of thread and being able to schedule
Raymond Toy
2017/05/19 19:37:54
Based on the comments, when rendering is done, the
| |
| 240 // The specified suspend time is negative; reject the promise. | 233 // The specified suspend time is negative; reject the promise. |
| 241 if (when < 0) { | 234 if (when < 0) { |
| 242 resolver->Reject(DOMException::Create( | 235 resolver->Reject(DOMException::Create( |
| 243 kInvalidStateError, | 236 kInvalidStateError, |
| 244 "negative suspend time (" + String::Number(when) + ") is not allowed")); | 237 "negative suspend time (" + String::Number(when) + ") is not allowed")); |
| 245 return promise; | 238 return promise; |
| 246 } | 239 } |
| 247 | 240 |
| 248 // Quantize (to the lower boundary) the suspend time by the render quantum. | 241 // Quantize (to the lower boundary) the suspend time by the render quantum. |
| 249 size_t frame = when * sampleRate(); | 242 size_t frame = when * sampleRate(); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 | 445 |
| 453 // Note that the GraphLock is required before this check. Since this needs | 446 // Note that the GraphLock is required before this check. Since this needs |
| 454 // to run on the audio thread, OfflineGraphAutoLocker must be used. | 447 // to run on the audio thread, OfflineGraphAutoLocker must be used. |
| 455 if (scheduled_suspends_.Contains(CurrentSampleFrame())) | 448 if (scheduled_suspends_.Contains(CurrentSampleFrame())) |
| 456 return true; | 449 return true; |
| 457 | 450 |
| 458 return false; | 451 return false; |
| 459 } | 452 } |
| 460 | 453 |
| 461 } // namespace blink | 454 } // namespace blink |
| OLD | NEW |