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 19 matching lines...) Expand all Loading... |
30 #include "wtf/HashSet.h" | 30 #include "wtf/HashSet.h" |
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 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 class AudioContext; | 40 class AbstractAudioContext; |
41 class AudioHandler; | 41 class AudioHandler; |
42 class AudioNodeOutput; | 42 class AudioNodeOutput; |
43 class AudioSummingJunction; | 43 class AudioSummingJunction; |
44 | 44 |
45 // DeferredTaskHandler manages the major part of pre- and post- rendering tasks, | 45 // DeferredTaskHandler manages the major part of pre- and post- rendering tasks, |
46 // and provides a lock mechanism against the audio rendering graph. A | 46 // and provides a lock mechanism against the audio rendering graph. A |
47 // DeferredTaskHandler object is created when an AudioContext object is created. | 47 // DeferredTaskHandler object is created when an AbstractAudioContext object is
created. |
48 // | 48 // |
49 // DeferredTaskHandler outlives the AudioContext only if all of the following | 49 // DeferredTaskHandler outlives the AbstractAudioContext only if all of the foll
owing |
50 // conditions match: | 50 // conditions match: |
51 // - An audio rendering thread is running, | 51 // - An audio rendering thread is running, |
52 // - It is requested to stop, | 52 // - It is requested to stop, |
53 // - The audio rendering thread calls requestToDeleteHandlersOnMainThread(), | 53 // - The audio rendering thread calls requestToDeleteHandlersOnMainThread(), |
54 // - It posts a task of deleteHandlersOnMainThread(), and | 54 // - It posts a task of deleteHandlersOnMainThread(), and |
55 // - GC happens and it collects the AudioContext before the task execution. | 55 // - GC happens and it collects the AbstractAudioContext before the task executi
on. |
56 // | 56 // |
57 class MODULES_EXPORT DeferredTaskHandler final : public ThreadSafeRefCounted<Def
erredTaskHandler> { | 57 class MODULES_EXPORT DeferredTaskHandler final : public ThreadSafeRefCounted<Def
erredTaskHandler> { |
58 public: | 58 public: |
59 static PassRefPtr<DeferredTaskHandler> create(); | 59 static PassRefPtr<DeferredTaskHandler> create(); |
60 ~DeferredTaskHandler(); | 60 ~DeferredTaskHandler(); |
61 | 61 |
62 void handleDeferredTasks(); | 62 void handleDeferredTasks(); |
63 void contextWillBeDestroyed(); | 63 void contextWillBeDestroyed(); |
64 | 64 |
65 // AudioContext can pull node(s) at the end of each render quantum even when | 65 // AbstractAudioContext can pull node(s) at the end of each render quantum e
ven when |
66 // they are not connected to any downstream nodes. These two methods are | 66 // they are not connected to any downstream nodes. These two methods are |
67 // called by the nodes who want to add/remove themselves into/from the | 67 // called by the nodes who want to add/remove themselves into/from the |
68 // automatic pull lists. | 68 // automatic pull lists. |
69 void addAutomaticPullNode(AudioHandler*); | 69 void addAutomaticPullNode(AudioHandler*); |
70 void removeAutomaticPullNode(AudioHandler*); | 70 void removeAutomaticPullNode(AudioHandler*); |
71 // Called right before handlePostRenderTasks() to handle nodes which need to | 71 // Called right before handlePostRenderTasks() to handle nodes which need to |
72 // be pulled even when they are not connected to anything. | 72 // be pulled even when they are not connected to anything. |
73 void processAutomaticPullNodes(size_t framesToProcess); | 73 void processAutomaticPullNodes(size_t framesToProcess); |
74 | 74 |
75 // Keep track of AudioNode's that have their channel count mode changed. We | 75 // Keep track of AudioNode's that have their channel count mode changed. We |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 #endif | 110 #endif |
111 | 111 |
112 class MODULES_EXPORT AutoLocker { | 112 class MODULES_EXPORT AutoLocker { |
113 STACK_ALLOCATED(); | 113 STACK_ALLOCATED(); |
114 public: | 114 public: |
115 explicit AutoLocker(DeferredTaskHandler& handler) | 115 explicit AutoLocker(DeferredTaskHandler& handler) |
116 : m_handler(handler) | 116 : m_handler(handler) |
117 { | 117 { |
118 m_handler.lock(); | 118 m_handler.lock(); |
119 } | 119 } |
120 explicit AutoLocker(AudioContext*); | 120 explicit AutoLocker(AbstractAudioContext*); |
121 | 121 |
122 ~AutoLocker() { m_handler.unlock(); } | 122 ~AutoLocker() { m_handler.unlock(); } |
123 | 123 |
124 private: | 124 private: |
125 DeferredTaskHandler& m_handler; | 125 DeferredTaskHandler& m_handler; |
126 }; | 126 }; |
127 | 127 |
128 private: | 128 private: |
129 DeferredTaskHandler(); | 129 DeferredTaskHandler(); |
130 void updateAutomaticPullNodes(); | 130 void updateAutomaticPullNodes(); |
(...skipping 28 matching lines...) Expand all Loading... |
159 Vector<RefPtr<AudioHandler>> m_deletableOrphanHandlers; | 159 Vector<RefPtr<AudioHandler>> m_deletableOrphanHandlers; |
160 | 160 |
161 // Graph locking. | 161 // Graph locking. |
162 RecursiveMutex m_contextGraphMutex; | 162 RecursiveMutex m_contextGraphMutex; |
163 volatile ThreadIdentifier m_audioThread; | 163 volatile ThreadIdentifier m_audioThread; |
164 }; | 164 }; |
165 | 165 |
166 } // namespace blink | 166 } // namespace blink |
167 | 167 |
168 #endif // DeferredTaskHandler_h | 168 #endif // DeferredTaskHandler_h |
OLD | NEW |