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

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

Issue 10991019: audio_manager_linux: Allow CRAS to decide if sample rate conversion is needed. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: comment fix. Created 8 years, 2 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 | no next file » | 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"
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 return new AudioManagerLinux(); 343 return new AudioManagerLinux();
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 = GetAudioHardwareBufferSize();
354 if (static_cast<size_t>(input_params.frames_per_buffer()) < 354 if (static_cast<size_t>(input_params.frames_per_buffer()) < buffer_size)
DaleCurtis 2012/09/25 20:49:46 Drop static_cast now.
scherkus (not reviewing) 2012/09/25 20:52:39 nit: you can remove static_cast<>
355 GetAudioHardwareBufferSize()) {
356 buffer_size = input_params.frames_per_buffer(); 355 buffer_size = input_params.frames_per_buffer();
357 } else { 356
358 buffer_size = GetAudioHardwareBufferSize(); 357 int sample_rate = GetAudioHardwareSampleRate();
359 } 358 // CRAS will sample rate convert if needed, pass the desired sample rate.
DaleCurtis 2012/09/25 20:49:46 s/pass/so pass through input sample rate./
359 if (UseCras())
360 sample_rate = input_params.sample_rate();
360 361
361 // TODO(dalecurtis): This should include bits per channel and channel layout 362 // TODO(dalecurtis): This should include bits per channel and channel layout
362 // eventually. 363 // eventually.
363 return AudioParameters( 364 return AudioParameters(
364 AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(), 365 AudioParameters::AUDIO_PCM_LOW_LATENCY, input_params.channel_layout(),
365 GetAudioHardwareSampleRate(), 16, buffer_size); 366 sample_rate, 16, buffer_size);
366 } 367 }
367 368
368 } // namespace media 369 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698