Index: media/audio/mac/audio_manager_mac.cc |
diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc |
index b6ecf174ba9ccaae51d30b30fc13276706e6af92..b8416d291df50c5434b7c963b33397f8f39d82b4 100644 |
--- a/media/audio/mac/audio_manager_mac.cc |
+++ b/media/audio/mac/audio_manager_mac.cc |
@@ -717,17 +717,25 @@ void AudioManagerMac::HandleDeviceChanges() { |
NotifyAllOutputDeviceChangeListeners(); |
} |
-int AudioManagerMac::ChooseBufferSize(int output_sample_rate) { |
- int buffer_size = kMinimumInputOutputBufferSize; |
+int AudioManagerMac::ChooseBufferSize(bool is_input, int sample_rate) { |
+ // kMinimumInputOutputBufferSize is too small for the output side because |
+ // CoreAudio can get into under-run if the renderer fails delivering data |
+ // to the browser within the allowed time by the OS. The workaround is to |
+ // use 256 samples as the default output buffer size for sample rates |
+ // smaller than 96KHz. |
+ // TODO(xians): Remove this workaround after WebAudio supports user defined |
+ // buffer size. |
DaleCurtis
2014/10/24 17:04:43
Link to tracking bug?
no longer working on chromium
2014/10/27 10:58:51
Done.
|
+ int buffer_size = is_input ? |
no longer working on chromium
2014/10/24 10:05:29
Dale, for the input side, we still want 128 sample
|
+ kMinimumInputOutputBufferSize : 2 * kMinimumInputOutputBufferSize; |
const int user_buffer_size = GetUserBufferSize(); |
if (user_buffer_size) { |
buffer_size = user_buffer_size; |
- } else if (output_sample_rate > 48000) { |
+ } else if (sample_rate > 48000) { |
// The default buffer size is too small for higher sample rates and may lead |
// to glitching. Adjust upwards by multiples of the default size. |
- if (output_sample_rate <= 96000) |
+ if (sample_rate <= 96000) |
buffer_size = 2 * kMinimumInputOutputBufferSize; |
- else if (output_sample_rate <= 192000) |
+ else if (sample_rate <= 192000) |
buffer_size = 4 * kMinimumInputOutputBufferSize; |
} |