Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: media/audio/linux/audio_manager_linux.cc

Issue 7473021: PulseAudio Sound Playback on Linux (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: "alsa_output_unittest fix" Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/audio/linux/audio_manager_linux.h ('k') | media/audio/linux/pulse_output.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if defined(USE_PULSEAUDIO)
20 #include "media/audio/linux/pulse_output.h"
21 #endif
19 #include "media/base/limits.h" 22 #include "media/base/limits.h"
20 #include "media/base/media_switches.h" 23 #include "media/base/media_switches.h"
21 24
22 // Maximum number of output streams that can be open simultaneously. 25 // Maximum number of output streams that can be open simultaneously.
23 static const size_t kMaxOutputStreams = 50; 26 static const size_t kMaxOutputStreams = 50;
24 27
25 static const int kMaxInputChannels = 2; 28 static const int kMaxInputChannels = 2;
26 29
27 // Since "default", "pulse" and "dmix" devices are virtual devices mapped to 30 // Since "default", "pulse" and "dmix" devices are virtual devices mapped to
28 // real devices, we remove them from the list to avoiding duplicate counting. 31 // real devices, we remove them from the list to avoiding duplicate counting.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 95
93 if (!initialized()) { 96 if (!initialized()) {
94 return NULL; 97 return NULL;
95 } 98 }
96 99
97 // Don't allow opening more than |kMaxOutputStreams| streams. 100 // Don't allow opening more than |kMaxOutputStreams| streams.
98 if (active_streams_.size() >= kMaxOutputStreams) { 101 if (active_streams_.size() >= kMaxOutputStreams) {
99 return NULL; 102 return NULL;
100 } 103 }
101 104
102 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice; 105 AudioOutputStream* stream;
103 if (CommandLine::ForCurrentProcess()->HasSwitch( 106 #if defined(USE_PULSEAUDIO)
104 switches::kAlsaOutputDevice)) { 107 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) {
105 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 108 stream = new PulseAudioOutputStream(params, this, GetMessageLoop());
106 switches::kAlsaOutputDevice); 109 } else {
110 #endif
111 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice;
112 if (CommandLine::ForCurrentProcess()->HasSwitch(
113 switches::kAlsaOutputDevice)) {
114 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
115 switches::kAlsaOutputDevice);
116 }
117 stream = new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this,
118 GetMessageLoop());
119 #if defined(USE_PULSEAUDIO)
107 } 120 }
108 AlsaPcmOutputStream* stream = 121 #endif
109 new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this,
110 GetMessageLoop());
111 active_streams_.insert(stream); 122 active_streams_.insert(stream);
112 return stream; 123 return stream;
113 } 124 }
114 125
115 AudioInputStream* AudioManagerLinux::MakeAudioInputStream( 126 AudioInputStream* AudioManagerLinux::MakeAudioInputStream(
116 const AudioParameters& params) { 127 const AudioParameters& params) {
117 if (!params.IsValid() || params.channels > kMaxInputChannels) 128 if (!params.IsValid() || params.channels > kMaxInputChannels)
118 return NULL; 129 return NULL;
119 130
120 if (params.format == AudioParameters::AUDIO_MOCK) { 131 if (params.format == AudioParameters::AUDIO_MOCK) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 174 }
164 175
165 void AudioManagerLinux::MuteAll() { 176 void AudioManagerLinux::MuteAll() {
166 NOTIMPLEMENTED(); 177 NOTIMPLEMENTED();
167 } 178 }
168 179
169 void AudioManagerLinux::UnMuteAll() { 180 void AudioManagerLinux::UnMuteAll() {
170 NOTIMPLEMENTED(); 181 NOTIMPLEMENTED();
171 } 182 }
172 183
173 void AudioManagerLinux::ReleaseOutputStream(AlsaPcmOutputStream* stream) { 184 void AudioManagerLinux::ReleaseOutputStream(AudioOutputStream* stream) {
174 if (stream) { 185 if (stream) {
175 active_streams_.erase(stream); 186 active_streams_.erase(stream);
176 delete stream; 187 delete stream;
177 } 188 }
178 } 189 }
179 190
180 bool AudioManagerLinux::CanShowAudioInputSettings() { 191 bool AudioManagerLinux::CanShowAudioInputSettings() {
181 scoped_ptr<base::Environment> env(base::Environment::Create()); 192 scoped_ptr<base::Environment> env(base::Environment::Create());
182 base::nix::DesktopEnvironment desktop = base::nix::GetDesktopEnvironment( 193 base::nix::DesktopEnvironment desktop = base::nix::GetDesktopEnvironment(
183 env.get()); 194 env.get());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 return true; 240 return true;
230 } 241 }
231 242
232 return false; 243 return false;
233 } 244 }
234 245
235 // static 246 // static
236 AudioManager* AudioManager::CreateAudioManager() { 247 AudioManager* AudioManager::CreateAudioManager() {
237 return new AudioManagerLinux(); 248 return new AudioManagerLinux();
238 } 249 }
OLDNEW
« no previous file with comments | « media/audio/linux/audio_manager_linux.h ('k') | media/audio/linux/pulse_output.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698