Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp

Issue 2929283002: Avoid AudioBufferSourceHandler data race. (Closed)
Patch Set: rename accessor Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp b/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp
index 569440ff33b49d2101d2b482dd801f090bc7ce86..bc0666fe43dedb357b2bff8dfec9a4491c7cfe8b 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.cpp
@@ -590,12 +590,21 @@ double AudioBufferSourceHandler::ComputePlaybackRate() {
if (!is_playback_rate_valid)
final_playback_rate = 1.0;
- // Record the minimum playback rate for use by handleStoppableSourceNode.
- min_playback_rate_ = std::min(final_playback_rate, min_playback_rate_);
+ // Record the minimum playback rate for use by HandleStoppableSourceNode.
+ if (final_playback_rate < min_playback_rate_) {
+ MutexLocker locker(min_playback_rate_mutex_);
+ min_playback_rate_ = final_playback_rate;
+ }
return final_playback_rate;
}
+double AudioBufferSourceHandler::GetMinPlaybackRate() {
+ DCHECK(IsMainThread());
+ MutexLocker locker(min_playback_rate_mutex_);
+ return min_playback_rate_;
+}
+
bool AudioBufferSourceHandler::PropagatesSilence() const {
return !IsPlayingOrScheduled() || HasFinished() || !buffer_;
}
@@ -611,12 +620,13 @@ void AudioBufferSourceHandler::HandleStoppableSourceNode() {
// If looping was ever done (m_didSetLooping = true), give up. We can't
// easily determine how long we looped so we don't know the actual duration
// thus far, so don't try to do anything fancy.
+ double min_playback_rate = GetMinPlaybackRate();
if (!DidSetLooping() && Buffer() && IsPlayingOrScheduled() &&
- min_playback_rate_ > 0) {
+ min_playback_rate > 0) {
// Adjust the duration to include the playback rate. Only need to account
// for rate < 1 which makes the sound last longer. For rate >= 1, the
// source stops sooner, but that's ok.
- double actual_duration = Buffer()->duration() / min_playback_rate_;
+ double actual_duration = Buffer()->duration() / min_playback_rate;
double stop_time = start_time_ + actual_duration;
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioBufferSourceNode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698