Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/metrics/histogram.h" | 6 #include "base/metrics/histogram.h" |
| 7 #include "media/audio/audio_thread.h" | |
| 8 #include "media/base/media_switches.h" | |
| 9 | |
| 7 #if defined(USE_ALSA) | 10 #if defined(USE_ALSA) |
| 8 #include "media/audio/alsa/audio_manager_alsa.h" | 11 #include "media/audio/alsa/audio_manager_alsa.h" |
| 9 #else | 12 #else |
| 10 #include "media/audio/fake_audio_manager.h" | 13 #include "media/audio/fake_audio_manager.h" |
| 11 #endif | 14 #endif |
| 12 #if defined(USE_CRAS) | 15 #if defined(USE_CRAS) |
| 13 #include "media/audio/cras/audio_manager_cras.h" | 16 #include "media/audio/cras/audio_manager_cras.h" |
| 14 #endif | 17 #endif |
| 15 #if defined(USE_PULSEAUDIO) | 18 #if defined(USE_PULSEAUDIO) |
| 16 #include "media/audio/pulse/audio_manager_pulse.h" | 19 #include "media/audio/pulse/audio_manager_pulse.h" |
| 17 #endif | 20 #endif |
| 18 #include "media/base/media_switches.h" | |
| 19 | 21 |
| 20 namespace media { | 22 namespace media { |
| 21 | 23 |
| 22 enum LinuxAudioIO { | 24 enum LinuxAudioIO { |
| 23 kPulse, | 25 kPulse, |
| 24 kAlsa, | 26 kAlsa, |
| 25 kCras, | 27 kCras, |
| 26 kAudioIOMax = kCras // Must always be equal to largest logged entry. | 28 kAudioIOMax = kCras // Must always be equal to largest logged entry. |
| 27 }; | 29 }; |
| 28 | 30 |
| 29 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { | 31 AudioManager* CreateAudioManager( |
|
DaleCurtis
2016/03/18 17:48:19
It'd be nice if the default Create() function hand
alokp
2016/03/18 18:40:07
I did not not do that because I wanted to use a di
| |
| 32 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | |
| 33 const scoped_refptr<base::SingleThreadTaskRunner>& worker_task_runner, | |
| 34 AudioLogFactory* audio_log_factory) { | |
| 35 scoped_refptr<base::SingleThreadTaskRunner> audio_runner = | |
| 36 task_runner ? task_runner : AudioThread::Get()->task_runner(); | |
| 37 scoped_refptr<base::SingleThreadTaskRunner> worker_runner = | |
| 38 worker_task_runner ? worker_task_runner | |
| 39 : AudioThread::Get()->task_runner(); | |
| 40 | |
| 30 #if defined(USE_CRAS) | 41 #if defined(USE_CRAS) |
| 31 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseCras)) { | 42 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseCras)) { |
| 32 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kCras, kAudioIOMax + 1); | 43 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kCras, kAudioIOMax + 1); |
| 33 return new AudioManagerCras(audio_log_factory); | 44 return new AudioManagerCras(audio_runner, worker_runner, audio_log_factory); |
| 34 } | 45 } |
| 35 #endif | 46 #endif |
| 36 | 47 |
| 37 #if defined(USE_PULSEAUDIO) | 48 #if defined(USE_PULSEAUDIO) |
| 38 AudioManager* manager = AudioManagerPulse::Create(audio_log_factory); | 49 scoped_ptr<AudioManagerPulse> manager( |
| 39 if (manager) { | 50 new AudioManagerPulse(audio_runner, worker_runner, audio_log_factory)); |
| 51 if (manager->Init()) { | |
| 40 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kPulse, kAudioIOMax + 1); | 52 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kPulse, kAudioIOMax + 1); |
| 41 return manager; | 53 return manager.release(); |
| 54 } else { | |
| 55 DVLOG(1) << "PulseAudio is not available on the OS"; | |
| 56 AudioManager::Destroy(manager.release()); | |
| 42 } | 57 } |
| 43 #endif | 58 #endif |
| 44 | 59 |
| 45 #if defined(USE_ALSA) | 60 #if defined(USE_ALSA) |
| 46 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kAlsa, kAudioIOMax + 1); | 61 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kAlsa, kAudioIOMax + 1); |
| 47 return new AudioManagerAlsa(audio_log_factory); | 62 return new AudioManagerAlsa(audio_runner, worker_runner, audio_log_factory); |
| 48 #else | 63 #else |
| 49 return new FakeAudioManager(audio_log_factory); | 64 return new FakeAudioManager(audio_runner, worker_runner, audio_log_factory); |
| 50 #endif | 65 #endif |
| 51 } | 66 } |
| 52 | 67 |
| 53 } // namespace media | 68 } // namespace media |
| OLD | NEW |