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 30 matching lines...) Expand all Loading... |
41 // It may be connected to one or more AudioNodeInputs. | 41 // It may be connected to one or more AudioNodeInputs. |
42 | 42 |
43 class AudioNodeOutput { | 43 class AudioNodeOutput { |
44 public: | 44 public: |
45 // It's OK to pass 0 for numberOfChannels in which case setNumberOfChannels(
) must be called later on. | 45 // It's OK to pass 0 for numberOfChannels in which case setNumberOfChannels(
) must be called later on. |
46 AudioNodeOutput(AudioNode*, unsigned numberOfChannels); | 46 AudioNodeOutput(AudioNode*, unsigned numberOfChannels); |
47 | 47 |
48 // Can be called from any thread. | 48 // Can be called from any thread. |
49 AudioNode* node() const { return m_node; } | 49 AudioNode* node() const { return m_node; } |
50 AudioContext* context() { return m_node->context(); } | 50 AudioContext* context() { return m_node->context(); } |
51 | 51 |
52 // Causes our AudioNode to process if it hasn't already for this render quan
tum. | 52 // Causes our AudioNode to process if it hasn't already for this render quan
tum. |
53 // It returns the bus containing the processed audio for this output, return
ing inPlaceBus if in-place processing was possible. | 53 // It returns the bus containing the processed audio for this output, return
ing inPlaceBus if in-place processing was possible. |
54 // Called from context's audio thread. | 54 // Called from context's audio thread. |
55 AudioBus* pull(AudioBus* inPlaceBus, size_t framesToProcess); | 55 AudioBus* pull(AudioBus* inPlaceBus, size_t framesToProcess); |
56 | 56 |
57 // bus() will contain the rendered audio after pull() is called for each ren
dering time quantum. | 57 // bus() will contain the rendered audio after pull() is called for each ren
dering time quantum. |
58 // Called from context's audio thread. | 58 // Called from context's audio thread. |
59 AudioBus* bus() const; | 59 AudioBus* bus() const; |
60 | 60 |
61 // renderingFanOutCount() is the number of AudioNodeInputs that we're connec
ted to during rendering. | 61 // renderingFanOutCount() is the number of AudioNodeInputs that we're connec
ted to during rendering. |
(...skipping 15 matching lines...) Expand all Loading... |
77 | 77 |
78 // Disable/Enable happens when there are still JavaScript references to a no
de, but it has otherwise "finished" its work. | 78 // Disable/Enable happens when there are still JavaScript references to a no
de, but it has otherwise "finished" its work. |
79 // For example, when a note has finished playing. It is kept around, becaus
e it may be played again at a later time. | 79 // For example, when a note has finished playing. It is kept around, becaus
e it may be played again at a later time. |
80 // They must be called with the context's graph lock. | 80 // They must be called with the context's graph lock. |
81 void disable(); | 81 void disable(); |
82 void enable(); | 82 void enable(); |
83 | 83 |
84 // updateRenderingState() is called in the audio thread at the start or end
of the render quantum to handle any recent changes to the graph state. | 84 // updateRenderingState() is called in the audio thread at the start or end
of the render quantum to handle any recent changes to the graph state. |
85 // It must be called with the context's graph lock. | 85 // It must be called with the context's graph lock. |
86 void updateRenderingState(); | 86 void updateRenderingState(); |
87 | 87 |
88 private: | 88 private: |
89 AudioNode* m_node; | 89 AudioNode* m_node; |
90 | 90 |
91 friend class AudioNodeInput; | 91 friend class AudioNodeInput; |
92 friend class AudioParam; | 92 friend class AudioParam; |
93 | 93 |
94 // These are called from AudioNodeInput. | 94 // These are called from AudioNodeInput. |
95 // They must be called with the context's graph lock. | 95 // They must be called with the context's graph lock. |
96 void addInput(AudioNodeInput*); | 96 void addInput(AudioNodeInput*); |
97 void removeInput(AudioNodeInput*); | 97 void removeInput(AudioNodeInput*); |
98 void addParam(AudioParam*); | 98 void addParam(AudioParam*); |
99 void removeParam(AudioParam*); | 99 void removeParam(AudioParam*); |
100 | 100 |
101 // fanOutCount() is the number of AudioNodeInputs that we're connected to. | 101 // fanOutCount() is the number of AudioNodeInputs that we're connected to. |
102 // This method should not be called in audio thread rendering code, instead
renderingFanOutCount() should be used. | 102 // This method should not be called in audio thread rendering code, instead
renderingFanOutCount() should be used. |
103 // It must be called with the context's graph lock. | 103 // It must be called with the context's graph lock. |
(...skipping 17 matching lines...) Expand all Loading... |
121 void propagateChannelCount(); | 121 void propagateChannelCount(); |
122 | 122 |
123 // updateNumberOfChannels() is called in the audio thread at the start or en
d of the render quantum to pick up channel changes. | 123 // updateNumberOfChannels() is called in the audio thread at the start or en
d of the render quantum to pick up channel changes. |
124 // It must be called with the context's graph lock. | 124 // It must be called with the context's graph lock. |
125 void updateNumberOfChannels(); | 125 void updateNumberOfChannels(); |
126 | 126 |
127 // m_numberOfChannels will only be changed in the audio thread. | 127 // m_numberOfChannels will only be changed in the audio thread. |
128 // The main thread sets m_desiredNumberOfChannels which will later get picke
d up in the audio thread in updateNumberOfChannels(). | 128 // The main thread sets m_desiredNumberOfChannels which will later get picke
d up in the audio thread in updateNumberOfChannels(). |
129 unsigned m_numberOfChannels; | 129 unsigned m_numberOfChannels; |
130 unsigned m_desiredNumberOfChannels; | 130 unsigned m_desiredNumberOfChannels; |
131 | 131 |
132 // m_internalBus and m_inPlaceBus must only be changed in the audio thread w
ith the context's graph lock (or constructor). | 132 // m_internalBus and m_inPlaceBus must only be changed in the audio thread w
ith the context's graph lock (or constructor). |
133 RefPtr<AudioBus> m_internalBus; | 133 RefPtr<AudioBus> m_internalBus; |
134 RefPtr<AudioBus> m_inPlaceBus; | 134 RefPtr<AudioBus> m_inPlaceBus; |
135 // If m_isInPlace is true, use m_inPlaceBus as the valid AudioBus; If false,
use the default m_internalBus. | 135 // If m_isInPlace is true, use m_inPlaceBus as the valid AudioBus; If false,
use the default m_internalBus. |
136 bool m_isInPlace; | 136 bool m_isInPlace; |
137 | 137 |
138 HashSet<AudioNodeInput*> m_inputs; | 138 HashSet<AudioNodeInput*> m_inputs; |
139 typedef HashSet<AudioNodeInput*>::iterator InputsIterator; | 139 typedef HashSet<AudioNodeInput*>::iterator InputsIterator; |
140 bool m_isEnabled; | 140 bool m_isEnabled; |
141 | 141 |
142 // For the purposes of rendering, keeps track of the number of inputs and Au
dioParams we're connected to. | 142 // For the purposes of rendering, keeps track of the number of inputs and Au
dioParams we're connected to. |
143 // These value should only be changed at the very start or end of the render
ing quantum. | 143 // These value should only be changed at the very start or end of the render
ing quantum. |
144 unsigned m_renderingFanOutCount; | 144 unsigned m_renderingFanOutCount; |
145 unsigned m_renderingParamFanOutCount; | 145 unsigned m_renderingParamFanOutCount; |
146 | 146 |
147 HashSet<RefPtr<AudioParam> > m_params; | 147 HashSet<RefPtr<AudioParam> > m_params; |
148 typedef HashSet<RefPtr<AudioParam> >::iterator ParamsIterator; | 148 typedef HashSet<RefPtr<AudioParam> >::iterator ParamsIterator; |
149 }; | 149 }; |
150 | 150 |
151 } // namespace WebCore | 151 } // namespace WebCore |
152 | 152 |
153 #endif // AudioNodeOutput_h | 153 #endif // AudioNodeOutput_h |
OLD | NEW |