Improve Mojo permission service and chrome::PermissionManager observing.
[chromium-blink-merge.git] / media / audio / linux / audio_manager_linux.cc
blob0e7c9810a5c29e3b9a4e6e9c60e89163e60f850a
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/metrics/histogram.h"
7 #if defined(USE_ALSA)
8 #include "media/audio/alsa/audio_manager_alsa.h"
9 #else
10 #include "media/audio/fake_audio_manager.h"
11 #endif
12 #if defined(USE_CRAS)
13 #include "media/audio/cras/audio_manager_cras.h"
14 #endif
15 #if defined(USE_PULSEAUDIO)
16 #include "media/audio/pulse/audio_manager_pulse.h"
17 #endif
18 #include "media/base/media_switches.h"
20 namespace media {
22 enum LinuxAudioIO {
23 kPulse,
24 kAlsa,
25 kCras,
26 kAudioIOMax = kCras // Must always be equal to largest logged entry.
29 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) {
30 #if defined(USE_CRAS)
31 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseCras)) {
32 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kCras, kAudioIOMax + 1);
33 return new AudioManagerCras(audio_log_factory);
35 #endif
37 #if defined(USE_PULSEAUDIO)
38 AudioManager* manager = AudioManagerPulse::Create(audio_log_factory);
39 if (manager) {
40 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kPulse, kAudioIOMax + 1);
41 return manager;
43 #endif
45 #if defined(USE_ALSA)
46 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kAlsa, kAudioIOMax + 1);
47 return new AudioManagerAlsa(audio_log_factory);
48 #else
49 return new FakeAudioManager(audio_log_factory);
50 #endif
53 } // namespace media