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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 NotSupportedError, ExceptionMessages::indexExceedsMaximumBound( | 46 NotSupportedError, ExceptionMessages::indexExceedsMaximumBound( |
47 "number of hardware contexts", | 47 "number of hardware contexts", |
48 s_hardwareContextCount, MaxHardwareContexts)); | 48 s_hardwareContextCount, MaxHardwareContexts)); |
49 return nullptr; | 49 return nullptr; |
50 } | 50 } |
51 | 51 |
52 WebAudioLatencyHint latencyHint(WebAudioLatencyHint::kCategoryInteractive); | 52 WebAudioLatencyHint latencyHint(WebAudioLatencyHint::kCategoryInteractive); |
53 if (contextOptions.latencyHint().isAudioContextLatencyCategory()) { | 53 if (contextOptions.latencyHint().isAudioContextLatencyCategory()) { |
54 latencyHint = WebAudioLatencyHint( | 54 latencyHint = WebAudioLatencyHint( |
55 contextOptions.latencyHint().getAsAudioContextLatencyCategory()); | 55 contextOptions.latencyHint().getAsAudioContextLatencyCategory()); |
| 56 } else if (contextOptions.latencyHint().isDouble()) { |
| 57 latencyHint = |
| 58 WebAudioLatencyHint(contextOptions.latencyHint().getAsDouble()); |
56 } | 59 } |
57 // TODO: add support for latencyHint().isDouble() | |
58 | 60 |
59 AudioContext* audioContext = new AudioContext(document, latencyHint); | 61 AudioContext* audioContext = new AudioContext(document, latencyHint); |
60 audioContext->suspendIfNeeded(); | 62 audioContext->suspendIfNeeded(); |
61 | 63 |
62 if (!AudioUtilities::isValidAudioBufferSampleRate( | 64 if (!AudioUtilities::isValidAudioBufferSampleRate( |
63 audioContext->sampleRate())) { | 65 audioContext->sampleRate())) { |
64 exceptionState.throwDOMException( | 66 exceptionState.throwDOMException( |
65 NotSupportedError, | 67 NotSupportedError, |
66 ExceptionMessages::indexOutsideRange( | 68 ExceptionMessages::indexOutsideRange( |
67 "hardware sample rate", audioContext->sampleRate(), | 69 "hardware sample rate", audioContext->sampleRate(), |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 setContextState(Suspended); | 256 setContextState(Suspended); |
255 deferredTaskHandler().clearHandlersToBeDeleted(); | 257 deferredTaskHandler().clearHandlersToBeDeleted(); |
256 } | 258 } |
257 } | 259 } |
258 | 260 |
259 double AudioContext::baseLatency() const { | 261 double AudioContext::baseLatency() const { |
260 return framesPerBuffer() * 2 / static_cast<double>(sampleRate()); | 262 return framesPerBuffer() * 2 / static_cast<double>(sampleRate()); |
261 } | 263 } |
262 | 264 |
263 } // namespace blink | 265 } // namespace blink |
OLD | NEW |