Chromium Code Reviews| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 AudioBuffer* outputBuffer = m_outputBuffers[m_doubleBufferIndexForEvent].get (); | 258 AudioBuffer* outputBuffer = m_outputBuffers[m_doubleBufferIndexForEvent].get (); |
| 259 ASSERT(outputBuffer); | 259 ASSERT(outputBuffer); |
| 260 if (!outputBuffer) | 260 if (!outputBuffer) |
| 261 return; | 261 return; |
| 262 | 262 |
| 263 // Avoid firing the event if the document has already gone away. | 263 // Avoid firing the event if the document has already gone away. |
| 264 if (context()->executionContext()) { | 264 if (context()->executionContext()) { |
| 265 // Let the audio thread know we've gotten to the point where it's OK for it to make another request. | 265 // Let the audio thread know we've gotten to the point where it's OK for it to make another request. |
| 266 m_isRequestOutstanding = false; | 266 m_isRequestOutstanding = false; |
| 267 | 267 |
| 268 // Calculate a playbackTime with the buffersize which needs to be proces sed each time onaudioprocess is called. | |
| 269 // The outputBuffer being passed to JS will be played after exhuasting p revious outputBuffer by double-buffering. | |
| 270 double playbackTime = (context()->currentSampleFrame() + m_bufferSize) / context()->sampleRate(); | |
|
Raymond Toy
2014/03/28 18:14:14
Cast context()->sampleRate() to double because it'
KhNo
2014/03/29 00:24:46
I missed it. Thank you.
| |
| 271 | |
| 268 // Call the JavaScript event handler which will do the audio processing. | 272 // Call the JavaScript event handler which will do the audio processing. |
| 269 dispatchEvent(AudioProcessingEvent::create(inputBuffer, outputBuffer)); | 273 dispatchEvent(AudioProcessingEvent::create(inputBuffer, outputBuffer, pl aybackTime)); |
| 270 } | 274 } |
| 271 } | 275 } |
| 272 | 276 |
| 273 double ScriptProcessorNode::tailTime() const | 277 double ScriptProcessorNode::tailTime() const |
| 274 { | 278 { |
| 275 return std::numeric_limits<double>::infinity(); | 279 return std::numeric_limits<double>::infinity(); |
| 276 } | 280 } |
| 277 | 281 |
| 278 double ScriptProcessorNode::latencyTime() const | 282 double ScriptProcessorNode::latencyTime() const |
| 279 { | 283 { |
| 280 return std::numeric_limits<double>::infinity(); | 284 return std::numeric_limits<double>::infinity(); |
| 281 } | 285 } |
| 282 | 286 |
| 283 } // namespace WebCore | 287 } // namespace WebCore |
| 284 | 288 |
| 285 #endif // ENABLE(WEB_AUDIO) | 289 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |