| 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" |
| 11 #include "core/dom/ExceptionCode.h" | 11 #include "core/dom/ExceptionCode.h" |
| 12 #include "core/frame/UseCounter.h" |
| 12 #include "modules/webaudio/AudioBufferCallback.h" | 13 #include "modules/webaudio/AudioBufferCallback.h" |
| 13 #include "platform/Histogram.h" | 14 #include "platform/Histogram.h" |
| 14 #include "platform/audio/AudioUtilities.h" | 15 #include "platform/audio/AudioUtilities.h" |
| 15 | 16 |
| 16 #if DEBUG_AUDIONODE_REFERENCES | 17 #if DEBUG_AUDIONODE_REFERENCES |
| 17 #include <stdio.h> | 18 #include <stdio.h> |
| 18 #endif | 19 #endif |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 // Don't allow more than this number of simultaneous AudioContexts | 23 // Don't allow more than this number of simultaneous AudioContexts |
| 23 // talking to hardware. | 24 // talking to hardware. |
| 24 const unsigned MaxHardwareContexts = 6; | 25 const unsigned MaxHardwareContexts = 6; |
| 25 static unsigned s_hardwareContextCount = 0; | 26 static unsigned s_hardwareContextCount = 0; |
| 26 static unsigned s_contextId = 0; | 27 static unsigned s_contextId = 0; |
| 27 | 28 |
| 28 AbstractAudioContext* AudioContext::create(Document& document, ExceptionState& e
xceptionState) | 29 AbstractAudioContext* AudioContext::create(Document& document, ExceptionState& e
xceptionState) |
| 29 { | 30 { |
| 30 ASSERT(isMainThread()); | 31 ASSERT(isMainThread()); |
| 32 |
| 33 UseCounter::countCrossOriginIframe(document, UseCounter::AudioContextCrossOr
iginIframe); |
| 34 |
| 31 if (s_hardwareContextCount >= MaxHardwareContexts) { | 35 if (s_hardwareContextCount >= MaxHardwareContexts) { |
| 32 exceptionState.throwDOMException( | 36 exceptionState.throwDOMException( |
| 33 NotSupportedError, | 37 NotSupportedError, |
| 34 ExceptionMessages::indexExceedsMaximumBound( | 38 ExceptionMessages::indexExceedsMaximumBound( |
| 35 "number of hardware contexts", | 39 "number of hardware contexts", |
| 36 s_hardwareContextCount, | 40 s_hardwareContextCount, |
| 37 MaxHardwareContexts)); | 41 MaxHardwareContexts)); |
| 38 return nullptr; | 42 return nullptr; |
| 39 } | 43 } |
| 40 | 44 |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 ASSERT(destination()); | 205 ASSERT(destination()); |
| 202 | 206 |
| 203 if (contextState() == Running) { | 207 if (contextState() == Running) { |
| 204 destination()->audioDestinationHandler().stopRendering(); | 208 destination()->audioDestinationHandler().stopRendering(); |
| 205 setContextState(Suspended); | 209 setContextState(Suspended); |
| 206 deferredTaskHandler().clearHandlersToBeDeleted(); | 210 deferredTaskHandler().clearHandlersToBeDeleted(); |
| 207 } | 211 } |
| 208 } | 212 } |
| 209 | 213 |
| 210 } // namespace blink | 214 } // namespace blink |
| OLD | NEW |