| 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 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #include "config.h" | 25 #include "config.h" |
| 26 #if ENABLE(WEB_AUDIO) | 26 #if ENABLE(WEB_AUDIO) |
| 27 #include "modules/webaudio/DeferredTaskHandler.h" | 27 #include "modules/webaudio/DeferredTaskHandler.h" |
| 28 | 28 |
| 29 #include "modules/webaudio/AudioNode.h" | 29 #include "modules/webaudio/AudioNode.h" |
| 30 #include "modules/webaudio/AudioNodeOutput.h" | 30 #include "modules/webaudio/AudioNodeOutput.h" |
| 31 #include "modules/webaudio/OfflineAudioContext.h" |
| 31 #include "platform/ThreadSafeFunctional.h" | 32 #include "platform/ThreadSafeFunctional.h" |
| 32 #include "public/platform/Platform.h" | 33 #include "public/platform/Platform.h" |
| 33 #include "wtf/MainThread.h" | 34 #include "wtf/MainThread.h" |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 void DeferredTaskHandler::lock() | 38 void DeferredTaskHandler::lock() |
| 38 { | 39 { |
| 39 // Don't allow regular lock in real-time audio thread. | 40 // Don't allow regular lock in real-time audio thread. |
| 40 ASSERT(!isAudioThread()); | 41 ASSERT(!isAudioThread()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 53 return true; | 54 return true; |
| 54 } | 55 } |
| 55 return m_contextGraphMutex.tryLock(); | 56 return m_contextGraphMutex.tryLock(); |
| 56 } | 57 } |
| 57 | 58 |
| 58 void DeferredTaskHandler::unlock() | 59 void DeferredTaskHandler::unlock() |
| 59 { | 60 { |
| 60 m_contextGraphMutex.unlock(); | 61 m_contextGraphMutex.unlock(); |
| 61 } | 62 } |
| 62 | 63 |
| 64 void DeferredTaskHandler::offlineLock() |
| 65 { |
| 66 // RELEASE_ASSERT is here to make sure to explicitly crash if this is called |
| 67 // from other than the offline render thread, which is considered as the |
| 68 // audio thread in OfflineAudioContext. |
| 69 RELEASE_ASSERT_WITH_MESSAGE(isAudioThread(), |
| 70 "DeferredTaskHandler::offlineLock() must be called within the offline au
dio thread."); |
| 71 |
| 72 m_contextGraphMutex.lock(); |
| 73 } |
| 74 |
| 63 #if ENABLE(ASSERT) | 75 #if ENABLE(ASSERT) |
| 64 bool DeferredTaskHandler::isGraphOwner() | 76 bool DeferredTaskHandler::isGraphOwner() |
| 65 { | 77 { |
| 66 return m_contextGraphMutex.locked(); | 78 return m_contextGraphMutex.locked(); |
| 67 } | 79 } |
| 68 #endif | 80 #endif |
| 69 | 81 |
| 70 void DeferredTaskHandler::addDeferredBreakConnection(AudioHandler& node) | 82 void DeferredTaskHandler::addDeferredBreakConnection(AudioHandler& node) |
| 71 { | 83 { |
| 72 ASSERT(isAudioThread()); | 84 ASSERT(isAudioThread()); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 clearHandlersToBeDeleted(); | 237 clearHandlersToBeDeleted(); |
| 226 // Some handlers might live because of their cross thread tasks. | 238 // Some handlers might live because of their cross thread tasks. |
| 227 } | 239 } |
| 228 | 240 |
| 229 DeferredTaskHandler::AutoLocker::AutoLocker(AbstractAudioContext* context) | 241 DeferredTaskHandler::AutoLocker::AutoLocker(AbstractAudioContext* context) |
| 230 : m_handler(context->deferredTaskHandler()) | 242 : m_handler(context->deferredTaskHandler()) |
| 231 { | 243 { |
| 232 m_handler.lock(); | 244 m_handler.lock(); |
| 233 } | 245 } |
| 234 | 246 |
| 247 DeferredTaskHandler::OfflineGraphAutoLocker::OfflineGraphAutoLocker(OfflineAudio
Context* context) |
| 248 : m_handler(context->deferredTaskHandler()) |
| 249 { |
| 250 m_handler.offlineLock(); |
| 251 } |
| 252 |
| 235 void DeferredTaskHandler::addRenderingOrphanHandler(PassRefPtr<AudioHandler> han
dler) | 253 void DeferredTaskHandler::addRenderingOrphanHandler(PassRefPtr<AudioHandler> han
dler) |
| 236 { | 254 { |
| 237 ASSERT(handler); | 255 ASSERT(handler); |
| 238 ASSERT(!m_renderingOrphanHandlers.contains(handler)); | 256 ASSERT(!m_renderingOrphanHandlers.contains(handler)); |
| 239 m_renderingOrphanHandlers.append(handler); | 257 m_renderingOrphanHandlers.append(handler); |
| 240 } | 258 } |
| 241 | 259 |
| 242 void DeferredTaskHandler::requestToDeleteHandlersOnMainThread() | 260 void DeferredTaskHandler::requestToDeleteHandlersOnMainThread() |
| 243 { | 261 { |
| 244 ASSERT(isGraphOwner()); | 262 ASSERT(isGraphOwner()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 261 { | 279 { |
| 262 ASSERT(isMainThread()); | 280 ASSERT(isMainThread()); |
| 263 AutoLocker locker(*this); | 281 AutoLocker locker(*this); |
| 264 m_renderingOrphanHandlers.clear(); | 282 m_renderingOrphanHandlers.clear(); |
| 265 m_deletableOrphanHandlers.clear(); | 283 m_deletableOrphanHandlers.clear(); |
| 266 } | 284 } |
| 267 | 285 |
| 268 } // namespace blink | 286 } // namespace blink |
| 269 | 287 |
| 270 #endif // ENABLE(WEB_AUDIO) | 288 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |