Changeset 118247 in webkit
- Timestamp:
- May 23, 2012 2:46:15 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r118246 r118247 1 2012-05-23 Chris Rogers <crogers@google.com> 2 3 AudioParam must support fan-in (multiple audio connections) 4 https://bugs.webkit.org/show_bug.cgi?id=83610 5 6 Reviewed by Kenneth Russell. 7 8 * webaudio/audioparam-connect-audioratesignal.html: 9 * webaudio/audioparam-summingjunction-expected.txt: Added. 10 * webaudio/audioparam-summingjunction.html: Added. 11 1 12 2012-04-12 Eric Uhrhane <ericu@chromium.org> 2 13 -
trunk/LayoutTests/webaudio/audioparam-connect-audioratesignal.html
r117404 r118247 88 88 // Create a gain node controlling the gain of constantSource and make the connections. 89 89 var gainNode = context.createGainNode(); 90 91 // Intrinsic baseline gain of zero. 92 gainNode.gain.value = 0; 93 90 94 constantSource.connect(gainNode); 91 95 gainNode.connect(context.destination); -
trunk/Source/WebCore/ChangeLog
r118241 r118247 1 2012-05-23 Chris Rogers <crogers@google.com> 2 3 AudioParam must support fan-in (multiple audio connections) (take 2) 4 https://bugs.webkit.org/show_bug.cgi?id=83610 5 6 Reviewed by Kenneth Russell. 7 8 This re-lands bug: https://bugs.webkit.org/show_bug.cgi?id=83610 9 Now that a fix has been landed: http://trac.webkit.org/changeset/118099 10 11 Test: webaudio/audioparam-summingjunction.html 12 13 * Modules/webaudio/AudioParam.cpp: 14 * Modules/webaudio/AudioParam.h: 15 (WebCore::AudioParam::calculateSampleAccurateValues): 16 (WebCore::AudioParam::calculateAudioRateSignalValues): 17 Sums intrinsic parameter value with all audio-rate connections. 18 19 (WebCore::AudioParam::connect): 20 (WebCore::AudioParam::disconnect): 21 Support multiple connections. 22 23 (WebCore::AudioParam::hasSampleAccurateValues): 24 If we have one or more audio-rate connections. 25 26 (WebCore::AudioParam::AudioParam): 27 AudioParam now sub-classes AudioSummingJunction. 28 1 29 2012-05-23 Christophe Dumez <christophe.dumez@intel.com> 2 30 -
trunk/Source/WebCore/Modules/webaudio/AudioParam.cpp
r117404 r118247 102 102 return; 103 103 104 if ( m_audioRateSignal)104 if (numberOfRenderingConnections()) 105 105 calculateAudioRateSignalValues(values, numberOfValues); 106 106 else … … 110 110 void AudioParam::calculateAudioRateSignalValues(float* values, unsigned numberOfValues) 111 111 { 112 // FIXME: support fan-in (multiple audio connections to this parameter with unity-gain summing). 113 // https://bugs.webkit.org/show_bug.cgi?id=83610 114 ASSERT(m_audioRateSignal); 115 116 AudioBus* bus = m_audioRateSignal->pull(0, numberOfValues); 117 bool isBusGood = bus && bus->numberOfChannels() && bus->length() >= numberOfValues; 118 ASSERT(isBusGood); 119 if (!isBusGood) 112 bool isGood = numberOfRenderingConnections() && numberOfValues; 113 ASSERT(isGood); 114 if (!isGood) 120 115 return; 121 116 122 if (bus->numberOfChannels() == 1) { 123 // The normal case is to deal with a mono audio-rate signal. 124 memcpy(values, bus->channel(0)->data(), sizeof(float) * numberOfValues); 117 // The calculated result will be the "intrinsic" value summed with all audio-rate connections. 118 119 if (m_timeline.hasValues()) { 120 // Calculate regular timeline values, if we have any. 121 calculateTimelineValues(values, numberOfValues); 125 122 } else { 126 // Do a standard mixdown to one channel if necessary. 127 AudioBus wrapperBus(1, numberOfValues, false); 128 wrapperBus.setChannelMemory(0, values, numberOfValues); 129 wrapperBus.copyFrom(*bus); // Mixdown. 123 // Otherwise set values array to our constant value. 124 float value = m_value; // Cache in local. 125 126 // FIXME: can be optimized if we create a new VectorMath function. 127 for (unsigned i = 0; i < numberOfValues; ++i) 128 values[i] = value; 130 129 } 131 m_value = values[0]; // Update to first value. 130 131 // Now sum all of the audio-rate connections together (unity-gain summing junction). 132 // Note that connections would normally be mono, but we mix down to mono if necessary. 133 AudioBus summingBus(1, numberOfValues, false); 134 summingBus.setChannelMemory(0, values, numberOfValues); 135 136 for (unsigned i = 0; i < numberOfRenderingConnections(); ++i) { 137 AudioNodeOutput* output = renderingOutput(i); 138 ASSERT(output); 139 140 // Render audio from this output. 141 AudioBus* connectionBus = output->pull(0, numberOfValues); 142 143 // Sum, with unity-gain. 144 summingBus.sumFrom(*connectionBus); 145 } 132 146 } 133 147 … … 145 159 } 146 160 147 void AudioParam::connect(AudioNodeOutput* audioRateSignal)161 void AudioParam::connect(AudioNodeOutput* output) 148 162 { 149 163 ASSERT(context()->isGraphOwner()); 150 ASSERT(audioRateSignal); 151 if (!audioRateSignal) 164 165 ASSERT(output); 166 if (!output) 152 167 return; 153 168 154 if (m_audioRateSignal && m_audioRateSignal != audioRateSignal) { 155 // Because we don't currently support fan-in we must explicitly disconnect from an old output. 156 m_audioRateSignal->removeParam(this); 157 } 169 if (m_outputs.contains(output)) 170 return; 158 171 159 audioRateSignal->addParam(this); 160 m_audioRateSignal = audioRateSignal; 172 output->addParam(this); 173 m_outputs.add(output); 174 changedOutputs(); 161 175 } 162 176 163 void AudioParam::disconnect(AudioNodeOutput* audioRateSignal)177 void AudioParam::disconnect(AudioNodeOutput* output) 164 178 { 165 179 ASSERT(context()->isGraphOwner()); 166 ASSERT(audioRateSignal); 167 if (!audioRateSignal) 180 181 ASSERT(output); 182 if (!output) 168 183 return; 169 184 170 // FIXME: support fan-in (multiple audio connections to this parameter with unity-gain summing). 171 // https://bugs.webkit.org/show_bug.cgi?id=83610 172 if (m_audioRateSignal == audioRateSignal) 173 m_audioRateSignal = 0; 185 if (m_outputs.contains(output)) { 186 m_outputs.remove(output); 187 changedOutputs(); 188 output->removeParam(this); 189 } 174 190 } 175 191 -
trunk/Source/WebCore/Modules/webaudio/AudioParam.h
r117404 r118247 32 32 #include "AudioContext.h" 33 33 #include "AudioParamTimeline.h" 34 #include "AudioSummingJunction.h" 34 35 #include "PlatformString.h" 35 36 #include <sys/types.h> … … 42 43 class AudioNodeOutput; 43 44 44 class AudioParam : public RefCounted<AudioParam> {45 class AudioParam : public AudioSummingJunction, public RefCounted<AudioParam> { 45 46 public: 46 47 static const double DefaultSmoothingConstant; … … 52 53 } 53 54 54 AudioContext* context() { return m_context.get(); } 55 // AudioSummingJunction 56 virtual bool canUpdateState() OVERRIDE { return true; } 57 virtual void didUpdate() OVERRIDE { } 55 58 56 59 float value(); … … 85 88 void cancelScheduledValues(float startTime) { m_timeline.cancelScheduledValues(startTime); } 86 89 87 bool hasSampleAccurateValues() { return m_timeline.hasValues() || m_audioRateSignal; }90 bool hasSampleAccurateValues() { return m_timeline.hasValues() || numberOfRenderingConnections(); } 88 91 89 92 // Calculates numberOfValues parameter values starting at the context's current time. … … 97 100 protected: 98 101 AudioParam(AudioContext* context, const String& name, double defaultValue, double minValue, double maxValue, unsigned units = 0) 99 : m_context(context)102 : AudioSummingJunction(context) 100 103 , m_name(name) 101 104 , m_value(defaultValue) … … 106 109 , m_smoothedValue(defaultValue) 107 110 , m_smoothingConstant(DefaultSmoothingConstant) 108 , m_audioRateSignal(0)109 111 { 110 112 } … … 114 116 void calculateTimelineValues(float* values, unsigned numberOfValues); 115 117 116 RefPtr<AudioContext> m_context;117 118 String m_name; 118 119 double m_value; … … 127 128 128 129 AudioParamTimeline m_timeline; 129 130 // An audio-rate signal directly providing parameter values.131 // FIXME: support fan-in (multiple audio connections to this parameter with unity-gain summing).132 // https://bugs.webkit.org/show_bug.cgi?id=83610133 AudioNodeOutput* m_audioRateSignal;134 130 }; 135 131
Note: See TracChangeset
for help on using the changeset viewer.