Chromium Code Reviews| 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 "modules/webaudio/AudioBufferCallback.h" | 12 #include "modules/webaudio/AudioBufferCallback.h" |
| 13 #include "platform/Histogram.h" | |
| 13 #include "platform/audio/AudioUtilities.h" | 14 #include "platform/audio/AudioUtilities.h" |
| 14 | 15 |
| 15 #if DEBUG_AUDIONODE_REFERENCES | 16 #if DEBUG_AUDIONODE_REFERENCES |
| 16 #include <stdio.h> | 17 #include <stdio.h> |
| 17 #endif | 18 #endif |
| 18 | 19 |
| 19 namespace blink { | 20 namespace blink { |
| 20 | 21 |
| 21 // Don't allow more than this number of simultaneous AudioContexts | 22 // Don't allow more than this number of simultaneous AudioContexts |
| 22 // talking to hardware. | 23 // talking to hardware. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 // quantum". NOTE: for now AudioContext does not need an explicit | 60 // quantum". NOTE: for now AudioContext does not need an explicit |
| 60 // startRendering() call from JavaScript. We may want to consider | 61 // startRendering() call from JavaScript. We may want to consider |
| 61 // requiring it for symmetry with OfflineAudioContext. | 62 // requiring it for symmetry with OfflineAudioContext. |
| 62 audioContext->startRendering(); | 63 audioContext->startRendering(); |
| 63 ++s_hardwareContextCount; | 64 ++s_hardwareContextCount; |
| 64 #if DEBUG_AUDIONODE_REFERENCES | 65 #if DEBUG_AUDIONODE_REFERENCES |
| 65 fprintf(stderr, "%p: AudioContext::AudioContext(): %u #%u\n", | 66 fprintf(stderr, "%p: AudioContext::AudioContext(): %u #%u\n", |
| 66 audioContext, audioContext->m_contextId, s_hardwareContextCount); | 67 audioContext, audioContext->m_contextId, s_hardwareContextCount); |
| 67 #endif | 68 #endif |
| 68 | 69 |
| 70 DEFINE_STATIC_LOCAL(SparseHistogram, maxChannelCountHistogram, | |
| 71 ("WebAudio.AudioContext.MaxChannelsAvailable")); | |
| 72 DEFINE_STATIC_LOCAL(SparseHistogram, sampleRateHistogram, | |
| 73 ("WebAudio.AudioContext.HardwareSampleRate")); | |
|
Mark P
2016/06/10 04:02:53
Is this generally fixed or should this be a custom
Raymond Toy
2016/06/10 15:13:44
We expect the possible values for the hardware sam
| |
| 74 maxChannelCountHistogram.sample(audioContext->destination()->maxChannelCount ()); | |
| 75 sampleRateHistogram.sample(audioContext->sampleRate()); | |
| 76 | |
| 69 return audioContext; | 77 return audioContext; |
| 70 } | 78 } |
| 71 | 79 |
| 72 AudioContext::AudioContext(Document& document) | 80 AudioContext::AudioContext(Document& document) |
| 73 : AbstractAudioContext(&document) | 81 : AbstractAudioContext(&document) |
| 74 , m_contextId(s_contextId++) | 82 , m_contextId(s_contextId++) |
| 75 { | 83 { |
| 76 } | 84 } |
| 77 | 85 |
| 78 AudioContext::~AudioContext() | 86 AudioContext::~AudioContext() |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 ASSERT(destination()); | 201 ASSERT(destination()); |
| 194 | 202 |
| 195 if (contextState() == Running) { | 203 if (contextState() == Running) { |
| 196 destination()->audioDestinationHandler().stopRendering(); | 204 destination()->audioDestinationHandler().stopRendering(); |
| 197 setContextState(Suspended); | 205 setContextState(Suspended); |
| 198 deferredTaskHandler().clearHandlersToBeDeleted(); | 206 deferredTaskHandler().clearHandlersToBeDeleted(); |
| 199 } | 207 } |
| 200 } | 208 } |
| 201 | 209 |
| 202 } // namespace blink | 210 } // namespace blink |
| OLD | NEW |