| Index: media/audio/audio_manager.cc
|
| diff --git a/media/audio/audio_manager.cc b/media/audio/audio_manager.cc
|
| index 2bbffa7eb6a33866c2e2089fa8be28453acccad6..8f57131bc776eb694c7f7e73ddfa6dc5abcbfca9 100644
|
| --- a/media/audio/audio_manager.cc
|
| +++ b/media/audio/audio_manager.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| +#include "base/command_line.h"
|
| #include "base/debug/alias.h"
|
| #include "base/lazy_instance.h"
|
| #include "base/logging.h"
|
| @@ -14,6 +15,7 @@
|
| #include "base/synchronization/waitable_event.h"
|
| #include "build/build_config.h"
|
| #include "media/audio/fake_audio_log_factory.h"
|
| +#include "media/base/media_switches.h"
|
|
|
| namespace media {
|
| namespace {
|
| @@ -122,6 +124,8 @@ class AudioManagerHelper : public base::PowerObserver {
|
| DISALLOW_COPY_AND_ASSIGN(AudioManagerHelper);
|
| };
|
|
|
| +static bool g_hang_monitor_enabled = false;
|
| +
|
| static base::LazyInstance<AudioManagerHelper>::Leaky g_helper =
|
| LAZY_INSTANCE_INITIALIZER;
|
| }
|
| @@ -148,11 +152,11 @@ AudioManager* AudioManager::CreateWithHangTimer(
|
| AudioLogFactory* audio_log_factory,
|
| const scoped_refptr<base::SingleThreadTaskRunner>& monitor_task_runner) {
|
| AudioManager* manager = Create(audio_log_factory);
|
| - // On OSX the audio thread is the UI thread, for which a hang monitor is not
|
| - // necessary.
|
| -#if !defined(OS_MACOSX)
|
| - g_helper.Pointer()->StartHangTimer(monitor_task_runner);
|
| -#endif
|
| + if (g_hang_monitor_enabled ||
|
| + base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableAudioHangMonitor)) {
|
| + g_helper.Pointer()->StartHangTimer(monitor_task_runner);
|
| + }
|
| return manager;
|
| }
|
|
|
| @@ -174,6 +178,17 @@ AudioManager* AudioManager::CreateForTesting() {
|
| }
|
|
|
| // static
|
| +void AudioManager::EnableHangMonitor() {
|
| + CHECK(!g_last_created);
|
| +// On OSX the audio thread is the UI thread, for which a hang monitor is not
|
| +// necessary or recommended. If it's manually requested, we should allow it
|
| +// to start though.
|
| +#if !defined(OS_MACOSX)
|
| + g_hang_monitor_enabled = true;
|
| +#endif
|
| +}
|
| +
|
| +// static
|
| AudioManager* AudioManager::Get() {
|
| return g_last_created;
|
| }
|
|
|