Chromium Code Reviews| 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 09b6433e631d819fc6bc87ab72f4c55b5cc672d1..1a892e9a851d3bd42d3dec9c8ee8c46510c8399d 100644 |
| --- a/media/audio/mac/audio_manager_mac.cc |
| +++ b/media/audio/mac/audio_manager_mac.cc |
| @@ -34,10 +34,6 @@ namespace media { |
| // Maximum number of output streams that can be open simultaneously. |
| static const int kMaxOutputStreams = 50; |
| -// Define bounds for for low-latency input and output streams. |
| -static const int kMinimumInputOutputBufferSize = 128; |
| -static const int kMaximumInputOutputBufferSize = 4096; |
| - |
| // Default sample-rate on most Apple hardware. |
| static const int kFallbackSampleRate = 44100; |
| @@ -838,9 +834,13 @@ AudioParameters AudioManagerMac::GetPreferredOutputStreamParameters( |
| // stream must be able to FIFO requests appropriately when this happens. |
| int buffer_size = ChooseBufferSize(false, hardware_sample_rate); |
| if (has_valid_input_params) { |
|
o1ka
2017/06/09 10:52:39
combine into a conditional assignment?
int buffer_
Andrew MacPherson
2017/06/12 11:23:32
Done.
|
| - buffer_size = |
| - std::min(kMaximumInputOutputBufferSize, |
| - std::max(input_params.frames_per_buffer(), buffer_size)); |
| + // If passed in via the input_params we allow buffer sizes to go as low as |
| + // the the kMinimumInputOutputBufferSize, ignoring what ChooseBufferSize() |
| + // normally returns. |
| + buffer_size = std::min( |
|
o1ka
2017/06/09 10:52:39
Add a test to media/audio/audio_manager_unittest.c
Andrew MacPherson
2017/06/12 11:23:32
No problem, as soon as we agree that this approach
|
| + static_cast<int>(limits::kMaximumInputOutputBufferSize), |
| + std::max(input_params.frames_per_buffer(), |
| + static_cast<int>(limits::kMinimumInputOutputBufferSize))); |
| } |
| int hardware_channels; |
| @@ -895,8 +895,8 @@ int AudioManagerMac::ChooseBufferSize(bool is_input, int sample_rate) { |
| // TODO(xians): Remove this workaround after WebAudio supports user defined |
| // buffer size. See https://github.com/WebAudio/web-audio-api/issues/348 |
| // for details. |
| - int buffer_size = is_input ? |
| - kMinimumInputOutputBufferSize : 2 * kMinimumInputOutputBufferSize; |
| + int buffer_size = is_input ? limits::kMinimumInputOutputBufferSize |
| + : 2 * limits::kMinimumInputOutputBufferSize; |
| const int user_buffer_size = GetUserBufferSize(); |
| if (user_buffer_size) { |
| buffer_size = user_buffer_size; |
| @@ -904,9 +904,9 @@ int AudioManagerMac::ChooseBufferSize(bool is_input, int sample_rate) { |
| // 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 (sample_rate <= 96000) |
| - buffer_size = 2 * kMinimumInputOutputBufferSize; |
| + buffer_size = 2 * limits::kMinimumInputOutputBufferSize; |
| else if (sample_rate <= 192000) |
| - buffer_size = 4 * kMinimumInputOutputBufferSize; |
| + buffer_size = 4 * limits::kMinimumInputOutputBufferSize; |
| } |
| return buffer_size; |