Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: Source/modules/webaudio/DeferredTaskHandler.cpp

Issue 1140723003: Implement suspend() and resume() for OfflineAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed a LO test and minor nits Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 24 matching lines...) Expand all
35 35
36 namespace blink { 36 namespace blink {
37 37
38 void DeferredTaskHandler::lock() 38 void DeferredTaskHandler::lock()
39 { 39 {
40 // Don't allow regular lock in real-time audio thread. 40 // Don't allow regular lock in real-time audio thread.
41 ASSERT(isMainThread()); 41 ASSERT(isMainThread());
42 m_contextGraphMutex.lock(); 42 m_contextGraphMutex.lock();
43 } 43 }
44 44
45 void DeferredTaskHandler::forceLock()
46 {
47 // This allows the regular lock in non-real-time audio thread.
48 ASSERT(!isMainThread());
49 if (isMainThread()) {
50 // If this gets called in the main thread, do tryLock() instead.
51 m_contextGraphMutex.tryLock();
haraken 2015/06/17 06:46:08 Two questions: - This can fail. Is it OK? - Why d
hongchan 2015/06/17 20:10:39 For this pattern, I would like to ask your opinion
52 return;
53 }
54
55 m_contextGraphMutex.lock();
56 }
57
45 bool DeferredTaskHandler::tryLock() 58 bool DeferredTaskHandler::tryLock()
46 { 59 {
47 // Try to catch cases of using try lock on main thread 60 // Try to catch cases of using try lock on main thread
48 // - it should use regular lock. 61 // - it should use regular lock.
49 ASSERT(isAudioThread()); 62 ASSERT(isAudioThread());
50 if (!isAudioThread()) { 63 if (!isAudioThread()) {
51 // In release build treat tryLock() as lock() (since above 64 // In release build treat tryLock() as lock() (since above
52 // ASSERT(isAudioThread) never fires) - this is the best we can do. 65 // ASSERT(isAudioThread) never fires) - this is the best we can do.
53 lock(); 66 lock();
54 return true; 67 return true;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 { 280 {
268 ASSERT(isMainThread()); 281 ASSERT(isMainThread());
269 AutoLocker locker(*this); 282 AutoLocker locker(*this);
270 m_renderingOrphanHandlers.clear(); 283 m_renderingOrphanHandlers.clear();
271 m_deletableOrphanHandlers.clear(); 284 m_deletableOrphanHandlers.clear();
272 } 285 }
273 286
274 } // namespace blink 287 } // namespace blink
275 288
276 #endif // ENABLE(WEB_AUDIO) 289 #endif // ENABLE(WEB_AUDIO)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698