Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012, Google Inc. All rights reserved. | 2 * Copyright (C) 2012, 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 14 matching lines...) Expand all Loading... | |
| 25 #ifndef AudioSummingJunction_h | 25 #ifndef AudioSummingJunction_h |
| 26 #define AudioSummingJunction_h | 26 #define AudioSummingJunction_h |
| 27 | 27 |
| 28 #include "platform/audio/AudioBus.h" | 28 #include "platform/audio/AudioBus.h" |
| 29 #include "platform/heap/Handle.h" | 29 #include "platform/heap/Handle.h" |
| 30 #include "wtf/HashSet.h" | 30 #include "wtf/HashSet.h" |
| 31 #include "wtf/Vector.h" | 31 #include "wtf/Vector.h" |
| 32 | 32 |
| 33 namespace blink { | 33 namespace blink { |
| 34 | 34 |
| 35 class AudioContext; | |
| 36 class AudioNodeOutput; | 35 class AudioNodeOutput; |
| 36 class DeferredTaskHandler; | |
| 37 | 37 |
| 38 // An AudioSummingJunction represents a point where zero, one, or more AudioNode Outputs connect. | 38 // An AudioSummingJunction represents a point where zero, one, or more AudioNode Outputs connect. |
| 39 | 39 |
| 40 class AudioSummingJunction : public GarbageCollectedFinalized<AudioSummingJuncti on> { | 40 class AudioSummingJunction { |
| 41 public: | 41 public: |
| 42 virtual ~AudioSummingJunction(); | 42 virtual ~AudioSummingJunction(); |
| 43 DECLARE_VIRTUAL_TRACE(); | |
| 44 void dispose(); | |
| 45 | 43 |
| 46 // Can be called from any thread. | 44 // Can be called from any thread. |
| 47 AudioContext* context() { return m_context.get(); } | 45 DeferredTaskHandler& deferredTaskHandler() { return *m_deferredTaskHandler; } |
|
Raymond Toy
2015/03/25 15:43:54
Is it possible for m_deferredTaskHandler to ever b
tkent
2015/03/25 22:28:08
It's never be null. AudioSummingJunction construc
| |
| 48 | 46 |
| 49 // This must be called whenever we modify m_outputs. | 47 // This must be called whenever we modify m_outputs. |
| 50 void changedOutputs(); | 48 void changedOutputs(); |
| 51 | 49 |
| 52 // This copies m_outputs to m_renderingOutputs. Please see comments for thes e lists below. | 50 // This copies m_outputs to m_renderingOutputs. Please see comments for thes e lists below. |
| 53 // This must be called when we own the context's graph lock in the audio thr ead at the very start or end of the render quantum. | 51 // This must be called when we own the context's graph lock in the audio thr ead at the very start or end of the render quantum. |
| 54 void updateRenderingState(); | 52 void updateRenderingState(); |
| 55 | 53 |
| 56 // Rendering code accesses its version of the current connections here. | 54 // Rendering code accesses its version of the current connections here. |
| 57 unsigned numberOfRenderingConnections() const { return m_renderingOutputs.si ze(); } | 55 unsigned numberOfRenderingConnections() const { return m_renderingOutputs.si ze(); } |
| 58 AudioNodeOutput* renderingOutput(unsigned i) { return m_renderingOutputs[i]; } | 56 AudioNodeOutput* renderingOutput(unsigned i) { return m_renderingOutputs[i]; } |
| 59 bool isConnected() const { return numberOfRenderingConnections() > 0; } | 57 bool isConnected() const { return numberOfRenderingConnections() > 0; } |
| 60 | 58 |
| 61 virtual void didUpdate() = 0; | 59 virtual void didUpdate() = 0; |
| 62 | 60 |
| 63 protected: | 61 protected: |
| 64 explicit AudioSummingJunction(AudioContext*); | 62 explicit AudioSummingJunction(DeferredTaskHandler&); |
| 65 | 63 |
| 66 Member<AudioContext> m_context; | 64 RefPtr<DeferredTaskHandler> m_deferredTaskHandler; |
| 67 | 65 |
| 68 // m_outputs contains the AudioNodeOutputs representing current connections which are not disabled. | 66 // m_outputs contains the AudioNodeOutputs representing current connections which are not disabled. |
| 69 // The rendering code should never use this directly, but instead uses m_ren deringOutputs. | 67 // The rendering code should never use this directly, but instead uses m_ren deringOutputs. |
| 70 // Oilpan: Since items are added to the hash set by the audio thread (not re gistered to Oilpan), | 68 // Oilpan: Since items are added to the hash set by the audio thread (not re gistered to Oilpan), |
| 71 // we cannot use a HeapHashSet. | 69 // we cannot use a HeapHashSet. |
| 72 GC_PLUGIN_IGNORE("http://crbug.com/404527") | 70 GC_PLUGIN_IGNORE("http://crbug.com/404527") |
| 73 HashSet<AudioNodeOutput*> m_outputs; | 71 HashSet<AudioNodeOutput*> m_outputs; |
| 74 | 72 |
| 75 // m_renderingOutputs is a copy of m_outputs which will never be modified du ring the graph rendering on the audio thread. | 73 // m_renderingOutputs is a copy of m_outputs which will never be modified du ring the graph rendering on the audio thread. |
| 76 // This is the list which is used by the rendering code. | 74 // This is the list which is used by the rendering code. |
| 77 // Whenever m_outputs is modified, the context is told so it can later updat e m_renderingOutputs from m_outputs at a safe time. | 75 // Whenever m_outputs is modified, the context is told so it can later updat e m_renderingOutputs from m_outputs at a safe time. |
| 78 // Most of the time, m_renderingOutputs is identical to m_outputs. | 76 // Most of the time, m_renderingOutputs is identical to m_outputs. |
| 79 // Oilpan: Since items are added to the vector by the audio thread (not regi stered to Oilpan), | 77 // Oilpan: Since items are added to the vector by the audio thread (not regi stered to Oilpan), |
| 80 // we cannot use a HeapVector. | 78 // we cannot use a HeapVector. |
| 81 GC_PLUGIN_IGNORE("http://crbug.com/404527") | 79 GC_PLUGIN_IGNORE("http://crbug.com/404527") |
| 82 Vector<AudioNodeOutput*> m_renderingOutputs; | 80 Vector<AudioNodeOutput*> m_renderingOutputs; |
| 83 | 81 |
| 84 // m_renderingStateNeedUpdating keeps track if m_outputs is modified. | 82 // m_renderingStateNeedUpdating keeps track if m_outputs is modified. |
| 85 bool m_renderingStateNeedUpdating; | 83 bool m_renderingStateNeedUpdating; |
| 86 | 84 |
| 87 bool m_didCallDispose; | 85 bool m_didCallDispose; |
| 88 }; | 86 }; |
| 89 | 87 |
| 90 } // namespace blink | 88 } // namespace blink |
| 91 | 89 |
| 92 #endif // AudioSummingJunction_h | 90 #endif // AudioSummingJunction_h |
| OLD | NEW |