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

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

Issue 1865583002: Implement BaseAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 #endif 123 #endif
124 124
125 class MODULES_EXPORT AutoLocker { 125 class MODULES_EXPORT AutoLocker {
126 STACK_ALLOCATED(); 126 STACK_ALLOCATED();
127 public: 127 public:
128 explicit AutoLocker(DeferredTaskHandler& handler) 128 explicit AutoLocker(DeferredTaskHandler& handler)
129 : m_handler(handler) 129 : m_handler(handler)
130 { 130 {
131 m_handler.lock(); 131 m_handler.lock();
132 } 132 }
133 explicit AutoLocker(AbstractAudioContext*); 133 explicit AutoLocker(BaseAudioContext*);
134 134
135 ~AutoLocker() { m_handler.unlock(); } 135 ~AutoLocker() { m_handler.unlock(); }
136 136
137 private: 137 private:
138 DeferredTaskHandler& m_handler; 138 DeferredTaskHandler& m_handler;
139 }; 139 };
140 140
141 // This is for locking offline render thread (which is considered as the 141 // This is for locking offline render thread (which is considered as the
142 // audio thread) with unlocking on self-destruction at the end of the scope. 142 // audio thread) with unlocking on self-destruction at the end of the scope.
143 // Also note that it uses lock() rather than tryLock() because the timing 143 // Also note that it uses lock() rather than tryLock() because the timing
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 Vector<RefPtr<AudioHandler>> m_deletableOrphanHandlers; 187 Vector<RefPtr<AudioHandler>> m_deletableOrphanHandlers;
188 188
189 // Graph locking. 189 // Graph locking.
190 RecursiveMutex m_contextGraphMutex; 190 RecursiveMutex m_contextGraphMutex;
191 volatile ThreadIdentifier m_audioThread; 191 volatile ThreadIdentifier m_audioThread;
192 }; 192 };
193 193
194 } // namespace blink 194 } // namespace blink
195 195
196 #endif // DeferredTaskHandler_h 196 #endif // DeferredTaskHandler_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698