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

Side by Side Diff: media/audio/alsa/audio_manager_alsa.cc

Issue 509893002: Revert of Remove the last piece of deprecated synchronous IO code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/alsa/audio_manager_alsa.h" 5 #include "media/audio/alsa/audio_manager_alsa.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/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 AudioParameters AudioManagerAlsa::GetPreferredOutputStreamParameters( 304 AudioParameters AudioManagerAlsa::GetPreferredOutputStreamParameters(
305 const std::string& output_device_id, 305 const std::string& output_device_id,
306 const AudioParameters& input_params) { 306 const AudioParameters& input_params) {
307 // TODO(tommi): Support |output_device_id|. 307 // TODO(tommi): Support |output_device_id|.
308 DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!"; 308 DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!";
309 static const int kDefaultOutputBufferSize = 2048; 309 static const int kDefaultOutputBufferSize = 2048;
310 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO; 310 ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
311 int sample_rate = kDefaultSampleRate; 311 int sample_rate = kDefaultSampleRate;
312 int buffer_size = kDefaultOutputBufferSize; 312 int buffer_size = kDefaultOutputBufferSize;
313 int bits_per_sample = 16; 313 int bits_per_sample = 16;
314 int input_channels = 0;
314 if (input_params.IsValid()) { 315 if (input_params.IsValid()) {
315 // Some clients, such as WebRTC, have a more limited use case and work 316 // Some clients, such as WebRTC, have a more limited use case and work
316 // acceptably with a smaller buffer size. The check below allows clients 317 // acceptably with a smaller buffer size. The check below allows clients
317 // which want to try a smaller buffer size on Linux to do so. 318 // which want to try a smaller buffer size on Linux to do so.
318 // TODO(dalecurtis): This should include bits per channel and channel layout 319 // TODO(dalecurtis): This should include bits per channel and channel layout
319 // eventually. 320 // eventually.
320 sample_rate = input_params.sample_rate(); 321 sample_rate = input_params.sample_rate();
321 bits_per_sample = input_params.bits_per_sample(); 322 bits_per_sample = input_params.bits_per_sample();
322 channel_layout = input_params.channel_layout(); 323 channel_layout = input_params.channel_layout();
324 input_channels = input_params.input_channels();
323 buffer_size = std::min(input_params.frames_per_buffer(), buffer_size); 325 buffer_size = std::min(input_params.frames_per_buffer(), buffer_size);
324 } 326 }
325 327
326 int user_buffer_size = GetUserBufferSize(); 328 int user_buffer_size = GetUserBufferSize();
327 if (user_buffer_size) 329 if (user_buffer_size)
328 buffer_size = user_buffer_size; 330 buffer_size = user_buffer_size;
329 331
330 return AudioParameters( 332 return AudioParameters(
331 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, 333 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels,
332 sample_rate, bits_per_sample, buffer_size, AudioParameters::NO_EFFECTS); 334 sample_rate, bits_per_sample, buffer_size, AudioParameters::NO_EFFECTS);
333 } 335 }
334 336
335 AudioOutputStream* AudioManagerAlsa::MakeOutputStream( 337 AudioOutputStream* AudioManagerAlsa::MakeOutputStream(
336 const AudioParameters& params) { 338 const AudioParameters& params) {
337 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice; 339 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice;
338 if (CommandLine::ForCurrentProcess()->HasSwitch( 340 if (CommandLine::ForCurrentProcess()->HasSwitch(
339 switches::kAlsaOutputDevice)) { 341 switches::kAlsaOutputDevice)) {
340 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 342 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
341 switches::kAlsaOutputDevice); 343 switches::kAlsaOutputDevice);
342 } 344 }
343 return new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this); 345 return new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this);
344 } 346 }
345 347
346 AudioInputStream* AudioManagerAlsa::MakeInputStream( 348 AudioInputStream* AudioManagerAlsa::MakeInputStream(
347 const AudioParameters& params, const std::string& device_id) { 349 const AudioParameters& params, const std::string& device_id) {
348 std::string device_name = (device_id == AudioManagerBase::kDefaultDeviceId) ? 350 std::string device_name = (device_id == AudioManagerBase::kDefaultDeviceId) ?
349 AlsaPcmInputStream::kAutoSelectDevice : device_id; 351 AlsaPcmInputStream::kAutoSelectDevice : device_id;
350 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAlsaInputDevice)) { 352 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAlsaInputDevice)) {
351 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 353 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
352 switches::kAlsaInputDevice); 354 switches::kAlsaInputDevice);
353 } 355 }
354 356
355 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); 357 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get());
356 } 358 }
357 359
358 } // namespace media 360 } // namespace media
OLDNEW
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.cc ('k') | media/audio/android/audio_android_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698