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

Unified Diff: media/base/audio_hardware_config.cc

Issue 2067863003: Mixing audio with different latency requirements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing bot redness Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: media/base/audio_hardware_config.cc
diff --git a/media/base/audio_hardware_config.cc b/media/base/audio_hardware_config.cc
index f3f151385cda9855cb170c8e5fc8845291b7962d..43b51c8f03321cc02f247548a96a06c46ecc0445 100644
--- a/media/base/audio_hardware_config.cc
+++ b/media/base/audio_hardware_config.cc
@@ -17,21 +17,6 @@ using media::AudioParameters;
namespace media {
-#if !defined(OS_WIN)
-// Taken from "Bit Twiddling Hacks"
-// http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
-static uint32_t RoundUpToPowerOfTwo(uint32_t v) {
- v--;
- v |= v >> 1;
- v |= v >> 2;
- v |= v >> 4;
- v |= v >> 8;
- v |= v >> 16;
- v++;
- return v;
-}
-#endif
-
AudioHardwareConfig::AudioHardwareConfig(
const AudioParameters& input_params,
const AudioParameters& output_params)
@@ -99,43 +84,4 @@ void AudioHardwareConfig::UpdateOutputConfig(
output_params_ = output_params;
}
-// static
-int AudioHardwareConfig::GetHighLatencyBufferSize(int sample_rate,
- int buffer_size) {
- // Empirically, we consider 20ms of samples to be high latency.
- const double twenty_ms_size = 2.0 * sample_rate / 100;
-
-#if defined(OS_WIN)
- buffer_size = std::max(buffer_size, 1);
-
- // Windows doesn't use power of two buffer sizes, so we should always round up
- // to the nearest multiple of the output buffer size.
- const int high_latency_buffer_size =
- std::ceil(twenty_ms_size / buffer_size) * buffer_size;
-#else
- // On other platforms use the nearest higher power of two buffer size. For a
- // given sample rate, this works out to:
- //
- // <= 3200 : 64
- // <= 6400 : 128
- // <= 12800 : 256
- // <= 25600 : 512
- // <= 51200 : 1024
- // <= 102400 : 2048
- // <= 204800 : 4096
- //
- // On Linux, the minimum hardware buffer size is 512, so the lower calculated
- // values are unused. OSX may have a value as low as 128.
- const int high_latency_buffer_size = RoundUpToPowerOfTwo(twenty_ms_size);
-#endif // defined(OS_WIN)
-
- return std::max(buffer_size, high_latency_buffer_size);
-}
-
-int AudioHardwareConfig::GetHighLatencyBufferSize() const {
- AutoLock auto_lock(config_lock_);
- return GetHighLatencyBufferSize(output_params_.sample_rate(),
- output_params_.frames_per_buffer());
-}
-
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698