| OLD | NEW |
| 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 if (!outputBuffer) | 252 if (!outputBuffer) |
| 253 return; | 253 return; |
| 254 | 254 |
| 255 // Avoid firing the event if the document has already gone away. | 255 // Avoid firing the event if the document has already gone away. |
| 256 if (context()->executionContext()) { | 256 if (context()->executionContext()) { |
| 257 // This synchronizes with process(). | 257 // This synchronizes with process(). |
| 258 MutexLocker processLocker(m_processEventLock); | 258 MutexLocker processLocker(m_processEventLock); |
| 259 | 259 |
| 260 // Calculate a playbackTime with the buffersize which needs to be proces
sed each time onaudioprocess is called. | 260 // Calculate a playbackTime with the buffersize which needs to be proces
sed each time onaudioprocess is called. |
| 261 // The outputBuffer being passed to JS will be played after exhuasting p
revious outputBuffer by double-buffering. | 261 // The outputBuffer being passed to JS will be played after exhuasting p
revious outputBuffer by double-buffering. |
| 262 double playbackTime = (context()->currentSampleFrame() + m_bufferSize) /
static_cast<double>(context()->sampleRate()); | 262 double playbackTime = (context()->sampleFrame() + m_bufferSize) / static
_cast<double>(context()->sampleRate()); |
| 263 | 263 |
| 264 // Call the JavaScript event handler which will do the audio processing. | 264 // Call the JavaScript event handler which will do the audio processing. |
| 265 dispatchEvent(AudioProcessingEvent::create(inputBuffer, outputBuffer, pl
aybackTime)); | 265 dispatchEvent(AudioProcessingEvent::create(inputBuffer, outputBuffer, pl
aybackTime)); |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 | 268 |
| 269 double ScriptProcessorNode::tailTime() const | 269 double ScriptProcessorNode::tailTime() const |
| 270 { | 270 { |
| 271 return std::numeric_limits<double>::infinity(); | 271 return std::numeric_limits<double>::infinity(); |
| 272 } | 272 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 303 void ScriptProcessorNode::trace(Visitor* visitor) | 303 void ScriptProcessorNode::trace(Visitor* visitor) |
| 304 { | 304 { |
| 305 visitor->trace(m_inputBuffers); | 305 visitor->trace(m_inputBuffers); |
| 306 visitor->trace(m_outputBuffers); | 306 visitor->trace(m_outputBuffers); |
| 307 AudioNode::trace(visitor); | 307 AudioNode::trace(visitor); |
| 308 } | 308 } |
| 309 | 309 |
| 310 } // namespace blink | 310 } // namespace blink |
| 311 | 311 |
| 312 #endif // ENABLE(WEB_AUDIO) | 312 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |