Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(768)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/AudioContext.cpp

Issue 2103043007: Rename AbstractAudioContext to BaseAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use ASSERT(isGraphOwner()) instead of DCHECK Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/Histogram.h"
14 #include "platform/audio/AudioUtilities.h" 14 #include "platform/audio/AudioUtilities.h"
15 15
16 #if DEBUG_AUDIONODE_REFERENCES 16 #if DEBUG_AUDIONODE_REFERENCES
17 #include <stdio.h> 17 #include <stdio.h>
18 #endif 18 #endif
19 19
20 namespace blink { 20 namespace blink {
21 21
22 // Don't allow more than this number of simultaneous AudioContexts 22 // Don't allow more than this number of simultaneous AudioContexts
23 // talking to hardware. 23 // talking to hardware.
24 const unsigned MaxHardwareContexts = 6; 24 const unsigned MaxHardwareContexts = 6;
25 static unsigned s_hardwareContextCount = 0; 25 static unsigned s_hardwareContextCount = 0;
26 static unsigned s_contextId = 0; 26 static unsigned s_contextId = 0;
27 27
28 AbstractAudioContext* AudioContext::create(Document& document, ExceptionState& e xceptionState) 28 BaseAudioContext* AudioContext::create(Document& document, ExceptionState& excep tionState)
29 { 29 {
30 ASSERT(isMainThread()); 30 ASSERT(isMainThread());
31 if (s_hardwareContextCount >= MaxHardwareContexts) { 31 if (s_hardwareContextCount >= MaxHardwareContexts) {
32 exceptionState.throwDOMException( 32 exceptionState.throwDOMException(
33 NotSupportedError, 33 NotSupportedError,
34 ExceptionMessages::indexExceedsMaximumBound( 34 ExceptionMessages::indexExceedsMaximumBound(
35 "number of hardware contexts", 35 "number of hardware contexts",
36 s_hardwareContextCount, 36 s_hardwareContextCount,
37 MaxHardwareContexts)); 37 MaxHardwareContexts));
38 return nullptr; 38 return nullptr;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ("WebAudio.AudioContext.MaxChannelsAvailable")); 71 ("WebAudio.AudioContext.MaxChannelsAvailable"));
72 DEFINE_STATIC_LOCAL(SparseHistogram, sampleRateHistogram, 72 DEFINE_STATIC_LOCAL(SparseHistogram, sampleRateHistogram,
73 ("WebAudio.AudioContext.HardwareSampleRate")); 73 ("WebAudio.AudioContext.HardwareSampleRate"));
74 maxChannelCountHistogram.sample(audioContext->destination()->maxChannelCount ()); 74 maxChannelCountHistogram.sample(audioContext->destination()->maxChannelCount ());
75 sampleRateHistogram.sample(audioContext->sampleRate()); 75 sampleRateHistogram.sample(audioContext->sampleRate());
76 76
77 return audioContext; 77 return audioContext;
78 } 78 }
79 79
80 AudioContext::AudioContext(Document& document) 80 AudioContext::AudioContext(Document& document)
81 : AbstractAudioContext(&document) 81 : BaseAudioContext(&document)
82 , m_contextId(s_contextId++) 82 , m_contextId(s_contextId++)
83 { 83 {
84 } 84 }
85 85
86 AudioContext::~AudioContext() 86 AudioContext::~AudioContext()
87 { 87 {
88 #if DEBUG_AUDIONODE_REFERENCES 88 #if DEBUG_AUDIONODE_REFERENCES
89 fprintf(stderr, "%p: AudioContext::~AudioContext(): %u\n", this, m_contextId ); 89 fprintf(stderr, "%p: AudioContext::~AudioContext(): %u\n", this, m_contextId );
90 #endif 90 #endif
91 } 91 }
92 92
93 DEFINE_TRACE(AudioContext) 93 DEFINE_TRACE(AudioContext)
94 { 94 {
95 visitor->trace(m_closeResolver); 95 visitor->trace(m_closeResolver);
96 AbstractAudioContext::trace(visitor); 96 BaseAudioContext::trace(visitor);
97 } 97 }
98 98
99 ScriptPromise AudioContext::suspendContext(ScriptState* scriptState) 99 ScriptPromise AudioContext::suspendContext(ScriptState* scriptState)
100 { 100 {
101 ASSERT(isMainThread()); 101 ASSERT(isMainThread());
102 AutoLocker locker(this); 102 AutoLocker locker(this);
103 103
104 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 104 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
105 ScriptPromise promise = resolver->promise(); 105 ScriptPromise promise = resolver->promise();
106 106
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 ASSERT(s_hardwareContextCount); 186 ASSERT(s_hardwareContextCount);
187 --s_hardwareContextCount; 187 --s_hardwareContextCount;
188 188
189 if (m_closeResolver) 189 if (m_closeResolver)
190 m_closeResolver->resolve(); 190 m_closeResolver->resolve();
191 } 191 }
192 192
193 bool AudioContext::isContextClosed() const 193 bool AudioContext::isContextClosed() const
194 { 194 {
195 return m_closeResolver || AbstractAudioContext::isContextClosed(); 195 return m_closeResolver || BaseAudioContext::isContextClosed();
196 } 196 }
197 197
198 void AudioContext::stopRendering() 198 void AudioContext::stopRendering()
199 { 199 {
200 ASSERT(isMainThread()); 200 ASSERT(isMainThread());
201 ASSERT(destination()); 201 ASSERT(destination());
202 202
203 if (contextState() == Running) { 203 if (contextState() == Running) {
204 destination()->audioDestinationHandler().stopRendering(); 204 destination()->audioDestinationHandler().stopRendering();
205 setContextState(Suspended); 205 setContextState(Suspended);
206 deferredTaskHandler().clearHandlersToBeDeleted(); 206 deferredTaskHandler().clearHandlersToBeDeleted();
207 } 207 }
208 } 208 }
209 209
210 } // namespace blink 210 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioContext.h ('k') | third_party/WebKit/Source/modules/webaudio/AudioContext.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698