Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 } | 344 } |
| 345 | 345 |
| 346 AudioParameters AudioManagerLinux::GetPreferredLowLatencyOutputStreamParameters( | 346 AudioParameters AudioManagerLinux::GetPreferredLowLatencyOutputStreamParameters( |
| 347 const AudioParameters& input_params) { | 347 const AudioParameters& input_params) { |
| 348 // Since Linux doesn't actually have a low latency path the hardware buffer | 348 // Since Linux doesn't actually have a low latency path the hardware buffer |
| 349 // size is quite large in order to prevent glitches with general usage. Some | 349 // size is quite large in order to prevent glitches with general usage. Some |
| 350 // clients, such as WebRTC, have a more limited use case and work acceptably | 350 // clients, such as WebRTC, have a more limited use case and work acceptably |
| 351 // with a smaller buffer size. The check below allows clients which want to | 351 // with a smaller buffer size. The check below allows clients which want to |
| 352 // try a smaller buffer size on Linux to do so. | 352 // try a smaller buffer size on Linux to do so. |
| 353 int buffer_size = 0; | 353 int buffer_size = 0; |
| 354 if (static_cast<size_t>(input_params.frames_per_buffer()) < | 354 if (static_cast<size_t>(input_params.frames_per_buffer()) < |
|
DaleCurtis
2012/09/25 19:56:55
Mind collapsing this to:
int buffer_size = GetAud
| |
| 355 GetAudioHardwareBufferSize()) { | 355 GetAudioHardwareBufferSize()) { |
| 356 buffer_size = input_params.frames_per_buffer(); | 356 buffer_size = input_params.frames_per_buffer(); |
| 357 } else { | 357 } else { |
| 358 buffer_size = GetAudioHardwareBufferSize(); | 358 buffer_size = GetAudioHardwareBufferSize(); |
| 359 } | 359 } |
| 360 | 360 |
| 361 #if defined(USE_CRAS) | |
| 362 // CRAS will sample rate convert if it is needed, pass the desired frame rate. | |
|
DaleCurtis
2012/09/25 19:56:55
To keep style with the above code, why not:
int s
| |
| 363 if (UseCras()) | |
| 364 return AudioParameters( | |
| 365 AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(), | |
| 366 input_params.sample_rate(), 16, buffer_size); | |
| 367 #endif | |
| 368 | |
| 361 // TODO(dalecurtis): This should include bits per channel and channel layout | 369 // TODO(dalecurtis): This should include bits per channel and channel layout |
| 362 // eventually. | 370 // eventually. |
| 363 return AudioParameters( | 371 return AudioParameters( |
| 364 AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(), | 372 AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(), |
| 365 GetAudioHardwareSampleRate(), 16, buffer_size); | 373 GetAudioHardwareSampleRate(), 16, buffer_size); |
| 366 } | 374 } |
| 367 | 375 |
| 368 } // namespace media | 376 } // namespace media |
| OLD | NEW |