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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 // When this happens, fire an event and swap buffers. | 219 // When this happens, fire an event and swap buffers. |
220 if (!m_bufferReadWriteIndex) { | 220 if (!m_bufferReadWriteIndex) { |
221 // Avoid building up requests on the main thread to fire process events
when they're not being handled. | 221 // Avoid building up requests on the main thread to fire process events
when they're not being handled. |
222 // This could be a problem if the main thread is very busy doing other t
hings and is being held up handling previous requests. | 222 // This could be a problem if the main thread is very busy doing other t
hings and is being held up handling previous requests. |
223 // The audio thread can't block on this lock, so we call tryLock() inste
ad. | 223 // The audio thread can't block on this lock, so we call tryLock() inste
ad. |
224 MutexTryLocker tryLocker(m_processEventLock); | 224 MutexTryLocker tryLocker(m_processEventLock); |
225 if (!tryLocker.locked()) { | 225 if (!tryLocker.locked()) { |
226 // We're late in handling the previous request. The main thread must
be very busy. | 226 // We're late in handling the previous request. The main thread must
be very busy. |
227 // The best we can do is clear out the buffer ourself here. | 227 // The best we can do is clear out the buffer ourself here. |
228 outputBuffer->zero(); | 228 outputBuffer->zero(); |
229 } else { | 229 } else if (context()->executionContext()) { |
230 // Fire the event on the main thread, not this one (which is the rea
ltime audio thread). | 230 // Fire the event on the main thread, not this one (which is the rea
ltime audio thread). |
231 m_doubleBufferIndexForEvent = m_doubleBufferIndex; | 231 m_doubleBufferIndexForEvent = m_doubleBufferIndex; |
232 context()->executionContext()->postTask(createCrossThreadTask(&Scrip
tProcessorNode::fireProcessEvent, PassRefPtrWillBeRawPtr<ScriptProcessorNode>(th
is))); | 232 context()->executionContext()->postTask(createCrossThreadTask(&Scrip
tProcessorNode::fireProcessEvent, PassRefPtrWillBeRawPtr<ScriptProcessorNode>(th
is))); |
233 } | 233 } |
234 | 234 |
235 swapBuffers(); | 235 swapBuffers(); |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
239 void ScriptProcessorNode::fireProcessEvent() | 239 void ScriptProcessorNode::fireProcessEvent() |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 void ScriptProcessorNode::trace(Visitor* visitor) | 278 void ScriptProcessorNode::trace(Visitor* visitor) |
279 { | 279 { |
280 visitor->trace(m_inputBuffers); | 280 visitor->trace(m_inputBuffers); |
281 visitor->trace(m_outputBuffers); | 281 visitor->trace(m_outputBuffers); |
282 AudioNode::trace(visitor); | 282 AudioNode::trace(visitor); |
283 } | 283 } |
284 | 284 |
285 } // namespace WebCore | 285 } // namespace WebCore |
286 | 286 |
287 #endif // ENABLE(WEB_AUDIO) | 287 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |