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

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

Issue 10592014: media/audio/linux: Add CrasInputStream. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase before trying cq Created 8 years, 5 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
« no previous file with comments | « no previous file | media/audio/linux/cras_input.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) 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"
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/linux/alsa_input.h" 14 #include "media/audio/linux/alsa_input.h"
15 #include "media/audio/linux/alsa_output.h" 15 #include "media/audio/linux/alsa_output.h"
16 #include "media/audio/linux/alsa_wrapper.h" 16 #include "media/audio/linux/alsa_wrapper.h"
17 #if defined(USE_PULSEAUDIO) 17 #if defined(USE_PULSEAUDIO)
18 #include "media/audio/pulse/pulse_output.h" 18 #include "media/audio/pulse/pulse_output.h"
19 #endif 19 #endif
20 #if defined(USE_CRAS) 20 #if defined(USE_CRAS)
21 #include "media/audio/linux/cras_input.h"
21 #include "media/audio/linux/cras_output.h" 22 #include "media/audio/linux/cras_output.h"
22 #endif 23 #endif
23 #include "media/base/limits.h" 24 #include "media/base/limits.h"
24 #include "media/base/media_switches.h" 25 #include "media/base/media_switches.h"
25 26
26 namespace media { 27 namespace media {
27 28
28 // Maximum number of output streams that can be open simultaneously. 29 // Maximum number of output streams that can be open simultaneously.
29 static const int kMaxOutputStreams = 50; 30 static const int kMaxOutputStreams = 50;
30 31
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 261 }
261 262
262 AudioInputStream* AudioManagerLinux::MakeLowLatencyInputStream( 263 AudioInputStream* AudioManagerLinux::MakeLowLatencyInputStream(
263 const AudioParameters& params, const std::string& device_id) { 264 const AudioParameters& params, const std::string& device_id) {
264 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format()); 265 DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
265 return MakeInputStream(params, device_id); 266 return MakeInputStream(params, device_id);
266 } 267 }
267 268
268 AudioOutputStream* AudioManagerLinux::MakeOutputStream( 269 AudioOutputStream* AudioManagerLinux::MakeOutputStream(
269 const AudioParameters& params) { 270 const AudioParameters& params) {
270 AudioOutputStream* stream = NULL;
271 #if defined(USE_CRAS) 271 #if defined(USE_CRAS)
272 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseCras)) { 272 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseCras)) {
273 stream = new CrasOutputStream(params, this); 273 return new CrasOutputStream(params, this);
274 } else { 274 }
275 #endif 275 #endif
276
276 #if defined(USE_PULSEAUDIO) 277 #if defined(USE_PULSEAUDIO)
277 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) { 278 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUsePulseAudio)) {
278 stream = new PulseAudioOutputStream(params, this); 279 return new PulseAudioOutputStream(params, this);
279 } else {
280 #endif
281 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice;
282 if (CommandLine::ForCurrentProcess()->HasSwitch(
283 switches::kAlsaOutputDevice)) {
284 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
285 switches::kAlsaOutputDevice);
286 }
287 stream = new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this);
288 #if defined(USE_PULSEAUDIO)
289 } 280 }
290 #endif 281 #endif
291 #if defined(USE_CRAS) 282
283 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice;
284 if (CommandLine::ForCurrentProcess()->HasSwitch(
285 switches::kAlsaOutputDevice)) {
286 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
287 switches::kAlsaOutputDevice);
292 } 288 }
293 #endif 289 return new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this);
294 DCHECK(stream);
295 return stream;
296 } 290 }
297 291
298 AudioInputStream* AudioManagerLinux::MakeInputStream( 292 AudioInputStream* AudioManagerLinux::MakeInputStream(
299 const AudioParameters& params, const std::string& device_id) { 293 const AudioParameters& params, const std::string& device_id) {
294 #if defined(USE_CRAS)
295 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseCras)) {
296 return new CrasInputStream(params, this);
297 }
298 #endif
300 299
301 std::string device_name = (device_id == AudioManagerBase::kDefaultDeviceId) ? 300 std::string device_name = (device_id == AudioManagerBase::kDefaultDeviceId) ?
302 AlsaPcmInputStream::kAutoSelectDevice : device_id; 301 AlsaPcmInputStream::kAutoSelectDevice : device_id;
303 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAlsaInputDevice)) { 302 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAlsaInputDevice)) {
304 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 303 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
305 switches::kAlsaInputDevice); 304 switches::kAlsaInputDevice);
306 } 305 }
307 306
308 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); 307 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get());
309 } 308 }
310 309
311 AudioManager* CreateAudioManager() { 310 AudioManager* CreateAudioManager() {
312 return new AudioManagerLinux(); 311 return new AudioManagerLinux();
313 } 312 }
314 313
315 } // namespace media 314 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/audio/linux/cras_input.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698