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

Unified Diff: media/audio/audio_power_monitor.cc

Issue 611373003: Add a mutex lock to AudioPowerMonitor::Reset() to placate TSAN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify variable read/write safety in Reset() method. Created 6 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_power_monitor.cc
diff --git a/media/audio/audio_power_monitor.cc b/media/audio/audio_power_monitor.cc
index 6536f464b9c16905e7d4080a907b5a4df5678acf..b0b17971b4fa63d8e34700bfec75ab13c5d6a21a 100644
--- a/media/audio/audio_power_monitor.cc
+++ b/media/audio/audio_power_monitor.cc
@@ -26,8 +26,17 @@ AudioPowerMonitor::~AudioPowerMonitor() {
}
void AudioPowerMonitor::Reset() {
- power_reading_ = average_power_ = 0.0f;
- clipped_reading_ = has_clipped_ = false;
+ // These are only read/written by Scan(), but Scan() should not be running
+ // when Reset() is called.
+ average_power_ = 0.0f;
+ has_clipped_ = false;
+
+ // These are the copies read by ReadCurrentPowerAndClip(). The lock here is
+ // not necessary, as racey writes/reads are acceptable, but this prevents
+ // quality-enhancement tools like TSAN from complaining.
+ base::AutoLock for_reset(reading_lock_);
+ power_reading_ = 0.0f;
+ clipped_reading_ = false;
}
void AudioPowerMonitor::Scan(const AudioBus& buffer, int num_frames) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698