<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[162296] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/162296">162296</a></dd>
<dt>Author</dt> <dd>andersca@apple.com</dd>
<dt>Date</dt> <dd>2014-01-19 12:37:53 -0800 (Sun, 19 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Stop using MutexTryLocker in WebCore
https://bugs.webkit.org/show_bug.cgi?id=127254
Reviewed by Andreas Kling.
Instead use std::mutex and std::unique_lock with the std::try_to_lock constructor.
* Modules/webaudio/AudioBufferSourceNode.cpp:
(WebCore::AudioBufferSourceNode::process):
(WebCore::AudioBufferSourceNode::setBuffer):
* Modules/webaudio/AudioBufferSourceNode.h:
* Modules/webaudio/AudioParamTimeline.cpp:
(WebCore::AudioParamTimeline::insertEvent):
(WebCore::AudioParamTimeline::cancelScheduledValues):
(WebCore::AudioParamTimeline::valueForContextTime):
(WebCore::AudioParamTimeline::valuesForTimeRange):
(WebCore::AudioParamTimeline::valuesForTimeRangeImpl):
* Modules/webaudio/AudioParamTimeline.h:
* Modules/webaudio/ConvolverNode.cpp:
(WebCore::ConvolverNode::process):
(WebCore::ConvolverNode::reset):
(WebCore::ConvolverNode::setBuffer):
* Modules/webaudio/ConvolverNode.h:
* Modules/webaudio/MediaElementAudioSourceNode.cpp:
(WebCore::MediaElementAudioSourceNode::setFormat):
(WebCore::MediaElementAudioSourceNode::process):
(WebCore::MediaElementAudioSourceNode::lock):
(WebCore::MediaElementAudioSourceNode::unlock):
* Modules/webaudio/MediaElementAudioSourceNode.h:
* Modules/webaudio/MediaStreamAudioSourceNode.cpp:
(WebCore::MediaStreamAudioSourceNode::setFormat):
(WebCore::MediaStreamAudioSourceNode::process):
* Modules/webaudio/MediaStreamAudioSourceNode.h:
* Modules/webaudio/OscillatorNode.cpp:
(WebCore::OscillatorNode::process):
(WebCore::OscillatorNode::setPeriodicWave):
* Modules/webaudio/OscillatorNode.h:
* Modules/webaudio/PannerNode.cpp:
(WebCore::PannerNode::process):
(WebCore::PannerNode::setPanningModel):
* Modules/webaudio/PannerNode.h:
* Modules/webaudio/WaveShaperProcessor.cpp:
(WebCore::WaveShaperProcessor::setCurve):
(WebCore::WaveShaperProcessor::setOversample):
(WebCore::WaveShaperProcessor::process):
* Modules/webaudio/WaveShaperProcessor.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioAudioBufferSourceNodecpp">trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioAudioBufferSourceNodeh">trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioAudioParamTimelinecpp">trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioAudioParamTimelineh">trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioConvolverNodecpp">trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioConvolverNodeh">trunk/Source/WebCore/Modules/webaudio/ConvolverNode.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioMediaElementAudioSourceNodecpp">trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioMediaElementAudioSourceNodeh">trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioMediaStreamAudioSourceNodecpp">trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioMediaStreamAudioSourceNodeh">trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioOscillatorNodecpp">trunk/Source/WebCore/Modules/webaudio/OscillatorNode.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioOscillatorNodeh">trunk/Source/WebCore/Modules/webaudio/OscillatorNode.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioPannerNodecpp">trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioPannerNodeh">trunk/Source/WebCore/Modules/webaudio/PannerNode.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioWaveShaperProcessorcpp">trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioWaveShaperProcessorh">trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/ChangeLog        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -1,3 +1,52 @@
</span><ins>+2014-01-19 Anders Carlsson <andersca@apple.com>
+
+ Stop using MutexTryLocker in WebCore
+ https://bugs.webkit.org/show_bug.cgi?id=127254
+
+ Reviewed by Andreas Kling.
+
+ Instead use std::mutex and std::unique_lock with the std::try_to_lock constructor.
+
+ * Modules/webaudio/AudioBufferSourceNode.cpp:
+ (WebCore::AudioBufferSourceNode::process):
+ (WebCore::AudioBufferSourceNode::setBuffer):
+ * Modules/webaudio/AudioBufferSourceNode.h:
+ * Modules/webaudio/AudioParamTimeline.cpp:
+ (WebCore::AudioParamTimeline::insertEvent):
+ (WebCore::AudioParamTimeline::cancelScheduledValues):
+ (WebCore::AudioParamTimeline::valueForContextTime):
+ (WebCore::AudioParamTimeline::valuesForTimeRange):
+ (WebCore::AudioParamTimeline::valuesForTimeRangeImpl):
+ * Modules/webaudio/AudioParamTimeline.h:
+ * Modules/webaudio/ConvolverNode.cpp:
+ (WebCore::ConvolverNode::process):
+ (WebCore::ConvolverNode::reset):
+ (WebCore::ConvolverNode::setBuffer):
+ * Modules/webaudio/ConvolverNode.h:
+ * Modules/webaudio/MediaElementAudioSourceNode.cpp:
+ (WebCore::MediaElementAudioSourceNode::setFormat):
+ (WebCore::MediaElementAudioSourceNode::process):
+ (WebCore::MediaElementAudioSourceNode::lock):
+ (WebCore::MediaElementAudioSourceNode::unlock):
+ * Modules/webaudio/MediaElementAudioSourceNode.h:
+ * Modules/webaudio/MediaStreamAudioSourceNode.cpp:
+ (WebCore::MediaStreamAudioSourceNode::setFormat):
+ (WebCore::MediaStreamAudioSourceNode::process):
+ * Modules/webaudio/MediaStreamAudioSourceNode.h:
+ * Modules/webaudio/OscillatorNode.cpp:
+ (WebCore::OscillatorNode::process):
+ (WebCore::OscillatorNode::setPeriodicWave):
+ * Modules/webaudio/OscillatorNode.h:
+ * Modules/webaudio/PannerNode.cpp:
+ (WebCore::PannerNode::process):
+ (WebCore::PannerNode::setPanningModel):
+ * Modules/webaudio/PannerNode.h:
+ * Modules/webaudio/WaveShaperProcessor.cpp:
+ (WebCore::WaveShaperProcessor::setCurve):
+ (WebCore::WaveShaperProcessor::setOversample):
+ (WebCore::WaveShaperProcessor::process):
+ * Modules/webaudio/WaveShaperProcessor.h:
+
</ins><span class="cx"> 2014-01-19 Alberto Garcia <berto@igalia.com>
</span><span class="cx">
</span><span class="cx"> Does not build with SVG disabled
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioAudioBufferSourceNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.cpp        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -93,52 +93,50 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // The audio thread can't block on this lock, so we call tryLock() instead.
- MutexTryLocker tryLocker(m_processLock);
- if (tryLocker.locked()) {
- if (!buffer()) {
- outputBus->zero();
- return;
- }
</del><ins>+ // The audio thread can't block on this lock, so we use std::try_to_lock instead.
+ std::unique_lock<std::mutex> lock(m_processMutex, std::try_to_lock);
+ if (!lock.owns_lock()) {
+ // Too bad - the try_lock() failed. We must be in the middle of changing buffers and were already outputting silence anyway.
+ outputBus->zero();
+ return;
+ }
</ins><span class="cx">
</span><del>- // After calling setBuffer() with a buffer having a different number of channels, there can in rare cases be a slight delay
- // before the output bus is updated to the new number of channels because of use of tryLocks() in the context's updating system.
- // In this case, if the the buffer has just been changed and we're not quite ready yet, then just output silence.
- if (numberOfChannels() != buffer()->numberOfChannels()) {
- outputBus->zero();
- return;
- }
</del><ins>+ if (!buffer()) {
+ outputBus->zero();
+ return;
+ }
</ins><span class="cx">
</span><del>- size_t quantumFrameOffset;
- size_t bufferFramesToProcess;
</del><ins>+ // After calling setBuffer() with a buffer having a different number of channels, there can in rare cases be a slight delay
+ // before the output bus is updated to the new number of channels because of use of tryLocks() in the context's updating system.
+ // In this case, if the the buffer has just been changed and we're not quite ready yet, then just output silence.
+ if (numberOfChannels() != buffer()->numberOfChannels()) {
+ outputBus->zero();
+ return;
+ }
</ins><span class="cx">
</span><del>- updateSchedulingInfo(framesToProcess,
- outputBus,
- quantumFrameOffset,
- bufferFramesToProcess);
-
- if (!bufferFramesToProcess) {
- outputBus->zero();
- return;
- }
</del><ins>+ size_t quantumFrameOffset;
+ size_t bufferFramesToProcess;
</ins><span class="cx">
</span><del>- for (unsigned i = 0; i < outputBus->numberOfChannels(); ++i)
- m_destinationChannels[i] = outputBus->channel(i)->mutableData();
</del><ins>+ updateSchedulingInfo(framesToProcess, outputBus, quantumFrameOffset, bufferFramesToProcess);
</ins><span class="cx">
</span><del>- // Render by reading directly from the buffer.
- if (!renderFromBuffer(outputBus, quantumFrameOffset, bufferFramesToProcess)) {
- outputBus->zero();
- return;
- }
</del><ins>+ if (!bufferFramesToProcess) {
+ outputBus->zero();
+ return;
+ }
</ins><span class="cx">
</span><del>- // Apply the gain (in-place) to the output bus.
- float totalGain = gain()->value() * m_buffer->gain();
- outputBus->copyWithGainFrom(*outputBus, &m_lastGain, totalGain);
- outputBus->clearSilentFlag();
- } else {
- // Too bad - the tryLock() failed. We must be in the middle of changing buffers and were already outputting silence anyway.
</del><ins>+ for (unsigned i = 0; i < outputBus->numberOfChannels(); ++i)
+ m_destinationChannels[i] = outputBus->channel(i)->mutableData();
+
+ // Render by reading directly from the buffer.
+ if (!renderFromBuffer(outputBus, quantumFrameOffset, bufferFramesToProcess)) {
</ins><span class="cx"> outputBus->zero();
</span><ins>+ return;
</ins><span class="cx"> }
</span><ins>+
+ // Apply the gain (in-place) to the output bus.
+ float totalGain = gain()->value() * m_buffer->gain();
+ outputBus->copyWithGainFrom(*outputBus, &m_lastGain, totalGain);
+ outputBus->clearSilentFlag();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Returns true if we're finished.
</span><span class="lines">@@ -343,7 +341,7 @@
</span><span class="cx"> AudioContext::AutoLocker contextLocker(*context());
</span><span class="cx">
</span><span class="cx"> // This synchronizes with process().
</span><del>- MutexLocker processLocker(m_processLock);
</del><ins>+ std::lock_guard<std::mutex> lock(m_processMutex);
</ins><span class="cx">
</span><span class="cx"> if (buffer) {
</span><span class="cx"> // Do any necesssary re-configuration to the buffer's number of channels.
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioAudioBufferSourceNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBufferSourceNode.h        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -32,9 +32,9 @@
</span><span class="cx"> #include "ExceptionCode.h"
</span><span class="cx"> #include "PannerNode.h"
</span><span class="cx"> #include <memory>
</span><ins>+#include <mutex>
</ins><span class="cx"> #include <wtf/PassRefPtr.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><del>-#include <wtf/Threading.h>
</del><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -150,7 +150,7 @@
</span><span class="cx"> PannerNode* m_pannerNode;
</span><span class="cx">
</span><span class="cx"> // This synchronizes process() with setBuffer() which can cause dynamic channel count changes.
</span><del>- mutable Mutex m_processLock;
</del><ins>+ mutable std::mutex m_processMutex;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioAudioParamTimelinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.cpp        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx"> if (!isValid)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- MutexLocker locker(m_eventsLock);
</del><ins>+ std::lock_guard<std::mutex> lock(m_eventsMutex);
</ins><span class="cx">
</span><span class="cx"> unsigned i = 0;
</span><span class="cx"> float insertTime = event.time();
</span><span class="lines">@@ -100,7 +100,7 @@
</span><span class="cx">
</span><span class="cx"> void AudioParamTimeline::cancelScheduledValues(float startTime)
</span><span class="cx"> {
</span><del>- MutexLocker locker(m_eventsLock);
</del><ins>+ std::lock_guard<std::mutex> lock(m_eventsMutex);
</ins><span class="cx">
</span><span class="cx"> // Remove all events starting at startTime.
</span><span class="cx"> for (unsigned i = 0; i < m_events.size(); ++i) {
</span><span class="lines">@@ -116,8 +116,8 @@
</span><span class="cx"> ASSERT(context);
</span><span class="cx">
</span><span class="cx"> {
</span><del>- MutexTryLocker tryLocker(m_eventsLock);
- if (!tryLocker.locked() || !context || !m_events.size() || context->currentTime() < m_events[0].time()) {
</del><ins>+ std::unique_lock<std::mutex> lock(m_eventsMutex, std::try_to_lock);
+ if (!lock.owns_lock() || !context || !m_events.size() || context->currentTime() < m_events[0].time()) {
</ins><span class="cx"> hasValue = false;
</span><span class="cx"> return defaultValue;
</span><span class="cx"> }
</span><span class="lines">@@ -135,18 +135,11 @@
</span><span class="cx"> return value;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-float AudioParamTimeline::valuesForTimeRange(
- double startTime,
- double endTime,
- float defaultValue,
- float* values,
- unsigned numberOfValues,
- double sampleRate,
- double controlRate)
</del><ins>+float AudioParamTimeline::valuesForTimeRange(double startTime, double endTime, float defaultValue, float* values, unsigned numberOfValues, double sampleRate, double controlRate)
</ins><span class="cx"> {
</span><span class="cx"> // We can't contend the lock in the realtime audio thread.
</span><del>- MutexTryLocker tryLocker(m_eventsLock);
- if (!tryLocker.locked()) {
</del><ins>+ std::unique_lock<std::mutex> lock(m_eventsMutex, std::try_to_lock);
+ if (!lock.owns_lock()) {
</ins><span class="cx"> if (values) {
</span><span class="cx"> for (unsigned i = 0; i < numberOfValues; ++i)
</span><span class="cx"> values[i] = defaultValue;
</span><span class="lines">@@ -159,14 +152,7 @@
</span><span class="cx"> return value;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-float AudioParamTimeline::valuesForTimeRangeImpl(
- double startTime,
- double endTime,
- float defaultValue,
- float* values,
- unsigned numberOfValues,
- double sampleRate,
- double controlRate)
</del><ins>+float AudioParamTimeline::valuesForTimeRangeImpl(double startTime, double endTime, float defaultValue, float* values, unsigned numberOfValues, double sampleRate, double controlRate)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(values);
</span><span class="cx"> if (!values)
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioAudioParamTimelineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.h (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.h        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/AudioParamTimeline.h        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -30,10 +30,10 @@
</span><span class="cx"> #define AudioParamTimeline_h
</span><span class="cx">
</span><span class="cx"> #include "AudioContext.h"
</span><ins>+#include <mutex>
</ins><span class="cx"> #include <runtime/Float32Array.h>
</span><span class="cx"> #include <wtf/PassRefPtr.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><del>-#include <wtf/Threading.h>
</del><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -107,7 +107,7 @@
</span><span class="cx">
</span><span class="cx"> Vector<ParamEvent> m_events;
</span><span class="cx">
</span><del>- Mutex m_eventsLock;
</del><ins>+ std::mutex m_eventsMutex;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioConvolverNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -73,27 +73,28 @@
</span><span class="cx"> ASSERT(outputBus);
</span><span class="cx">
</span><span class="cx"> // Synchronize with possible dynamic changes to the impulse response.
</span><del>- MutexTryLocker tryLocker(m_processLock);
- if (tryLocker.locked()) {
- if (!isInitialized() || !m_reverb.get())
- outputBus->zero();
- else {
- // Process using the convolution engine.
- // Note that we can handle the case where nothing is connected to the input, in which case we'll just feed silence into the convolver.
- // FIXME: If we wanted to get fancy we could try to factor in the 'tail time' and stop processing once the tail dies down if
- // we keep getting fed silence.
- m_reverb->process(input(0)->bus(), outputBus, framesToProcess);
- }
- } else {
- // Too bad - the tryLock() failed. We must be in the middle of setting a new impulse response.
</del><ins>+ std::unique_lock<std::mutex> lock(m_processMutex, std::try_to_lock);
+ if (!lock.owns_lock()) {
+ // Too bad - the try_lock() failed. We must be in the middle of setting a new impulse response.
</ins><span class="cx"> outputBus->zero();
</span><ins>+ return;
</ins><span class="cx"> }
</span><ins>+
+ if (!isInitialized() || !m_reverb.get())
+ outputBus->zero();
+ else {
+ // Process using the convolution engine.
+ // Note that we can handle the case where nothing is connected to the input, in which case we'll just feed silence into the convolver.
+ // FIXME: If we wanted to get fancy we could try to factor in the 'tail time' and stop processing once the tail dies down if
+ // we keep getting fed silence.
+ m_reverb->process(input(0)->bus(), outputBus, framesToProcess);
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ConvolverNode::reset()
</span><span class="cx"> {
</span><del>- MutexLocker locker(m_processLock);
- if (m_reverb.get())
</del><ins>+ std::lock_guard<std::mutex> lock(m_processMutex);
+ if (m_reverb)
</ins><span class="cx"> m_reverb->reset();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -144,7 +145,7 @@
</span><span class="cx">
</span><span class="cx"> {
</span><span class="cx"> // Synchronize with process().
</span><del>- MutexLocker locker(m_processLock);
</del><ins>+ std::lock_guard<std::mutex> lock(m_processMutex);
</ins><span class="cx"> m_reverb = reverb.release();
</span><span class="cx"> m_buffer = buffer;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioConvolverNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/ConvolverNode.h (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/ConvolverNode.h        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/ConvolverNode.h        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -26,9 +26,9 @@
</span><span class="cx"> #define ConvolverNode_h
</span><span class="cx">
</span><span class="cx"> #include "AudioNode.h"
</span><ins>+#include <mutex>
</ins><span class="cx"> #include <wtf/OwnPtr.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><del>-#include <wtf/Threading.h>
</del><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx"> RefPtr<AudioBuffer> m_buffer;
</span><span class="cx">
</span><span class="cx"> // This synchronizes dynamic changes to the convolution impulse response with process().
</span><del>- mutable Mutex m_processLock;
</del><ins>+ mutable std::mutex m_processMutex;
</ins><span class="cx">
</span><span class="cx"> // Normalize the impulse response or not. Must default to true.
</span><span class="cx"> bool m_normalize;
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioMediaElementAudioSourceNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx"> m_sourceSampleRate = sourceSampleRate;
</span><span class="cx">
</span><span class="cx"> // Synchronize with process().
</span><del>- Locker<MediaElementAudioSourceNode> locker(*this);
</del><ins>+ std::lock_guard<MediaElementAudioSourceNode> lock(*this);
</ins><span class="cx">
</span><span class="cx"> if (sourceSampleRate != sampleRate()) {
</span><span class="cx"> double scaleFactor = sourceSampleRate / sampleRate();
</span><span class="lines">@@ -109,27 +109,28 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // Use a tryLock() to avoid contention in the real-time audio thread.
</del><ins>+ // Use a std::try_to_lock to avoid contention in the real-time audio thread.
</ins><span class="cx"> // If we fail to acquire the lock then the HTMLMediaElement must be in the middle of
</span><span class="cx"> // reconfiguring its playback engine, so we output silence in this case.
</span><del>- MutexTryLocker tryLocker(m_processLock);
- if (tryLocker.locked()) {
- if (AudioSourceProvider* provider = mediaElement()->audioSourceProvider()) {
- if (m_multiChannelResampler.get()) {
- ASSERT(m_sourceSampleRate != sampleRate());
- m_multiChannelResampler->process(provider, outputBus, numberOfFrames);
- } else {
- // Bypass the resampler completely if the source is at the context's sample-rate.
- ASSERT(m_sourceSampleRate == sampleRate());
- provider->provideInput(outputBus, numberOfFrames);
- }
</del><ins>+ std::unique_lock<std::mutex> lock(m_processMutex, std::try_to_lock);
+ if (!lock.owns_lock()) {
+ // We failed to acquire the lock.
+ outputBus->zero();
+ return;
+ }
+
+ if (AudioSourceProvider* provider = mediaElement()->audioSourceProvider()) {
+ if (m_multiChannelResampler.get()) {
+ ASSERT(m_sourceSampleRate != sampleRate());
+ m_multiChannelResampler->process(provider, outputBus, numberOfFrames);
</ins><span class="cx"> } else {
</span><del>- // Either this port doesn't yet support HTMLMediaElement audio stream access,
- // or the stream is not yet available.
- outputBus->zero();
</del><ins>+ // Bypass the resampler completely if the source is at the context's sample-rate.
+ ASSERT(m_sourceSampleRate == sampleRate());
+ provider->provideInput(outputBus, numberOfFrames);
</ins><span class="cx"> }
</span><span class="cx"> } else {
</span><del>- // We failed to acquire the lock.
</del><ins>+ // Either this port doesn't yet support HTMLMediaElement audio stream access,
+ // or the stream is not yet available.
</ins><span class="cx"> outputBus->zero();
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -141,12 +142,12 @@
</span><span class="cx"> void MediaElementAudioSourceNode::lock()
</span><span class="cx"> {
</span><span class="cx"> ref();
</span><del>- m_processLock.lock();
</del><ins>+ m_processMutex.lock();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void MediaElementAudioSourceNode::unlock()
</span><span class="cx"> {
</span><del>- m_processLock.unlock();
</del><ins>+ m_processMutex.unlock();
</ins><span class="cx"> deref();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioMediaElementAudioSourceNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.h (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.h        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.h        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -31,9 +31,9 @@
</span><span class="cx"> #include "AudioSourceProviderClient.h"
</span><span class="cx"> #include "HTMLMediaElement.h"
</span><span class="cx"> #include "MultiChannelResampler.h"
</span><ins>+#include <mutex>
</ins><span class="cx"> #include <wtf/OwnPtr.h>
</span><span class="cx"> #include <wtf/PassRefPtr.h>
</span><del>-#include <wtf/Threading.h>
</del><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx"> virtual bool propagatesSilence() const override { return false; }
</span><span class="cx">
</span><span class="cx"> RefPtr<HTMLMediaElement> m_mediaElement;
</span><del>- Mutex m_processLock;
</del><ins>+ std::mutex m_processMutex;
</ins><span class="cx">
</span><span class="cx"> unsigned m_sourceNumberOfChannels;
</span><span class="cx"> double m_sourceSampleRate;
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioMediaStreamAudioSourceNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.cpp        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // Synchronize with process().
</span><del>- MutexLocker locker(m_processLock);
</del><ins>+ std::lock_guard<std::mutex> lock(m_processMutex);
</ins><span class="cx">
</span><span class="cx"> m_sourceNumberOfChannels = numberOfChannels;
</span><span class="cx">
</span><span class="lines">@@ -100,16 +100,17 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // Use a tryLock() to avoid contention in the real-time audio thread.
</del><ins>+ // Use std::try_to_lock to avoid contention in the real-time audio thread.
</ins><span class="cx"> // If we fail to acquire the lock then the MediaStream must be in the middle of
</span><span class="cx"> // a format change, so we output silence in this case.
</span><del>- MutexTryLocker tryLocker(m_processLock);
- if (tryLocker.locked())
- audioSourceProvider()->provideInput(outputBus, numberOfFrames);
- else {
</del><ins>+ std::unique_lock<std::mutex> lock(m_processMutex, std::try_to_lock);
+ if (!lock.owns_lock()) {
</ins><span class="cx"> // We failed to acquire the lock.
</span><span class="cx"> outputBus->zero();
</span><ins>+ return;
</ins><span class="cx"> }
</span><ins>+
+ audioSourceProvider()->provideInput(outputBus, numberOfFrames);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void MediaStreamAudioSourceNode::reset()
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioMediaStreamAudioSourceNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.h (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.h        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceNode.h        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -31,9 +31,9 @@
</span><span class="cx"> #include "AudioSourceProvider.h"
</span><span class="cx"> #include "AudioSourceProviderClient.h"
</span><span class="cx"> #include "MediaStream.h"
</span><ins>+#include <mutex>
</ins><span class="cx"> #include <wtf/OwnPtr.h>
</span><span class="cx"> #include <wtf/PassRefPtr.h>
</span><del>-#include <wtf/Threading.h>
</del><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx"> RefPtr<MediaStreamTrack> m_audioTrack;
</span><span class="cx"> AudioSourceProvider* m_audioSourceProvider;
</span><span class="cx">
</span><del>- Mutex m_processLock;
</del><ins>+ std::mutex m_processMutex;
</ins><span class="cx">
</span><span class="cx"> unsigned m_sourceNumberOfChannels;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioOscillatorNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/OscillatorNode.cpp (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/OscillatorNode.cpp        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/OscillatorNode.cpp        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -230,10 +230,10 @@
</span><span class="cx"> if (framesToProcess > m_phaseIncrements.size())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- // The audio thread can't block on this lock, so we call tryLock() instead.
- MutexTryLocker tryLocker(m_processLock);
- if (!tryLocker.locked()) {
- // Too bad - the tryLock() failed. We must be in the middle of changing wave-tables.
</del><ins>+ // The audio thread can't block on this lock, so we use std::try_to_lock instead.
+ std::unique_lock<std::mutex> lock(m_processMutex, std::try_to_lock);
+ if (!lock.owns_lock()) {
+ // Too bad - the try_lock() failed. We must be in the middle of changing wave-tables.
</ins><span class="cx"> outputBus->zero();
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="lines">@@ -340,7 +340,7 @@
</span><span class="cx"> ASSERT(isMainThread());
</span><span class="cx">
</span><span class="cx"> // This synchronizes with process().
</span><del>- MutexLocker processLocker(m_processLock);
</del><ins>+ std::lock_guard<std::mutex> lock(m_processMutex);
</ins><span class="cx"> m_periodicWave = periodicWave;
</span><span class="cx"> m_type = CUSTOM;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioOscillatorNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/OscillatorNode.h (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/OscillatorNode.h        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/OscillatorNode.h        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -28,9 +28,9 @@
</span><span class="cx"> #include "AudioBus.h"
</span><span class="cx"> #include "AudioParam.h"
</span><span class="cx"> #include "AudioScheduledSourceNode.h"
</span><ins>+#include <mutex>
</ins><span class="cx"> #include <wtf/PassRefPtr.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><del>-#include <wtf/Threading.h>
</del><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx"> double m_virtualReadIndex;
</span><span class="cx">
</span><span class="cx"> // This synchronizes process().
</span><del>- mutable Mutex m_processLock;
</del><ins>+ mutable std::mutex m_processMutex;
</ins><span class="cx">
</span><span class="cx"> // Stores sample-accurate values calculated according to frequency and detune.
</span><span class="cx"> AudioFloatArray m_phaseIncrements;
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioPannerNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/PannerNode.cpp        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -107,28 +107,29 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // 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);
</del><ins>+ // The audio thread can't block on this lock, so we use std::try_to_lock instead.
+ std::unique_lock<std::mutex> lock(m_pannerMutex, std::try_to_lock);
+ if (!lock.owns_lock()) {
+ // Too bad - The try_lock() failed. We must be in the middle of changing the panner.
+ destination->zero();
+ return;
+ }
</ins><span class="cx">
</span><del>- // Get the distance and cone gain.
- double totalGain = distanceConeGain();
</del><ins>+ // Apply the panning effect.
+ double azimuth;
+ double elevation;
+ getAzimuthElevation(&azimuth, &elevation);
+ m_panner->pan(azimuth, elevation, source, destination, framesToProcess);
</ins><span class="cx">
</span><del>- // 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);
- } else {
- // Too bad - The tryLock() failed. We must be in the middle of changing the panner.
- destination->zero();
- }
</del><ins>+ // Get the distance and cone gain.
+ double totalGain = distanceConeGain();
+
+ // 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);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PannerNode::reset()
</span><span class="lines">@@ -196,8 +197,8 @@
</span><span class="cx"> case HRTF:
</span><span class="cx"> if (!m_panner.get() || model != m_panningModel) {
</span><span class="cx"> // This synchronizes with process().
</span><del>- MutexLocker processLocker(m_pannerLock);
-
</del><ins>+ std::lock_guard<std::mutex> lock(m_pannerMutex);
+
</ins><span class="cx"> OwnPtr<Panner> newPanner = Panner::create(model, sampleRate(), context()->hrtfDatabaseLoader());
</span><span class="cx"> m_panner = newPanner.release();
</span><span class="cx"> m_panningModel = model;
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioPannerNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/PannerNode.h (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/PannerNode.h        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/PannerNode.h        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include "Distance.h"
</span><span class="cx"> #include "FloatPoint3D.h"
</span><span class="cx"> #include "Panner.h"
</span><ins>+#include <mutex>
</ins><span class="cx"> #include <wtf/OwnPtr.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -156,7 +157,7 @@
</span><span class="cx"> unsigned m_connectionCount;
</span><span class="cx">
</span><span class="cx"> // Synchronize process() and setPanningModel() which can change the panner.
</span><del>- mutable Mutex m_pannerLock;
</del><ins>+ mutable std::mutex m_pannerMutex;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioWaveShaperProcessorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.cpp (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.cpp        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.cpp        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -52,15 +52,15 @@
</span><span class="cx"> void WaveShaperProcessor::setCurve(Float32Array* curve)
</span><span class="cx"> {
</span><span class="cx"> // This synchronizes with process().
</span><del>- MutexLocker processLocker(m_processLock);
-
</del><ins>+ std::lock_guard<std::mutex> lock(m_processMutex);
+
</ins><span class="cx"> m_curve = curve;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WaveShaperProcessor::setOversample(OverSampleType oversample)
</span><span class="cx"> {
</span><span class="cx"> // This synchronizes with process().
</span><del>- MutexLocker processLocker(m_processLock);
</del><ins>+ std::lock_guard<std::mutex> lock(m_processMutex);
</ins><span class="cx">
</span><span class="cx"> m_oversample = oversample;
</span><span class="cx">
</span><span class="lines">@@ -84,16 +84,17 @@
</span><span class="cx"> if (!channelCountMatches)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- // The audio thread can't block on this lock, so we call tryLock() instead.
- MutexTryLocker tryLocker(m_processLock);
- if (tryLocker.locked()) {
- // For each channel of our input, process using the corresponding WaveShaperDSPKernel into the output channel.
- for (unsigned i = 0; i < m_kernels.size(); ++i)
- m_kernels[i]->process(source->channel(i)->data(), destination->channel(i)->mutableData(), framesToProcess);
- } else {
- // Too bad - the tryLock() failed. We must be in the middle of a setCurve() call.
</del><ins>+ // The audio thread can't block on this lock, so we use std::try_to_lock instead.
+ std::unique_lock<std::mutex> lock(m_processMutex, std::try_to_lock);
+ if (!lock.owns_lock()) {
+ // Too bad - the try_lock() failed. We must be in the middle of a setCurve() call.
</ins><span class="cx"> destination->zero();
</span><ins>+ return;
</ins><span class="cx"> }
</span><ins>+
+ // For each channel of our input, process using the corresponding WaveShaperDSPKernel into the output channel.
+ for (unsigned i = 0; i < m_kernels.size(); ++i)
+ m_kernels[i]->process(source->channel(i)->data(), destination->channel(i)->mutableData(), framesToProcess);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioWaveShaperProcessorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.h (162295 => 162296)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.h        2014-01-19 19:13:10 UTC (rev 162295)
+++ trunk/Source/WebCore/Modules/webaudio/WaveShaperProcessor.h        2014-01-19 20:37:53 UTC (rev 162296)
</span><span class="lines">@@ -28,9 +28,9 @@
</span><span class="cx"> #include "AudioDSPKernel.h"
</span><span class="cx"> #include "AudioDSPKernelProcessor.h"
</span><span class="cx"> #include "AudioNode.h"
</span><ins>+#include <mutex>
</ins><span class="cx"> #include <runtime/Float32Array.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><del>-#include <wtf/Threading.h>
</del><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx"> OverSampleType m_oversample;
</span><span class="cx">
</span><span class="cx"> // This synchronizes process() with setCurve().
</span><del>- mutable Mutex m_processLock;
</del><ins>+ mutable std::mutex m_processMutex;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre>
</div>
</div>
</body>
</html>