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

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: "New buffering scheme, per offline with vrk" 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
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
25
22 // Maximum number of output streams that can be open simultaneously. 26 // Maximum number of output streams that can be open simultaneously.
23 static const size_t kMaxOutputStreams = 50; 27 static const size_t kMaxOutputStreams = 50;
24 28
25 static const int kMaxInputChannels = 2; 29 static const int kMaxInputChannels = 2;
26 30
27 // Since "default", "pulse" and "dmix" devices are virtual devices mapped to 31 // Since "default", "pulse" and "dmix" devices are virtual devices mapped to
28 // real devices, we remove them from the list to avoiding duplicate counting. 32 // real devices, we remove them from the list to avoiding duplicate counting.
29 // In addition, note that we support no more than 2 channels for recording, 33 // In addition, note that we support no more than 2 channels for recording,
30 // hence surround devices are not stored in the list. 34 // hence surround devices are not stored in the list.
31 static const char* kInvalidAudioInputDevices[] = { 35 static const char* kInvalidAudioInputDevices[] = {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 96
93 if (!initialized()) { 97 if (!initialized()) {
94 return NULL; 98 return NULL;
95 } 99 }
96 100
97 // Don't allow opening more than |kMaxOutputStreams| streams. 101 // Don't allow opening more than |kMaxOutputStreams| streams.
98 if (active_streams_.size() >= kMaxOutputStreams) { 102 if (active_streams_.size() >= kMaxOutputStreams) {
99 return NULL; 103 return NULL;
100 } 104 }
101 105
102 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice; 106 AudioOutputStream* stream;
103 if (CommandLine::ForCurrentProcess()->HasSwitch( 107 #if defined(USE_PULSEAUDIO)
104 switches::kAlsaOutputDevice)) { 108 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) {
105 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 109 stream = new PulseAudioOutputStream(params, this, GetMessageLoop());
106 switches::kAlsaOutputDevice); 110 } else {
111 #endif
112 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice;
113 if (CommandLine::ForCurrentProcess()->HasSwitch(
114 switches::kAlsaOutputDevice)) {
115 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
116 switches::kAlsaOutputDevice);
117 }
118 stream = new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this,
119 GetMessageLoop());
120 #if defined(USE_PULSEAUDIO)
107 } 121 }
108 AlsaPcmOutputStream* stream = 122 #endif
109 new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this,
110 GetMessageLoop());
111 active_streams_.insert(stream); 123 active_streams_.insert(stream);
112 return stream; 124 return stream;
113 } 125 }
114 126
115 AudioInputStream* AudioManagerLinux::MakeAudioInputStream( 127 AudioInputStream* AudioManagerLinux::MakeAudioInputStream(
116 const AudioParameters& params) { 128 const AudioParameters& params) {
117 if (!params.IsValid() || params.channels > kMaxInputChannels) 129 if (!params.IsValid() || params.channels > kMaxInputChannels)
118 return NULL; 130 return NULL;
119 131
120 if (params.format == AudioParameters::AUDIO_MOCK) { 132 if (params.format == AudioParameters::AUDIO_MOCK) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 175 }
164 176
165 void AudioManagerLinux::MuteAll() { 177 void AudioManagerLinux::MuteAll() {
166 NOTIMPLEMENTED(); 178 NOTIMPLEMENTED();
167 } 179 }
168 180
169 void AudioManagerLinux::UnMuteAll() { 181 void AudioManagerLinux::UnMuteAll() {
170 NOTIMPLEMENTED(); 182 NOTIMPLEMENTED();
171 } 183 }
172 184
173 void AudioManagerLinux::ReleaseOutputStream(AlsaPcmOutputStream* stream) { 185 void AudioManagerLinux::ReleaseOutputStream(AudioOutputStream* stream) {
174 if (stream) { 186 if (stream) {
175 active_streams_.erase(stream); 187 active_streams_.erase(stream);
176 delete stream; 188 delete stream;
177 } 189 }
178 } 190 }
179 191
180 bool AudioManagerLinux::CanShowAudioInputSettings() { 192 bool AudioManagerLinux::CanShowAudioInputSettings() {
181 scoped_ptr<base::Environment> env(base::Environment::Create()); 193 scoped_ptr<base::Environment> env(base::Environment::Create());
182 base::nix::DesktopEnvironment desktop = base::nix::GetDesktopEnvironment( 194 base::nix::DesktopEnvironment desktop = base::nix::GetDesktopEnvironment(
183 env.get()); 195 env.get());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 return true; 241 return true;
230 } 242 }
231 243
232 return false; 244 return false;
233 } 245 }
234 246
235 // static 247 // static
236 AudioManager* AudioManager::CreateAudioManager() { 248 AudioManager* AudioManager::CreateAudioManager() {
237 return new AudioManagerLinux(); 249 return new AudioManagerLinux();
238 } 250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698