summaryrefslogtreecommitdiffstats
path: root/media/audio
diff options
context:
space:
mode:
authorbajones@chromium.org <bajones@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-05 17:28:39 +0000
committerbajones@chromium.org <bajones@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-05 17:28:39 +0000
commitf65e97e447b789af3a8dc653d8801e8c6f24f935 (patch)
tree40a67136a65931462cbf1a39fc03844b43117d11 /media/audio
parentfb4341cd131ff6143ac8cf579d0eee4eb0c6bf3e (diff)
downloadchromium_src-f65e97e447b789af3a8dc653d8801e8c6f24f935.zip
chromium_src-f65e97e447b789af3a8dc653d8801e8c6f24f935.tar.gz
chromium_src-f65e97e447b789af3a8dc653d8801e8c6f24f935.tar.bz2
Attempting to resolve a race condition with PowerMonitor.
ThreadSanitizer caught multiple instances where PowerMonitor::Get or PowerMonitor::Add/RemoveObserver were being called concurrently with the PowerMonitor constructor in the main thread. These functions access a process-global PowerMontior instance (g_power_monitor), which was not thread safe. This change adds locks around PowerMonitor creation and deletion, and forces Add/RemoveObserver to be called in a threadsafe manner. It also removes the need to call PowerMonitor::Get. BUG=268924 Review URL: https://codereview.chromium.org/179923006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262018 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio')
-rw-r--r--media/audio/mac/audio_manager_mac.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc
index 60c8a3e..b9376447 100644
--- a/media/audio/mac/audio_manager_mac.cc
+++ b/media/audio/mac/audio_manager_mac.cc
@@ -226,20 +226,20 @@ class AudioManagerMac::AudioPowerObserver : public base::PowerObserver {
public:
AudioPowerObserver()
: is_suspending_(false),
- is_monitoring_(base::PowerMonitor::Get()) {
+ is_monitoring_(base::PowerMonitor::IsInitialized()) {
// The PowerMonitor requires signifcant setup (a CFRunLoop and preallocated
// IO ports) so it's not available under unit tests. See the OSX impl of
// base::PowerMonitorDeviceSource for more details.
if (!is_monitoring_)
return;
- base::PowerMonitor::Get()->AddObserver(this);
+ base::PowerMonitor::AddObserver(this);
}
virtual ~AudioPowerObserver() {
DCHECK(thread_checker_.CalledOnValidThread());
if (!is_monitoring_)
return;
- base::PowerMonitor::Get()->RemoveObserver(this);
+ base::PowerMonitor::RemoveObserver(this);
}
bool ShouldDeferOutputStreamStart() {