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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.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 /* 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return nullptr; 50 return nullptr;
51 } 51 }
52 52
53 Document* document = toDocument(context); 53 Document* document = toDocument(context);
54 54
55 if (!numberOfFrames) { 55 if (!numberOfFrames) {
56 exceptionState.throwDOMException(SyntaxError, "number of frames cannot b e zero."); 56 exceptionState.throwDOMException(SyntaxError, "number of frames cannot b e zero.");
57 return nullptr; 57 return nullptr;
58 } 58 }
59 59
60 if (numberOfChannels > AbstractAudioContext::maxNumberOfChannels()) { 60 if (numberOfChannels > BaseAudioContext::maxNumberOfChannels()) {
61 exceptionState.throwDOMException( 61 exceptionState.throwDOMException(
62 IndexSizeError, 62 IndexSizeError,
63 ExceptionMessages::indexOutsideRange<unsigned>( 63 ExceptionMessages::indexOutsideRange<unsigned>(
64 "number of channels", 64 "number of channels",
65 numberOfChannels, 65 numberOfChannels,
66 0, 66 0,
67 ExceptionMessages::InclusiveBound, 67 ExceptionMessages::InclusiveBound,
68 AbstractAudioContext::maxNumberOfChannels(), 68 BaseAudioContext::maxNumberOfChannels(),
69 ExceptionMessages::InclusiveBound)); 69 ExceptionMessages::InclusiveBound));
70 return nullptr; 70 return nullptr;
71 } 71 }
72 72
73 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate)) { 73 if (!AudioUtilities::isValidAudioBufferSampleRate(sampleRate)) {
74 exceptionState.throwDOMException( 74 exceptionState.throwDOMException(
75 IndexSizeError, 75 IndexSizeError,
76 ExceptionMessages::indexOutsideRange( 76 ExceptionMessages::indexOutsideRange(
77 "sampleRate", sampleRate, 77 "sampleRate", sampleRate,
78 AudioUtilities::minAudioBufferSampleRate(), ExceptionMessages::I nclusiveBound, 78 AudioUtilities::minAudioBufferSampleRate(), ExceptionMessages::I nclusiveBound,
(...skipping 28 matching lines...) Expand all
107 107
108 offlineContextChannelCountHistogram.sample(numberOfChannels); 108 offlineContextChannelCountHistogram.sample(numberOfChannels);
109 offlineContextLengthHistogram.count(numberOfFrames); 109 offlineContextLengthHistogram.count(numberOfFrames);
110 offlineContextSampleRateHistogram.count(sampleRate); 110 offlineContextSampleRateHistogram.count(sampleRate);
111 111
112 audioContext->suspendIfNeeded(); 112 audioContext->suspendIfNeeded();
113 return audioContext; 113 return audioContext;
114 } 114 }
115 115
116 OfflineAudioContext::OfflineAudioContext(Document* document, unsigned numberOfCh annels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionState) 116 OfflineAudioContext::OfflineAudioContext(Document* document, unsigned numberOfCh annels, size_t numberOfFrames, float sampleRate, ExceptionState& exceptionState)
117 : AbstractAudioContext(document, numberOfChannels, numberOfFrames, sampleRat e) 117 : BaseAudioContext(document, numberOfChannels, numberOfFrames, sampleRate)
118 , m_isRenderingStarted(false) 118 , m_isRenderingStarted(false)
119 , m_totalRenderFrames(numberOfFrames) 119 , m_totalRenderFrames(numberOfFrames)
120 { 120 {
121 // Create a new destination for offline rendering. 121 // Create a new destination for offline rendering.
122 m_renderTarget = AudioBuffer::create(numberOfChannels, numberOfFrames, sampl eRate); 122 m_renderTarget = AudioBuffer::create(numberOfChannels, numberOfFrames, sampl eRate);
123 123
124 // Throw an exception if the render target is not ready. 124 // Throw an exception if the render target is not ready.
125 if (m_renderTarget) { 125 if (m_renderTarget) {
126 m_destinationNode = OfflineAudioDestinationNode::create(this, m_renderTa rget.get()); 126 m_destinationNode = OfflineAudioDestinationNode::create(this, m_renderTa rget.get());
127 initialize(); 127 initialize();
128 } else { 128 } else {
129 exceptionState.throwRangeError(ExceptionMessages::failedToConstruct( 129 exceptionState.throwRangeError(ExceptionMessages::failedToConstruct(
130 "OfflineAudioContext", 130 "OfflineAudioContext",
131 "failed to create OfflineAudioContext(" + 131 "failed to create OfflineAudioContext(" +
132 String::number(numberOfChannels) + ", " + 132 String::number(numberOfChannels) + ", " +
133 String::number(numberOfFrames) + ", " + 133 String::number(numberOfFrames) + ", " +
134 String::number(sampleRate) + ")")); 134 String::number(sampleRate) + ")"));
135 } 135 }
136 } 136 }
137 137
138 OfflineAudioContext::~OfflineAudioContext() 138 OfflineAudioContext::~OfflineAudioContext()
139 { 139 {
140 } 140 }
141 141
142 DEFINE_TRACE(OfflineAudioContext) 142 DEFINE_TRACE(OfflineAudioContext)
143 { 143 {
144 visitor->trace(m_renderTarget); 144 visitor->trace(m_renderTarget);
145 visitor->trace(m_completeResolver); 145 visitor->trace(m_completeResolver);
146 visitor->trace(m_scheduledSuspends); 146 visitor->trace(m_scheduledSuspends);
147 AbstractAudioContext::trace(visitor); 147 BaseAudioContext::trace(visitor);
148 } 148 }
149 149
150 ScriptPromise OfflineAudioContext::startOfflineRendering(ScriptState* scriptStat e) 150 ScriptPromise OfflineAudioContext::startOfflineRendering(ScriptState* scriptStat e)
151 { 151 {
152 ASSERT(isMainThread()); 152 ASSERT(isMainThread());
153 153
154 // Calling close() on an OfflineAudioContext is not supported/allowed, 154 // Calling close() on an OfflineAudioContext is not supported/allowed,
155 // but it might well have been stopped by its execution context. 155 // but it might well have been stopped by its execution context.
156 // 156 //
157 // See: crbug.com/435867 157 // See: crbug.com/435867
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return ScriptPromise::rejectWithDOMException( 198 return ScriptPromise::rejectWithDOMException(
199 scriptState, 199 scriptState,
200 DOMException::create( 200 DOMException::create(
201 InvalidAccessError, 201 InvalidAccessError,
202 "cannot close an OfflineAudioContext.")); 202 "cannot close an OfflineAudioContext."));
203 } 203 }
204 204
205 ScriptPromise OfflineAudioContext::suspendContext(ScriptState* scriptState) 205 ScriptPromise OfflineAudioContext::suspendContext(ScriptState* scriptState)
206 { 206 {
207 // This CANNOT be called on OfflineAudioContext; this is only to implement 207 // This CANNOT be called on OfflineAudioContext; this is only to implement
208 // the pure virtual interface from AbstractAudioContext. 208 // the pure virtual interface from BaseAudioContext.
209 RELEASE_NOTREACHED(); 209 RELEASE_NOTREACHED();
210 210
211 return ScriptPromise(); 211 return ScriptPromise();
212 } 212 }
213 213
214 ScriptPromise OfflineAudioContext::suspendContext(ScriptState* scriptState, doub le when) 214 ScriptPromise OfflineAudioContext::suspendContext(ScriptState* scriptState, doub le when)
215 { 215 {
216 ASSERT(isMainThread()); 216 ASSERT(isMainThread());
217 217
218 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 218 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // Note that the GraphLock is required before this check. Since this needs 435 // Note that the GraphLock is required before this check. Since this needs
436 // to run on the audio thread, OfflineGraphAutoLocker must be used. 436 // to run on the audio thread, OfflineGraphAutoLocker must be used.
437 if (m_scheduledSuspends.contains(currentSampleFrame())) 437 if (m_scheduledSuspends.contains(currentSampleFrame()))
438 return true; 438 return true;
439 439
440 return false; 440 return false;
441 } 441 }
442 442
443 } // namespace blink 443 } // namespace blink
444 444
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698