| 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 "content/renderer/media/webrtc/processed_local_audio_source.h" | 5 #include "content/renderer/media/webrtc/processed_local_audio_source.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "content/renderer/media/audio_device_factory.h" | 10 #include "content/renderer/media/audio_device_factory.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 343 |
| 344 media::AudioParameters ProcessedLocalAudioSource::GetInputFormat() const { | 344 media::AudioParameters ProcessedLocalAudioSource::GetInputFormat() const { |
| 345 return audio_processor_ ? audio_processor_->InputFormat() | 345 return audio_processor_ ? audio_processor_->InputFormat() |
| 346 : media::AudioParameters(); | 346 : media::AudioParameters(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 int ProcessedLocalAudioSource::GetBufferSize(int sample_rate) const { | 349 int ProcessedLocalAudioSource::GetBufferSize(int sample_rate) const { |
| 350 DCHECK(thread_checker_.CalledOnValidThread()); | 350 DCHECK(thread_checker_.CalledOnValidThread()); |
| 351 #if defined(OS_ANDROID) | 351 #if defined(OS_ANDROID) |
| 352 // TODO(henrika): Re-evaluate whether to use same logic as other platforms. | 352 // TODO(henrika): Re-evaluate whether to use same logic as other platforms. |
| 353 // http://crbug.com/638081 |
| 353 return (2 * sample_rate / 100); | 354 return (2 * sample_rate / 100); |
| 354 #endif | 355 #endif |
| 355 | 356 |
| 356 // If audio processing is turned on, require 10ms buffers. | 357 // If audio processing is turned on, require 10ms buffers. |
| 357 if (audio_processor_->has_audio_processing()) | 358 if (audio_processor_->has_audio_processing()) |
| 358 return (sample_rate / 100); | 359 return (sample_rate / 100); |
| 359 | 360 |
| 360 // If audio processing is off and the native hardware buffer size was | 361 // If audio processing is off and the native hardware buffer size was |
| 361 // provided, use it. It can be harmful, in terms of CPU/power consumption, to | 362 // provided, use it. It can be harmful, in terms of CPU/power consumption, to |
| 362 // use smaller buffer sizes than the native size (http://crbug.com/362261). | 363 // use smaller buffer sizes than the native size (http://crbug.com/362261). |
| 363 if (int hardware_buffer_size = device_info().device.input.frames_per_buffer) | 364 if (int hardware_buffer_size = device_info().device.input.frames_per_buffer) |
| 364 return hardware_buffer_size; | 365 return hardware_buffer_size; |
| 365 | 366 |
| 366 // If the buffer size is missing from the StreamDeviceInfo, provide 10ms as a | 367 // If the buffer size is missing from the StreamDeviceInfo, provide 10ms as a |
| 367 // fall-back. | 368 // fall-back. |
| 368 // | 369 // |
| 369 // TODO(miu): Identify where/why the buffer size might be missing, fix the | 370 // TODO(miu): Identify where/why the buffer size might be missing, fix the |
| 370 // code, and then require it here. | 371 // code, and then require it here. http://crbug.com/638081 |
| 371 return (sample_rate / 100); | 372 return (sample_rate / 100); |
| 372 } | 373 } |
| 373 | 374 |
| 374 } // namespace content | 375 } // namespace content |
| OLD | NEW |