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 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(isMainThread()); | 41 ASSERT(isMainThread()); |
| (...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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 void DeferredTaskHandler::contextWillBeDestroyed() | 231 void DeferredTaskHandler::contextWillBeDestroyed() |
| 220 { | 232 { |
| 221 for (auto& handler : m_renderingOrphanHandlers) | 233 for (auto& handler : m_renderingOrphanHandlers) |
| 222 handler->clearContext(); | 234 handler->clearContext(); |
| 223 for (auto& handler : m_deletableOrphanHandlers) | 235 for (auto& handler : m_deletableOrphanHandlers) |
| 224 handler->clearContext(); | 236 handler->clearContext(); |
| 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 |
| 241 | |
|
haraken
2015/11/17 08:28:10
Nit: Remove the empty line.
hongchan
2015/11/17 18:11:44
Done.
| |
| 229 DeferredTaskHandler::AutoLocker::AutoLocker(AbstractAudioContext* context) | 242 DeferredTaskHandler::AutoLocker::AutoLocker(AbstractAudioContext* context) |
| 230 : m_handler(context->deferredTaskHandler()) | 243 : m_handler(context->deferredTaskHandler()) |
| 231 { | 244 { |
| 232 m_handler.lock(); | 245 m_handler.lock(); |
| 233 } | 246 } |
| 234 | 247 |
| 248 DeferredTaskHandler::OfflineGraphAutoLocker::OfflineGraphAutoLocker(OfflineAudio Context* context) | |
| 249 : m_handler(context->deferredTaskHandler()) | |
| 250 { | |
| 251 m_handler.offlineLock(); | |
| 252 } | |
| 253 | |
| 235 void DeferredTaskHandler::addRenderingOrphanHandler(PassRefPtr<AudioHandler> han dler) | 254 void DeferredTaskHandler::addRenderingOrphanHandler(PassRefPtr<AudioHandler> han dler) |
| 236 { | 255 { |
| 237 ASSERT(handler); | 256 ASSERT(handler); |
| 238 ASSERT(!m_renderingOrphanHandlers.contains(handler)); | 257 ASSERT(!m_renderingOrphanHandlers.contains(handler)); |
| 239 m_renderingOrphanHandlers.append(handler); | 258 m_renderingOrphanHandlers.append(handler); |
| 240 } | 259 } |
| 241 | 260 |
| 242 void DeferredTaskHandler::requestToDeleteHandlersOnMainThread() | 261 void DeferredTaskHandler::requestToDeleteHandlersOnMainThread() |
| 243 { | 262 { |
| 244 ASSERT(isGraphOwner()); | 263 ASSERT(isGraphOwner()); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 261 { | 280 { |
| 262 ASSERT(isMainThread()); | 281 ASSERT(isMainThread()); |
| 263 AutoLocker locker(*this); | 282 AutoLocker locker(*this); |
| 264 m_renderingOrphanHandlers.clear(); | 283 m_renderingOrphanHandlers.clear(); |
| 265 m_deletableOrphanHandlers.clear(); | 284 m_deletableOrphanHandlers.clear(); |
| 266 } | 285 } |
| 267 | 286 |
| 268 } // namespace blink | 287 } // namespace blink |
| 269 | 288 |
| 270 #endif // ENABLE(WEB_AUDIO) | 289 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |