| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/base/audio_hardware_config.h" | 5 #include "media/base/audio_hardware_config.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 | 11 |
| 12 using base::AutoLock; | 12 using base::AutoLock; |
| 13 using media::AudioParameters; | 13 using media::AudioParameters; |
| 14 | 14 |
| 15 namespace media { | 15 namespace media { |
| 16 | 16 |
| 17 #if defined(OS_LINUX) | 17 #if defined(OS_LINUX) || defined(OS_MACOSX) |
| 18 #define HIGH_LATENCY_AUDIO_SUPPORT 1 | 18 #define HIGH_LATENCY_AUDIO_SUPPORT 1 |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 #if defined(HIGH_LATENCY_AUDIO_SUPPORT) | 21 #if defined(HIGH_LATENCY_AUDIO_SUPPORT) |
| 22 // Taken from "Bit Twiddling Hacks" | 22 // Taken from "Bit Twiddling Hacks" |
| 23 // http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 | 23 // http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 |
| 24 static uint32_t RoundUpToPowerOfTwo(uint32_t v) { | 24 static uint32_t RoundUpToPowerOfTwo(uint32_t v) { |
| 25 v--; | 25 v--; |
| 26 v |= v >> 1; | 26 v |= v >> 1; |
| 27 v |= v >> 2; | 27 v |= v >> 2; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // dependent but will generally be sample_rate() / 100. | 119 // dependent but will generally be sample_rate() / 100. |
| 120 const int high_latency_buffer_size = | 120 const int high_latency_buffer_size = |
| 121 RoundUpToPowerOfTwo(2 * output_params_.sample_rate() / 100); | 121 RoundUpToPowerOfTwo(2 * output_params_.sample_rate() / 100); |
| 122 return std::max(output_params_.frames_per_buffer(), high_latency_buffer_size); | 122 return std::max(output_params_.frames_per_buffer(), high_latency_buffer_size); |
| 123 #else | 123 #else |
| 124 return output_params_.frames_per_buffer(); | 124 return output_params_.frames_per_buffer(); |
| 125 #endif | 125 #endif |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace media | 128 } // namespace media |
| OLD | NEW |