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 "media/audio/linux/audio_manager_linux.h" | 5 #include "media/audio/linux/audio_manager_linux.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" |
10 #include "base/nix/xdg_util.h" | 11 #include "base/nix/xdg_util.h" |
11 #include "base/process_util.h" | 12 #include "base/process_util.h" |
12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
13 #include "media/audio/audio_output_dispatcher.h" | 14 #include "media/audio/audio_output_dispatcher.h" |
14 #include "media/audio/audio_parameters.h" | 15 #include "media/audio/audio_parameters.h" |
15 #include "media/audio/audio_util.h" | 16 #include "media/audio/audio_util.h" |
16 #if defined(USE_CRAS) | 17 #if defined(USE_CRAS) |
17 #include "media/audio/cras/audio_manager_cras.h" | 18 #include "media/audio/cras/audio_manager_cras.h" |
18 #endif | 19 #endif |
19 #include "media/audio/linux/alsa_input.h" | 20 #include "media/audio/linux/alsa_input.h" |
20 #include "media/audio/linux/alsa_output.h" | 21 #include "media/audio/linux/alsa_output.h" |
21 #include "media/audio/linux/alsa_wrapper.h" | 22 #include "media/audio/linux/alsa_wrapper.h" |
22 #if defined(USE_PULSEAUDIO) | |
23 #include "media/audio/pulse/audio_manager_pulse.h" | 23 #include "media/audio/pulse/audio_manager_pulse.h" |
24 #endif | |
25 #include "media/base/channel_layout.h" | 24 #include "media/base/channel_layout.h" |
26 #include "media/base/limits.h" | 25 #include "media/base/limits.h" |
27 #include "media/base/media_switches.h" | 26 #include "media/base/media_switches.h" |
28 | 27 |
29 namespace media { | 28 namespace media { |
30 | 29 |
31 // Maximum number of output streams that can be open simultaneously. | 30 // Maximum number of output streams that can be open simultaneously. |
32 static const int kMaxOutputStreams = 50; | 31 static const int kMaxOutputStreams = 50; |
33 | 32 |
34 // Default sample rate for input and output streams. | 33 // Default sample rate for input and output streams. |
35 static const int kDefaultSampleRate = 48000; | 34 static const int kDefaultSampleRate = 48000; |
36 | 35 |
37 // Since "default", "pulse" and "dmix" devices are virtual devices mapped to | 36 // Since "default", "pulse" and "dmix" devices are virtual devices mapped to |
38 // real devices, we remove them from the list to avoiding duplicate counting. | 37 // real devices, we remove them from the list to avoiding duplicate counting. |
39 // In addition, note that we support no more than 2 channels for recording, | 38 // In addition, note that we support no more than 2 channels for recording, |
40 // hence surround devices are not stored in the list. | 39 // hence surround devices are not stored in the list. |
41 static const char* kInvalidAudioInputDevices[] = { | 40 static const char* kInvalidAudioInputDevices[] = { |
42 "default", | 41 "default", |
43 "null", | 42 "null", |
44 "pulse", | 43 "pulse", |
45 "dmix", | 44 "dmix", |
46 "surround", | 45 "surround", |
47 }; | 46 }; |
48 | 47 |
| 48 enum LinuxAudioIO { |
| 49 kPulse, |
| 50 kAlsa, |
| 51 kCras, |
| 52 kAudioIOMax // Must always be last! |
| 53 }; |
| 54 |
49 // static | 55 // static |
50 void AudioManagerLinux::ShowLinuxAudioInputSettings() { | 56 void AudioManagerLinux::ShowLinuxAudioInputSettings() { |
51 scoped_ptr<base::Environment> env(base::Environment::Create()); | 57 scoped_ptr<base::Environment> env(base::Environment::Create()); |
52 CommandLine command_line(CommandLine::NO_PROGRAM); | 58 CommandLine command_line(CommandLine::NO_PROGRAM); |
53 switch (base::nix::GetDesktopEnvironment(env.get())) { | 59 switch (base::nix::GetDesktopEnvironment(env.get())) { |
54 case base::nix::DESKTOP_ENVIRONMENT_GNOME: | 60 case base::nix::DESKTOP_ENVIRONMENT_GNOME: |
55 command_line.SetProgram(base::FilePath("gnome-volume-control")); | 61 command_line.SetProgram(base::FilePath("gnome-volume-control")); |
56 break; | 62 break; |
57 case base::nix::DESKTOP_ENVIRONMENT_KDE3: | 63 case base::nix::DESKTOP_ENVIRONMENT_KDE3: |
58 case base::nix::DESKTOP_ENVIRONMENT_KDE4: | 64 case base::nix::DESKTOP_ENVIRONMENT_KDE4: |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 320 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
315 switches::kAlsaInputDevice); | 321 switches::kAlsaInputDevice); |
316 } | 322 } |
317 | 323 |
318 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); | 324 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); |
319 } | 325 } |
320 | 326 |
321 AudioManager* CreateAudioManager() { | 327 AudioManager* CreateAudioManager() { |
322 #if defined(USE_CRAS) | 328 #if defined(USE_CRAS) |
323 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseCras)) { | 329 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseCras)) { |
| 330 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kCras, kAudioIOMax); |
324 return new AudioManagerCras(); | 331 return new AudioManagerCras(); |
325 } | 332 } |
326 #endif | 333 #endif |
327 | 334 |
328 #if defined(USE_PULSEAUDIO) | 335 AudioManager* manager = AudioManagerPulse::Create(); |
329 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) { | 336 if (manager) { |
330 AudioManager* manager = AudioManagerPulse::Create(); | 337 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kPulse, kAudioIOMax); |
331 if (manager) | 338 return manager; |
332 return manager; | |
333 } | 339 } |
334 #endif | |
335 | 340 |
| 341 UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kAlsa, kAudioIOMax); |
336 return new AudioManagerLinux(); | 342 return new AudioManagerLinux(); |
337 } | 343 } |
338 | 344 |
339 } // namespace media | 345 } // namespace media |
OLD | NEW |