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

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

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 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 * 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 size_t bufferLength = buffer->length(); 112 size_t bufferLength = buffer->length();
113 113
114 // The current implementation supports only 1-, 2-, or 4-channel impulse 114 // The current implementation supports only 1-, 2-, or 4-channel impulse
115 // responses, with the 4-channel response being interpreted as true-stereo 115 // responses, with the 4-channel response being interpreted as true-stereo
116 // (see Reverb class). 116 // (see Reverb class).
117 bool isChannelCountGood = 117 bool isChannelCountGood =
118 numberOfChannels == 1 || numberOfChannels == 2 || numberOfChannels == 4; 118 numberOfChannels == 1 || numberOfChannels == 2 || numberOfChannels == 4;
119 119
120 if (!isChannelCountGood) { 120 if (!isChannelCountGood) {
121 exceptionState.throwDOMException( 121 exceptionState.throwDOMException(
122 NotSupportedError, "The buffer must have 1, 2, or 4 channels, not " + 122 NotSupportedError,
123 String::number(numberOfChannels)); 123 "The buffer must have 1, 2, or 4 channels, not " +
124 String::number(numberOfChannels));
124 return; 125 return;
125 } 126 }
126 127
127 // Wrap the AudioBuffer by an AudioBus. It's an efficient pointer set and not 128 // Wrap the AudioBuffer by an AudioBus. It's an efficient pointer set and not
128 // a memcpy(). This memory is simply used in the Reverb constructor and no 129 // a memcpy(). This memory is simply used in the Reverb constructor and no
129 // reference to it is kept for later use in that class. 130 // reference to it is kept for later use in that class.
130 RefPtr<AudioBus> bufferBus = 131 RefPtr<AudioBus> bufferBus =
131 AudioBus::create(numberOfChannels, bufferLength, false); 132 AudioBus::create(numberOfChannels, bufferLength, false);
132 for (unsigned i = 0; i < numberOfChannels; ++i) 133 for (unsigned i = 0; i < numberOfChannels; ++i)
133 bufferBus->setChannelMemory(i, buffer->getChannelData(i)->data(), 134 bufferBus->setChannelMemory(i, buffer->getChannelData(i)->data(),
(...skipping 15 matching lines...) Expand all
149 } 150 }
150 151
151 AudioBuffer* ConvolverHandler::buffer() { 152 AudioBuffer* ConvolverHandler::buffer() {
152 DCHECK(isMainThread()); 153 DCHECK(isMainThread());
153 return m_buffer.get(); 154 return m_buffer.get();
154 } 155 }
155 156
156 double ConvolverHandler::tailTime() const { 157 double ConvolverHandler::tailTime() const {
157 MutexTryLocker tryLocker(m_processLock); 158 MutexTryLocker tryLocker(m_processLock);
158 if (tryLocker.locked()) 159 if (tryLocker.locked())
159 return m_reverb 160 return m_reverb ? m_reverb->impulseResponseLength() /
160 ? m_reverb->impulseResponseLength() / 161 static_cast<double>(context()->sampleRate())
161 static_cast<double>(context()->sampleRate()) 162 : 0;
162 : 0;
163 // Since we don't want to block the Audio Device thread, we return a large 163 // Since we don't want to block the Audio Device thread, we return a large
164 // value instead of trying to acquire the lock. 164 // value instead of trying to acquire the lock.
165 return std::numeric_limits<double>::infinity(); 165 return std::numeric_limits<double>::infinity();
166 } 166 }
167 167
168 double ConvolverHandler::latencyTime() const { 168 double ConvolverHandler::latencyTime() const {
169 MutexTryLocker tryLocker(m_processLock); 169 MutexTryLocker tryLocker(m_processLock);
170 if (tryLocker.locked()) 170 if (tryLocker.locked())
171 return m_reverb 171 return m_reverb ? m_reverb->latencyFrames() /
172 ? m_reverb->latencyFrames() / 172 static_cast<double>(context()->sampleRate())
173 static_cast<double>(context()->sampleRate()) 173 : 0;
174 : 0;
175 // Since we don't want to block the Audio Device thread, we return a large 174 // Since we don't want to block the Audio Device thread, we return a large
176 // value instead of trying to acquire the lock. 175 // value instead of trying to acquire the lock.
177 return std::numeric_limits<double>::infinity(); 176 return std::numeric_limits<double>::infinity();
178 } 177 }
179 178
180 // ---------------------------------------------------------------- 179 // ----------------------------------------------------------------
181 180
182 ConvolverNode::ConvolverNode(BaseAudioContext& context) : AudioNode(context) { 181 ConvolverNode::ConvolverNode(BaseAudioContext& context) : AudioNode(context) {
183 setHandler(ConvolverHandler::create(*this, context.sampleRate())); 182 setHandler(ConvolverHandler::create(*this, context.sampleRate()));
184 } 183 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 227
229 bool ConvolverNode::normalize() const { 228 bool ConvolverNode::normalize() const {
230 return convolverHandler().normalize(); 229 return convolverHandler().normalize();
231 } 230 }
232 231
233 void ConvolverNode::setNormalize(bool normalize) { 232 void ConvolverNode::setNormalize(bool normalize) {
234 convolverHandler().setNormalize(normalize); 233 convolverHandler().setNormalize(normalize);
235 } 234 }
236 235
237 } // namespace blink 236 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698