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

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

Issue 518433002: Revert of 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;
315 if (input_params.IsValid()) { 314 if (input_params.IsValid()) {
316 // Some clients, such as WebRTC, have a more limited use case and work 315 // Some clients, such as WebRTC, have a more limited use case and work
317 // acceptably with a smaller buffer size. The check below allows clients 316 // acceptably with a smaller buffer size. The check below allows clients
318 // which want to try a smaller buffer size on Linux to do so. 317 // which want to try a smaller buffer size on Linux to do so.
319 // TODO(dalecurtis): This should include bits per channel and channel layout 318 // TODO(dalecurtis): This should include bits per channel and channel layout
320 // eventually. 319 // eventually.
321 sample_rate = input_params.sample_rate(); 320 sample_rate = input_params.sample_rate();
322 bits_per_sample = input_params.bits_per_sample(); 321 bits_per_sample = input_params.bits_per_sample();
323 channel_layout = input_params.channel_layout(); 322 channel_layout = input_params.channel_layout();
324 input_channels = input_params.input_channels();
325 buffer_size = std::min(input_params.frames_per_buffer(), buffer_size); 323 buffer_size = std::min(input_params.frames_per_buffer(), buffer_size);
326 } 324 }
327 325
328 int user_buffer_size = GetUserBufferSize(); 326 int user_buffer_size = GetUserBufferSize();
329 if (user_buffer_size) 327 if (user_buffer_size)
330 buffer_size = user_buffer_size; 328 buffer_size = user_buffer_size;
331 329
332 return AudioParameters( 330 return AudioParameters(
333 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, input_channels, 331 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
334 sample_rate, bits_per_sample, buffer_size, AudioParameters::NO_EFFECTS); 332 sample_rate, bits_per_sample, buffer_size, AudioParameters::NO_EFFECTS);
335 } 333 }
336 334
337 AudioOutputStream* AudioManagerAlsa::MakeOutputStream( 335 AudioOutputStream* AudioManagerAlsa::MakeOutputStream(
338 const AudioParameters& params) { 336 const AudioParameters& params) {
339 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice; 337 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice;
340 if (CommandLine::ForCurrentProcess()->HasSwitch( 338 if (CommandLine::ForCurrentProcess()->HasSwitch(
341 switches::kAlsaOutputDevice)) { 339 switches::kAlsaOutputDevice)) {
342 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 340 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
343 switches::kAlsaOutputDevice); 341 switches::kAlsaOutputDevice);
344 } 342 }
345 return new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this); 343 return new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this);
346 } 344 }
347 345
348 AudioInputStream* AudioManagerAlsa::MakeInputStream( 346 AudioInputStream* AudioManagerAlsa::MakeInputStream(
349 const AudioParameters& params, const std::string& device_id) { 347 const AudioParameters& params, const std::string& device_id) {
350 std::string device_name = (device_id == AudioManagerBase::kDefaultDeviceId) ? 348 std::string device_name = (device_id == AudioManagerBase::kDefaultDeviceId) ?
351 AlsaPcmInputStream::kAutoSelectDevice : device_id; 349 AlsaPcmInputStream::kAutoSelectDevice : device_id;
352 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAlsaInputDevice)) { 350 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAlsaInputDevice)) {
353 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 351 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
354 switches::kAlsaInputDevice); 352 switches::kAlsaInputDevice);
355 } 353 }
356 354
357 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get()); 355 return new AlsaPcmInputStream(this, device_name, params, wrapper_.get());
358 } 356 }
359 357
360 } // namespace media 358 } // 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