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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/DeferredTaskHandler.h

Issue 2103043007: Rename AbstractAudioContext to BaseAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use ASSERT(isGraphOwner()) instead of DCHECK Created 4 years, 5 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 20 matching lines...) Expand all
31 #include "wtf/PassRefPtr.h" 31 #include "wtf/PassRefPtr.h"
32 #include "wtf/RefPtr.h" 32 #include "wtf/RefPtr.h"
33 #include "wtf/ThreadSafeRefCounted.h" 33 #include "wtf/ThreadSafeRefCounted.h"
34 #include "wtf/Threading.h" 34 #include "wtf/Threading.h"
35 #include "wtf/ThreadingPrimitives.h" 35 #include "wtf/ThreadingPrimitives.h"
36 #include "wtf/Vector.h" 36 #include "wtf/Vector.h"
37 #include "wtf/build_config.h" 37 #include "wtf/build_config.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 class AbstractAudioContext; 41 class BaseAudioContext;
42 class OfflineAudioContext; 42 class OfflineAudioContext;
43 class AudioHandler; 43 class AudioHandler;
44 class AudioNodeOutput; 44 class AudioNodeOutput;
45 class AudioSummingJunction; 45 class AudioSummingJunction;
46 46
47 // DeferredTaskHandler manages the major part of pre- and post- rendering tasks, 47 // DeferredTaskHandler manages the major part of pre- and post- rendering tasks,
48 // and provides a lock mechanism against the audio rendering graph. A 48 // and provides a lock mechanism against the audio rendering graph. A
49 // DeferredTaskHandler object is created when an AbstractAudioContext object is created. 49 // DeferredTaskHandler object is created when an BaseAudioContext object is crea ted.
50 // 50 //
51 // DeferredTaskHandler outlives the AbstractAudioContext only if all of the foll owing 51 // DeferredTaskHandler outlives the BaseAudioContext only if all of the followin g
52 // conditions match: 52 // conditions match:
53 // - An audio rendering thread is running, 53 // - An audio rendering thread is running,
54 // - It is requested to stop, 54 // - It is requested to stop,
55 // - The audio rendering thread calls requestToDeleteHandlersOnMainThread(), 55 // - The audio rendering thread calls requestToDeleteHandlersOnMainThread(),
56 // - It posts a task of deleteHandlersOnMainThread(), and 56 // - It posts a task of deleteHandlersOnMainThread(), and
57 // - GC happens and it collects the AbstractAudioContext before the task executi on. 57 // - GC happens and it collects the BaseAudioContext before the task execution.
58 // 58 //
59 class MODULES_EXPORT DeferredTaskHandler final : public ThreadSafeRefCounted<Def erredTaskHandler> { 59 class MODULES_EXPORT DeferredTaskHandler final : public ThreadSafeRefCounted<Def erredTaskHandler> {
60 public: 60 public:
61 static PassRefPtr<DeferredTaskHandler> create(); 61 static PassRefPtr<DeferredTaskHandler> create();
62 ~DeferredTaskHandler(); 62 ~DeferredTaskHandler();
63 63
64 void handleDeferredTasks(); 64 void handleDeferredTasks();
65 void contextWillBeDestroyed(); 65 void contextWillBeDestroyed();
66 66
67 // AbstractAudioContext can pull node(s) at the end of each render quantum e ven when 67 // BaseAudioContext can pull node(s) at the end of each render quantum even when
68 // they are not connected to any downstream nodes. These two methods are 68 // they are not connected to any downstream nodes. These two methods are
69 // called by the nodes who want to add/remove themselves into/from the 69 // called by the nodes who want to add/remove themselves into/from the
70 // automatic pull lists. 70 // automatic pull lists.
71 void addAutomaticPullNode(AudioHandler*); 71 void addAutomaticPullNode(AudioHandler*);
72 void removeAutomaticPullNode(AudioHandler*); 72 void removeAutomaticPullNode(AudioHandler*);
73 // Called right before handlePostRenderTasks() to handle nodes which need to 73 // Called right before handlePostRenderTasks() to handle nodes which need to
74 // be pulled even when they are not connected to anything. 74 // be pulled even when they are not connected to anything.
75 void processAutomaticPullNodes(size_t framesToProcess); 75 void processAutomaticPullNodes(size_t framesToProcess);
76 76
77 // Keep track of AudioNode's that have their channel count mode changed. We 77 // Keep track of AudioNode's that have their channel count mode changed. We
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 #endif 128 #endif
129 129
130 class MODULES_EXPORT AutoLocker { 130 class MODULES_EXPORT AutoLocker {
131 STACK_ALLOCATED(); 131 STACK_ALLOCATED();
132 public: 132 public:
133 explicit AutoLocker(DeferredTaskHandler& handler) 133 explicit AutoLocker(DeferredTaskHandler& handler)
134 : m_handler(handler) 134 : m_handler(handler)
135 { 135 {
136 m_handler.lock(); 136 m_handler.lock();
137 } 137 }
138 explicit AutoLocker(AbstractAudioContext*); 138 explicit AutoLocker(BaseAudioContext*);
139 139
140 ~AutoLocker() { m_handler.unlock(); } 140 ~AutoLocker() { m_handler.unlock(); }
141 141
142 private: 142 private:
143 DeferredTaskHandler& m_handler; 143 DeferredTaskHandler& m_handler;
144 }; 144 };
145 145
146 // This is for locking offline render thread (which is considered as the 146 // This is for locking offline render thread (which is considered as the
147 // audio thread) with unlocking on self-destruction at the end of the scope. 147 // audio thread) with unlocking on self-destruction at the end of the scope.
148 // Also note that it uses lock() rather than tryLock() because the timing 148 // Also note that it uses lock() rather than tryLock() because the timing
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 Vector<RefPtr<AudioHandler>> m_deletableOrphanHandlers; 195 Vector<RefPtr<AudioHandler>> m_deletableOrphanHandlers;
196 196
197 // Graph locking. 197 // Graph locking.
198 RecursiveMutex m_contextGraphMutex; 198 RecursiveMutex m_contextGraphMutex;
199 volatile ThreadIdentifier m_audioThread; 199 volatile ThreadIdentifier m_audioThread;
200 }; 200 };
201 201
202 } // namespace blink 202 } // namespace blink
203 203
204 #endif // DeferredTaskHandler_h 204 #endif // DeferredTaskHandler_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698