Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "media/audio/audio_output_dispatcher.h" | 13 #include "media/audio/audio_output_dispatcher.h" |
| 14 #include "media/audio/fake_audio_input_stream.h" | 14 #include "media/audio/fake_audio_input_stream.h" |
| 15 #include "media/audio/fake_audio_output_stream.h" | 15 #include "media/audio/fake_audio_output_stream.h" |
| 16 #include "media/audio/linux/alsa_input.h" | 16 #include "media/audio/linux/alsa_input.h" |
| 17 #include "media/audio/linux/alsa_output.h" | 17 #include "media/audio/linux/alsa_output.h" |
| 18 #include "media/audio/linux/alsa_wrapper.h" | 18 #include "media/audio/linux/alsa_wrapper.h" |
| 19 #include "media/audio/linux/pulse_output.h" | |
|
Paweł Hajdan Jr.
2011/08/09 16:32:51
This header includes PA headers. audio_manager_lin
slock
2011/08/09 18:13:55
Done.
| |
| 19 #include "media/base/limits.h" | 20 #include "media/base/limits.h" |
| 20 #include "media/base/media_switches.h" | 21 #include "media/base/media_switches.h" |
| 21 | 22 |
| 22 // Maximum number of output streams that can be open simultaneously. | 23 // Maximum number of output streams that can be open simultaneously. |
| 23 static const size_t kMaxOutputStreams = 50; | 24 static const size_t kMaxOutputStreams = 50; |
| 24 | 25 |
| 25 static const int kMaxInputChannels = 2; | 26 static const int kMaxInputChannels = 2; |
| 26 | 27 |
| 27 // Since "default", "pulse" and "dmix" devices are virtual devices mapped to | 28 // Since "default", "pulse" and "dmix" devices are virtual devices mapped to |
| 28 // real devices, we remove them from the list to avoiding duplicate counting. | 29 // real devices, we remove them from the list to avoiding duplicate counting. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 93 |
| 93 if (!initialized()) { | 94 if (!initialized()) { |
| 94 return NULL; | 95 return NULL; |
| 95 } | 96 } |
| 96 | 97 |
| 97 // Don't allow opening more than |kMaxOutputStreams| streams. | 98 // Don't allow opening more than |kMaxOutputStreams| streams. |
| 98 if (active_streams_.size() >= kMaxOutputStreams) { | 99 if (active_streams_.size() >= kMaxOutputStreams) { |
| 99 return NULL; | 100 return NULL; |
| 100 } | 101 } |
| 101 | 102 |
| 102 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice; | 103 bool pulse = true; |
| 103 if (CommandLine::ForCurrentProcess()->HasSwitch( | 104 AudioOutputStream* stream; |
| 104 switches::kAlsaOutputDevice)) { | 105 if (pulse) { |
| 105 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 106 stream = new PulseAudioOutputStream(params, this); |
| 106 switches::kAlsaOutputDevice); | 107 } else { |
| 108 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice; | |
|
Paweł Hajdan Jr.
2011/08/09 16:32:51
Isn't this dead code? |pulse| is always true.
slock
2011/08/09 18:13:55
Yes it was, and it shouldn't have been there. I t
| |
| 109 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
| 110 switches::kAlsaOutputDevice)) { | |
| 111 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 112 switches::kAlsaOutputDevice); | |
| 113 } | |
| 114 stream = new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this, | |
| 115 GetMessageLoop()); | |
| 107 } | 116 } |
| 108 AlsaPcmOutputStream* stream = | |
| 109 new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this, | |
| 110 GetMessageLoop()); | |
| 111 active_streams_.insert(stream); | 117 active_streams_.insert(stream); |
| 112 return stream; | 118 return stream; |
| 113 } | 119 } |
| 114 | 120 |
| 115 AudioInputStream* AudioManagerLinux::MakeAudioInputStream( | 121 AudioInputStream* AudioManagerLinux::MakeAudioInputStream( |
| 116 const AudioParameters& params) { | 122 const AudioParameters& params) { |
| 117 if (!params.IsValid() || params.channels > kMaxInputChannels) | 123 if (!params.IsValid() || params.channels > kMaxInputChannels) |
| 118 return NULL; | 124 return NULL; |
| 119 | 125 |
| 120 if (params.format == AudioParameters::AUDIO_MOCK) { | 126 if (params.format == AudioParameters::AUDIO_MOCK) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 } | 169 } |
| 164 | 170 |
| 165 void AudioManagerLinux::MuteAll() { | 171 void AudioManagerLinux::MuteAll() { |
| 166 NOTIMPLEMENTED(); | 172 NOTIMPLEMENTED(); |
| 167 } | 173 } |
| 168 | 174 |
| 169 void AudioManagerLinux::UnMuteAll() { | 175 void AudioManagerLinux::UnMuteAll() { |
| 170 NOTIMPLEMENTED(); | 176 NOTIMPLEMENTED(); |
| 171 } | 177 } |
| 172 | 178 |
| 173 void AudioManagerLinux::ReleaseOutputStream(AlsaPcmOutputStream* stream) { | 179 void AudioManagerLinux::ReleaseOutputStream(AudioOutputStream* stream) { |
| 174 if (stream) { | 180 if (stream) { |
| 175 active_streams_.erase(stream); | 181 active_streams_.erase(stream); |
| 176 delete stream; | 182 delete stream; |
| 177 } | 183 } |
| 178 } | 184 } |
| 179 | 185 |
| 180 bool AudioManagerLinux::CanShowAudioInputSettings() { | 186 bool AudioManagerLinux::CanShowAudioInputSettings() { |
| 181 scoped_ptr<base::Environment> env(base::Environment::Create()); | 187 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 182 base::nix::DesktopEnvironment desktop = base::nix::GetDesktopEnvironment( | 188 base::nix::DesktopEnvironment desktop = base::nix::GetDesktopEnvironment( |
| 183 env.get()); | 189 env.get()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 return true; | 235 return true; |
| 230 } | 236 } |
| 231 | 237 |
| 232 return false; | 238 return false; |
| 233 } | 239 } |
| 234 | 240 |
| 235 // static | 241 // static |
| 236 AudioManager* AudioManager::CreateAudioManager() { | 242 AudioManager* AudioManager::CreateAudioManager() { |
| 237 return new AudioManagerLinux(); | 243 return new AudioManagerLinux(); |
| 238 } | 244 } |
| OLD | NEW |