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/nix/xdg_util.h" | 10 #include "base/nix/xdg_util.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 return HasAnyAlsaAudioDevice(kStreamPlayback); | 43 return HasAnyAlsaAudioDevice(kStreamPlayback); |
44 } | 44 } |
45 | 45 |
46 bool AudioManagerLinux::HasAudioInputDevices() { | 46 bool AudioManagerLinux::HasAudioInputDevices() { |
47 return HasAnyAlsaAudioDevice(kStreamCapture); | 47 return HasAnyAlsaAudioDevice(kStreamCapture); |
48 } | 48 } |
49 | 49 |
50 AudioOutputStream* AudioManagerLinux::MakeAudioOutputStream( | 50 AudioOutputStream* AudioManagerLinux::MakeAudioOutputStream( |
51 const AudioParameters& params) { | 51 const AudioParameters& params) { |
52 // Early return for testing hook. | 52 // Early return for testing hook. |
53 if (params.format == AudioParameters::AUDIO_MOCK) | 53 if (params.format() == AudioParameters::AUDIO_MOCK) |
54 return FakeAudioOutputStream::MakeFakeStream(params); | 54 return FakeAudioOutputStream::MakeFakeStream(params); |
55 | 55 |
56 // Don't allow opening more than |kMaxOutputStreams| streams. | 56 // Don't allow opening more than |kMaxOutputStreams| streams. |
57 if (active_output_stream_count_ >= kMaxOutputStreams) | 57 if (active_output_stream_count_ >= kMaxOutputStreams) |
58 return NULL; | 58 return NULL; |
59 | 59 |
60 AudioOutputStream* stream = NULL; | 60 AudioOutputStream* stream = NULL; |
61 #if defined(USE_PULSEAUDIO) | 61 #if defined(USE_PULSEAUDIO) |
62 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) { | 62 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) { |
63 stream = new PulseAudioOutputStream(params, this); | 63 stream = new PulseAudioOutputStream(params, this); |
64 } else { | 64 } else { |
65 #endif | 65 #endif |
66 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice; | 66 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice; |
67 if (CommandLine::ForCurrentProcess()->HasSwitch( | 67 if (CommandLine::ForCurrentProcess()->HasSwitch( |
68 switches::kAlsaOutputDevice)) { | 68 switches::kAlsaOutputDevice)) { |
69 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 69 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
70 switches::kAlsaOutputDevice); | 70 switches::kAlsaOutputDevice); |
71 } | 71 } |
72 stream = new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this); | 72 stream = new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this); |
73 #if defined(USE_PULSEAUDIO) | 73 #if defined(USE_PULSEAUDIO) |
74 } | 74 } |
75 #endif | 75 #endif |
76 ++active_output_stream_count_; | 76 ++active_output_stream_count_; |
77 DCHECK(stream); | 77 DCHECK(stream); |
78 return stream; | 78 return stream; |
79 } | 79 } |
80 | 80 |
81 AudioInputStream* AudioManagerLinux::MakeAudioInputStream( | 81 AudioInputStream* AudioManagerLinux::MakeAudioInputStream( |
82 const AudioParameters& params, const std::string& device_id) { | 82 const AudioParameters& params, const std::string& device_id) { |
83 if (!params.IsValid() || params.channels > kMaxInputChannels || | 83 if (!params.IsValid() || params.channels() > kMaxInputChannels || |
84 device_id.empty()) { | 84 device_id.empty()) { |
85 return NULL; | 85 return NULL; |
86 } | 86 } |
87 | 87 |
88 if (params.format == AudioParameters::AUDIO_MOCK) { | 88 if (params.format() == AudioParameters::AUDIO_MOCK) { |
89 return FakeAudioInputStream::MakeFakeStream(params); | 89 return FakeAudioInputStream::MakeFakeStream(params); |
90 } | 90 } |
91 | 91 |
92 std::string device_name = (device_id == AudioManagerBase::kDefaultDeviceId) ? | 92 std::string device_name = (device_id == AudioManagerBase::kDefaultDeviceId) ? |
93 AlsaPcmInputStream::kAutoSelectDevice : device_id; | 93 AlsaPcmInputStream::kAutoSelectDevice : device_id; |
94 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAlsaInputDevice)) { | 94 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAlsaInputDevice)) { |
95 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 95 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
96 switches::kAlsaInputDevice); | 96 switches::kAlsaInputDevice); |
97 } | 97 } |
98 | 98 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 << wrapper_->StrError(error); | 299 << wrapper_->StrError(error); |
300 } | 300 } |
301 } | 301 } |
302 | 302 |
303 return has_device; | 303 return has_device; |
304 } | 304 } |
305 | 305 |
306 AudioManager* CreateAudioManager() { | 306 AudioManager* CreateAudioManager() { |
307 return new AudioManagerLinux(); | 307 return new AudioManagerLinux(); |
308 } | 308 } |
OLD | NEW |