| 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 10 matching lines...) Expand all Loading... |
| 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 23 * DAMAGE. | 23 * DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "modules/webaudio/ScriptProcessorNode.h" | 26 #include "modules/webaudio/ScriptProcessorNode.h" |
| 27 #include "bindings/core/v8/ExceptionState.h" | 27 #include "bindings/core/v8/ExceptionState.h" |
| 28 #include "core/dom/ExceptionCode.h" | 28 #include "core/dom/ExceptionCode.h" |
| 29 #include "core/dom/ExecutionContext.h" | 29 #include "core/dom/ExecutionContext.h" |
| 30 #include "core/dom/ExecutionContextTask.h" | 30 #include "core/dom/ExecutionContextTask.h" |
| 31 #include "core/dom/TaskRunnerHelper.h" |
| 31 #include "modules/webaudio/AudioBuffer.h" | 32 #include "modules/webaudio/AudioBuffer.h" |
| 32 #include "modules/webaudio/AudioNodeInput.h" | 33 #include "modules/webaudio/AudioNodeInput.h" |
| 33 #include "modules/webaudio/AudioNodeOutput.h" | 34 #include "modules/webaudio/AudioNodeOutput.h" |
| 34 #include "modules/webaudio/AudioProcessingEvent.h" | 35 #include "modules/webaudio/AudioProcessingEvent.h" |
| 35 #include "modules/webaudio/BaseAudioContext.h" | 36 #include "modules/webaudio/BaseAudioContext.h" |
| 36 #include "platform/WaitableEvent.h" | 37 #include "platform/WaitableEvent.h" |
| 37 #include "public/platform/Platform.h" | 38 #include "public/platform/Platform.h" |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // We're late in handling the previous request. The main thread must be | 200 // We're late in handling the previous request. The main thread must be |
| 200 // very busy. The best we can do is clear out the buffer ourself here. | 201 // very busy. The best we can do is clear out the buffer ourself here. |
| 201 outputBuffer->zero(); | 202 outputBuffer->zero(); |
| 202 } else if (context()->getExecutionContext()) { | 203 } else if (context()->getExecutionContext()) { |
| 203 // With the realtime context, execute the script code asynchronously | 204 // With the realtime context, execute the script code asynchronously |
| 204 // and do not wait. | 205 // and do not wait. |
| 205 if (context()->hasRealtimeConstraint()) { | 206 if (context()->hasRealtimeConstraint()) { |
| 206 // Fire the event on the main thread with the appropriate buffer | 207 // Fire the event on the main thread with the appropriate buffer |
| 207 // index. | 208 // index. |
| 208 context()->getExecutionContext()->postTask( | 209 context()->getExecutionContext()->postTask( |
| 209 BLINK_FROM_HERE, | 210 TaskType::MediaElementEvent, BLINK_FROM_HERE, |
| 210 createCrossThreadTask(&ScriptProcessorHandler::fireProcessEvent, | 211 createCrossThreadTask(&ScriptProcessorHandler::fireProcessEvent, |
| 211 crossThreadUnretained(this), | 212 crossThreadUnretained(this), |
| 212 m_doubleBufferIndex)); | 213 m_doubleBufferIndex)); |
| 213 } else { | 214 } else { |
| 214 // If this node is in the offline audio context, use the | 215 // If this node is in the offline audio context, use the |
| 215 // waitable event to synchronize to the offline rendering thread. | 216 // waitable event to synchronize to the offline rendering thread. |
| 216 std::unique_ptr<WaitableEvent> waitableEvent = | 217 std::unique_ptr<WaitableEvent> waitableEvent = |
| 217 WTF::makeUnique<WaitableEvent>(); | 218 WTF::makeUnique<WaitableEvent>(); |
| 218 | 219 |
| 219 context()->getExecutionContext()->postTask( | 220 context()->getExecutionContext()->postTask( |
| 220 BLINK_FROM_HERE, | 221 TaskType::MediaElementEvent, BLINK_FROM_HERE, |
| 221 createCrossThreadTask( | 222 createCrossThreadTask( |
| 222 &ScriptProcessorHandler::fireProcessEventForOfflineAudioContext, | 223 &ScriptProcessorHandler::fireProcessEventForOfflineAudioContext, |
| 223 crossThreadUnretained(this), m_doubleBufferIndex, | 224 crossThreadUnretained(this), m_doubleBufferIndex, |
| 224 crossThreadUnretained(waitableEvent.get()))); | 225 crossThreadUnretained(waitableEvent.get()))); |
| 225 | 226 |
| 226 // Okay to block the offline audio rendering thread since it is | 227 // Okay to block the offline audio rendering thread since it is |
| 227 // not the actual audio device thread. | 228 // not the actual audio device thread. |
| 228 waitableEvent->wait(); | 229 waitableEvent->wait(); |
| 229 } | 230 } |
| 230 } | 231 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 474 |
| 474 // If |onaudioprocess| event handler is defined, the node should not be | 475 // If |onaudioprocess| event handler is defined, the node should not be |
| 475 // GCed even if it is out of scope. | 476 // GCed even if it is out of scope. |
| 476 if (hasEventListeners(EventTypeNames::audioprocess)) | 477 if (hasEventListeners(EventTypeNames::audioprocess)) |
| 477 return true; | 478 return true; |
| 478 | 479 |
| 479 return false; | 480 return false; |
| 480 } | 481 } |
| 481 | 482 |
| 482 } // namespace blink | 483 } // namespace blink |
| OLD | NEW |