Chromium Code Reviews

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

Issue 1773813007: blink: Rename modules/ method to prefix with get when they collide. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clash-modules: rebase-fixes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 143 matching lines...)
154 // When this happens, fire an event and swap buffers. 154 // When this happens, fire an event and swap buffers.
155 if (!m_bufferReadWriteIndex) { 155 if (!m_bufferReadWriteIndex) {
156 // Avoid building up requests on the main thread to fire process events when they're not being handled. 156 // Avoid building up requests on the main thread to fire process events when they're not being handled.
157 // This could be a problem if the main thread is very busy doing other t hings and is being held up handling previous requests. 157 // This could be a problem if the main thread is very busy doing other t hings and is being held up handling previous requests.
158 // The audio thread can't block on this lock, so we call tryLock() inste ad. 158 // The audio thread can't block on this lock, so we call tryLock() inste ad.
159 MutexTryLocker tryLocker(m_processEventLock); 159 MutexTryLocker tryLocker(m_processEventLock);
160 if (!tryLocker.locked()) { 160 if (!tryLocker.locked()) {
161 // We're late in handling the previous request. The main thread must be very busy. 161 // We're late in handling the previous request. The main thread must be very busy.
162 // The best we can do is clear out the buffer ourself here. 162 // The best we can do is clear out the buffer ourself here.
163 outputBuffer->zero(); 163 outputBuffer->zero();
164 } else if (context()->executionContext()) { 164 } else if (context()->getExecutionContext()) {
165 // Fire the event on the main thread with the appropriate buffer 165 // Fire the event on the main thread with the appropriate buffer
166 // index. 166 // index.
167 context()->executionContext()->postTask(BLINK_FROM_HERE, 167 context()->getExecutionContext()->postTask(BLINK_FROM_HERE,
168 createCrossThreadTask(&ScriptProcessorHandler::fireProcessEvent, this, m_doubleBufferIndex)); 168 createCrossThreadTask(&ScriptProcessorHandler::fireProcessEvent, this, m_doubleBufferIndex));
169 } 169 }
170 170
171 swapBuffers(); 171 swapBuffers();
172 } 172 }
173 } 173 }
174 174
175 void ScriptProcessorHandler::fireProcessEvent(unsigned doubleBufferIndex) 175 void ScriptProcessorHandler::fireProcessEvent(unsigned doubleBufferIndex)
176 { 176 {
177 ASSERT(isMainThread()); 177 ASSERT(isMainThread());
178 178
179 ASSERT(doubleBufferIndex < 2); 179 ASSERT(doubleBufferIndex < 2);
180 if (doubleBufferIndex > 1) 180 if (doubleBufferIndex > 1)
181 return; 181 return;
182 182
183 AudioBuffer* inputBuffer = m_inputBuffers[doubleBufferIndex].get(); 183 AudioBuffer* inputBuffer = m_inputBuffers[doubleBufferIndex].get();
184 AudioBuffer* outputBuffer = m_outputBuffers[doubleBufferIndex].get(); 184 AudioBuffer* outputBuffer = m_outputBuffers[doubleBufferIndex].get();
185 ASSERT(outputBuffer); 185 ASSERT(outputBuffer);
186 if (!outputBuffer) 186 if (!outputBuffer)
187 return; 187 return;
188 188
189 // Avoid firing the event if the document has already gone away. 189 // Avoid firing the event if the document has already gone away.
190 if (node() && context() && context()->executionContext()) { 190 if (node() && context() && context()->getExecutionContext()) {
191 // This synchronizes with process(). 191 // This synchronizes with process().
192 MutexLocker processLocker(m_processEventLock); 192 MutexLocker processLocker(m_processEventLock);
193 193
194 // Calculate a playbackTime with the buffersize which needs to be proces sed each time onaudioprocess is called. 194 // Calculate a playbackTime with the buffersize which needs to be proces sed each time onaudioprocess is called.
195 // The outputBuffer being passed to JS will be played after exhuasting p revious outputBuffer by double-buffering. 195 // The outputBuffer being passed to JS will be played after exhuasting p revious outputBuffer by double-buffering.
196 double playbackTime = (context()->currentSampleFrame() + m_bufferSize) / static_cast<double>(context()->sampleRate()); 196 double playbackTime = (context()->currentSampleFrame() + m_bufferSize) / static_cast<double>(context()->sampleRate());
197 197
198 // Call the JavaScript event handler which will do the audio processing. 198 // Call the JavaScript event handler which will do the audio processing.
199 node()->dispatchEvent(AudioProcessingEvent::create(inputBuffer, outputBu ffer, playbackTime)); 199 node()->dispatchEvent(AudioProcessingEvent::create(inputBuffer, outputBu ffer, playbackTime));
200 } 200 }
(...skipping 102 matching lines...)
303 // If |onaudioprocess| event handler is defined, the node should not be 303 // If |onaudioprocess| event handler is defined, the node should not be
304 // GCed even if it is out of scope. 304 // GCed even if it is out of scope.
305 if (hasEventListeners(EventTypeNames::audioprocess)) 305 if (hasEventListeners(EventTypeNames::audioprocess))
306 return true; 306 return true;
307 307
308 return false; 308 return false;
309 } 309 }
310 310
311 } // namespace blink 311 } // namespace blink
312 312
OLDNEW

Powered by Google App Engine