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

Side by Side Diff: media/audio/audio_manager.cc

Issue 1105083004: Switch audio hang monitor to default-off. Enable for non-beta,stable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « media/audio/audio_manager.h ('k') | media/base/media_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/audio_manager.h" 5 #include "media/audio/audio_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h"
9 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
10 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
13 #include "base/power_monitor/power_monitor.h" 14 #include "base/power_monitor/power_monitor.h"
14 #include "build/build_config.h" 15 #include "build/build_config.h"
15 #include "media/audio/audio_manager_factory.h" 16 #include "media/audio/audio_manager_factory.h"
16 #include "media/audio/fake_audio_log_factory.h" 17 #include "media/audio/fake_audio_log_factory.h"
18 #include "media/base/media_switches.h"
17 19
18 namespace media { 20 namespace media {
19 namespace { 21 namespace {
20 22
21 // The singleton instance of AudioManager. This is set when Create() is called. 23 // The singleton instance of AudioManager. This is set when Create() is called.
22 AudioManager* g_last_created = NULL; 24 AudioManager* g_last_created = NULL;
23 25
24 // The singleton instance of AudioManagerFactory. This is only set if 26 // The singleton instance of AudioManagerFactory. This is only set if
25 // SetFactory() is called. If it is set when Create() is called, its 27 // SetFactory() is called. If it is set when Create() is called, its
26 // CreateInstance() function is used to set |g_last_created|. Otherwise, the 28 // CreateInstance() function is used to set |g_last_created|. Otherwise, the
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 scoped_refptr<base::SingleThreadTaskRunner> monitor_task_runner_; 126 scoped_refptr<base::SingleThreadTaskRunner> monitor_task_runner_;
125 127
126 base::Lock hang_lock_; 128 base::Lock hang_lock_;
127 bool hang_detection_enabled_; 129 bool hang_detection_enabled_;
128 base::TimeTicks last_audio_thread_timer_tick_; 130 base::TimeTicks last_audio_thread_timer_tick_;
129 int hang_failures_; 131 int hang_failures_;
130 132
131 DISALLOW_COPY_AND_ASSIGN(AudioManagerHelper); 133 DISALLOW_COPY_AND_ASSIGN(AudioManagerHelper);
132 }; 134 };
133 135
136 static bool g_hang_monitor_enabled = false;
137
134 static base::LazyInstance<AudioManagerHelper>::Leaky g_helper = 138 static base::LazyInstance<AudioManagerHelper>::Leaky g_helper =
135 LAZY_INSTANCE_INITIALIZER; 139 LAZY_INSTANCE_INITIALIZER;
136 } // namespace 140 } // namespace
137 141
138 // Forward declaration of the platform specific AudioManager factory function. 142 // Forward declaration of the platform specific AudioManager factory function.
139 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory); 143 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory);
140 144
141 AudioManager::AudioManager() {} 145 AudioManager::AudioManager() {}
142 146
143 AudioManager::~AudioManager() { 147 AudioManager::~AudioManager() {
(...skipping 26 matching lines...) Expand all
170 g_last_created = CreateAudioManager(audio_log_factory); 174 g_last_created = CreateAudioManager(audio_log_factory);
171 175
172 return g_last_created; 176 return g_last_created;
173 } 177 }
174 178
175 // static 179 // static
176 AudioManager* AudioManager::CreateWithHangTimer( 180 AudioManager* AudioManager::CreateWithHangTimer(
177 AudioLogFactory* audio_log_factory, 181 AudioLogFactory* audio_log_factory,
178 const scoped_refptr<base::SingleThreadTaskRunner>& monitor_task_runner) { 182 const scoped_refptr<base::SingleThreadTaskRunner>& monitor_task_runner) {
179 AudioManager* manager = Create(audio_log_factory); 183 AudioManager* manager = Create(audio_log_factory);
180 // On OSX the audio thread is the UI thread, for which a hang monitor is not 184 if (g_hang_monitor_enabled ||
181 // necessary. 185 base::CommandLine::ForCurrentProcess()->HasSwitch(
182 #if !defined(OS_MACOSX) 186 switches::kEnableAudioHangMonitor)) {
183 g_helper.Pointer()->StartHangTimer(monitor_task_runner); 187 g_helper.Pointer()->StartHangTimer(monitor_task_runner);
184 #endif 188 }
185 return manager; 189 return manager;
186 } 190 }
187 191
188 // static 192 // static
189 AudioManager* AudioManager::CreateForTesting() { 193 AudioManager* AudioManager::CreateForTesting() {
190 return Create(g_helper.Pointer()->fake_log_factory()); 194 return Create(g_helper.Pointer()->fake_log_factory());
191 } 195 }
192 196
193 // static 197 // static
198 void AudioManager::EnableHangMonitor() {
199 CHECK(!g_last_created);
200 // On OSX the audio thread is the UI thread, for which a hang monitor is not
201 // necessary or recommended. If it's manually requested, we should allow it
202 // to start though.
203 #if !defined(OS_MACOSX)
204 g_hang_monitor_enabled = true;
205 #endif
206 }
207
208 // static
194 AudioManager* AudioManager::Get() { 209 AudioManager* AudioManager::Get() {
195 return g_last_created; 210 return g_last_created;
196 } 211 }
197 212
198 } // namespace media 213 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_manager.h ('k') | media/base/media_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698