Title: [143513] branches/chromium/1364/Source/WebCore/Modules/webaudio
Revision
143513
Author
cev...@google.com
Date
2013-02-20 15:04:18 -0800 (Wed, 20 Feb 2013)

Log Message

Merge 142687
BUG=172331
Review URL: https://codereview.chromium.org/12321030

Modified Paths

Diff

Modified: branches/chromium/1364/Source/WebCore/Modules/webaudio/PannerNode.cpp (143512 => 143513)


--- branches/chromium/1364/Source/WebCore/Modules/webaudio/PannerNode.cpp	2013-02-20 23:00:43 UTC (rev 143512)
+++ branches/chromium/1364/Source/WebCore/Modules/webaudio/PannerNode.cpp	2013-02-20 23:04:18 UTC (rev 143513)
@@ -103,21 +103,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()
@@ -157,6 +164,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;

Modified: branches/chromium/1364/Source/WebCore/Modules/webaudio/PannerNode.h (143512 => 143513)


--- branches/chromium/1364/Source/WebCore/Modules/webaudio/PannerNode.h	2013-02-20 23:00:43 UTC (rev 143512)
+++ branches/chromium/1364/Source/WebCore/Modules/webaudio/PannerNode.h	2013-02-20 23:04:18 UTC (rev 143513)
@@ -152,6 +152,9 @@
     float m_lastGain;
 
     unsigned m_connectionCount;
+
+    // Synchronize process() and setPanningModel() which can change the panner.
+    mutable Mutex m_pannerLock;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to