Index: Source/WebCore/Modules/webaudio/PannerNode.cpp |
=================================================================== |
--- Source/WebCore/Modules/webaudio/PannerNode.cpp (revision 143082) |
+++ Source/WebCore/Modules/webaudio/PannerNode.cpp (working copy) |
@@ -104,21 +104,28 @@ |
return; |
} |
- // Apply the panning effect. |
- double azimuth; |
- double elevation; |
- getAzimuthElevation(&azimuth, &elevation); |
- m_panner->pan(azimuth, elevation, source, destination, framesToProcess); |
+ // The audio thread can't block on this lock, so we call tryLock() instead. |
+ MutexTryLocker tryLocker(m_pannerLock); |
+ if (tryLocker.locked()) { |
+ // Apply the panning effect. |
+ double azimuth; |
+ double elevation; |
+ getAzimuthElevation(&azimuth, &elevation); |
+ m_panner->pan(azimuth, elevation, source, destination, framesToProcess); |
- // Get the distance and cone gain. |
- double totalGain = distanceConeGain(); |
+ // Get the distance and cone gain. |
+ double totalGain = distanceConeGain(); |
- // Snap to desired gain at the beginning. |
- if (m_lastGain == -1.0) |
- m_lastGain = totalGain; |
+ // Snap to desired gain at the beginning. |
+ if (m_lastGain == -1.0) |
+ m_lastGain = totalGain; |
- // Apply gain in-place with de-zippering. |
- destination->copyWithGainFrom(*destination, &m_lastGain, totalGain); |
+ // Apply gain in-place with de-zippering. |
+ destination->copyWithGainFrom(*destination, &m_lastGain, totalGain); |
+ } else { |
+ // Too bad - The tryLock() failed. We must be in the middle of changing the panner. |
+ destination->zero(); |
+ } |
} |
void PannerNode::reset() |
@@ -185,6 +192,9 @@ |
case EQUALPOWER: |
case HRTF: |
if (!m_panner.get() || model != m_panningModel) { |
+ // This synchronizes with process(). |
+ MutexLocker processLocker(m_pannerLock); |
+ |
OwnPtr<Panner> newPanner = Panner::create(model, sampleRate()); |
m_panner = newPanner.release(); |
m_panningModel = model; |