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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/ChannelMergerNode.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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 13 matching lines...) Expand all
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "modules/webaudio/ChannelMergerNode.h" 29 #include "modules/webaudio/ChannelMergerNode.h"
30 #include "bindings/core/v8/ExceptionMessages.h" 30 #include "bindings/core/v8/ExceptionMessages.h"
31 #include "bindings/core/v8/ExceptionState.h" 31 #include "bindings/core/v8/ExceptionState.h"
32 #include "core/dom/ExceptionCode.h" 32 #include "core/dom/ExceptionCode.h"
33 #include "core/dom/ExecutionContext.h" 33 #include "core/dom/ExecutionContext.h"
34 #include "modules/webaudio/AbstractAudioContext.h"
35 #include "modules/webaudio/AudioNodeInput.h" 34 #include "modules/webaudio/AudioNodeInput.h"
36 #include "modules/webaudio/AudioNodeOutput.h" 35 #include "modules/webaudio/AudioNodeOutput.h"
36 #include "modules/webaudio/BaseAudioContext.h"
37 37
38 38
39 namespace blink { 39 namespace blink {
40 40
41 ChannelMergerHandler::ChannelMergerHandler(AudioNode& node, float sampleRate, un signed numberOfInputs) 41 ChannelMergerHandler::ChannelMergerHandler(AudioNode& node, float sampleRate, un signed numberOfInputs)
42 : AudioHandler(NodeTypeChannelMerger, node, sampleRate) 42 : AudioHandler(NodeTypeChannelMerger, node, sampleRate)
43 { 43 {
44 // These properties are fixed for the node and cannot be changed by user. 44 // These properties are fixed for the node and cannot be changed by user.
45 m_channelCount = 1; 45 m_channelCount = 1;
46 m_channelCountMode = Explicit; 46 m_channelCountMode = Explicit;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } else { 87 } else {
88 // If input is unconnected, fill zeros in the channel. 88 // If input is unconnected, fill zeros in the channel.
89 outputChannel->zero(); 89 outputChannel->zero();
90 } 90 }
91 } 91 }
92 } 92 }
93 93
94 void ChannelMergerHandler::setChannelCount(unsigned long channelCount, Exception State& exceptionState) 94 void ChannelMergerHandler::setChannelCount(unsigned long channelCount, Exception State& exceptionState)
95 { 95 {
96 ASSERT(isMainThread()); 96 ASSERT(isMainThread());
97 AbstractAudioContext::AutoLocker locker(context()); 97 BaseAudioContext::AutoLocker locker(context());
98 98
99 // channelCount must be 1. 99 // channelCount must be 1.
100 if (channelCount != 1) { 100 if (channelCount != 1) {
101 exceptionState.throwDOMException( 101 exceptionState.throwDOMException(
102 InvalidStateError, 102 InvalidStateError,
103 "ChannelMerger: channelCount cannot be changed from 1"); 103 "ChannelMerger: channelCount cannot be changed from 1");
104 } 104 }
105 } 105 }
106 106
107 void ChannelMergerHandler::setChannelCountMode(const String& mode, ExceptionStat e& exceptionState) 107 void ChannelMergerHandler::setChannelCountMode(const String& mode, ExceptionStat e& exceptionState)
108 { 108 {
109 ASSERT(isMainThread()); 109 ASSERT(isMainThread());
110 AbstractAudioContext::AutoLocker locker(context()); 110 BaseAudioContext::AutoLocker locker(context());
111 111
112 // channcelCountMode must be 'explicit'. 112 // channcelCountMode must be 'explicit'.
113 if (mode != "explicit") { 113 if (mode != "explicit") {
114 exceptionState.throwDOMException( 114 exceptionState.throwDOMException(
115 InvalidStateError, 115 InvalidStateError,
116 "ChannelMerger: channelCountMode cannot be changed from 'explicit'") ; 116 "ChannelMerger: channelCountMode cannot be changed from 'explicit'") ;
117 } 117 }
118 } 118 }
119 119
120 // ---------------------------------------------------------------- 120 // ----------------------------------------------------------------
121 121
122 ChannelMergerNode::ChannelMergerNode(AbstractAudioContext& context, unsigned num berOfInputs) 122 ChannelMergerNode::ChannelMergerNode(BaseAudioContext& context, unsigned numberO fInputs)
123 : AudioNode(context) 123 : AudioNode(context)
124 { 124 {
125 setHandler(ChannelMergerHandler::create(*this, context.sampleRate(), numberO fInputs)); 125 setHandler(ChannelMergerHandler::create(*this, context.sampleRate(), numberO fInputs));
126 } 126 }
127 127
128 ChannelMergerNode* ChannelMergerNode::create(AbstractAudioContext& context, Exce ptionState& exceptionState) 128 ChannelMergerNode* ChannelMergerNode::create(BaseAudioContext& context, Exceptio nState& exceptionState)
129 { 129 {
130 DCHECK(isMainThread()); 130 DCHECK(isMainThread());
131 131
132 // The default number of inputs for the merger node is 6. 132 // The default number of inputs for the merger node is 6.
133 return create(context, 6, exceptionState); 133 return create(context, 6, exceptionState);
134 } 134 }
135 135
136 ChannelMergerNode* ChannelMergerNode::create(AbstractAudioContext& context, unsi gned numberOfInputs, ExceptionState& exceptionState) 136 ChannelMergerNode* ChannelMergerNode::create(BaseAudioContext& context, unsigned numberOfInputs, ExceptionState& exceptionState)
137 { 137 {
138 DCHECK(isMainThread()); 138 DCHECK(isMainThread());
139 139
140 if (context.isContextClosed()) { 140 if (context.isContextClosed()) {
141 context.throwExceptionForClosedState(exceptionState); 141 context.throwExceptionForClosedState(exceptionState);
142 return nullptr; 142 return nullptr;
143 } 143 }
144 144
145 if (!numberOfInputs || numberOfInputs > AbstractAudioContext::maxNumberOfCha nnels()) { 145 if (!numberOfInputs || numberOfInputs > BaseAudioContext::maxNumberOfChannel s()) {
146 exceptionState.throwDOMException( 146 exceptionState.throwDOMException(
147 IndexSizeError, 147 IndexSizeError,
148 ExceptionMessages::indexOutsideRange<size_t>( 148 ExceptionMessages::indexOutsideRange<size_t>(
149 "number of inputs", 149 "number of inputs",
150 numberOfInputs, 150 numberOfInputs,
151 1, 151 1,
152 ExceptionMessages::InclusiveBound, 152 ExceptionMessages::InclusiveBound,
153 AbstractAudioContext::maxNumberOfChannels(), 153 BaseAudioContext::maxNumberOfChannels(),
154 ExceptionMessages::InclusiveBound)); 154 ExceptionMessages::InclusiveBound));
155 return nullptr; 155 return nullptr;
156 } 156 }
157 157
158 return new ChannelMergerNode(context, numberOfInputs); 158 return new ChannelMergerNode(context, numberOfInputs);
159 } 159 }
160 160
161 } // namespace blink 161 } // namespace blink
162 162
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698