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

Unified Diff: media/base/audio_latency.cc

Issue 2908073002: Make OS audio buffer size limits visible. (Closed)
Patch Set: Different approach as suggested by olka. Created 3 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_latency.cc
diff --git a/media/base/audio_latency.cc b/media/base/audio_latency.cc
index 61b3724efa48cc36fc8ff7c3a545c95d7ba5bb56..05c9ac4ad18f883d4ec012f9a51fc2bd45bd2c09 100644
--- a/media/base/audio_latency.cc
+++ b/media/base/audio_latency.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/time/time.h"
#include "build/build_config.h"
+#include "media/base/limits.h"
namespace media {
@@ -132,6 +133,12 @@ int AudioLatency::GetExactBufferSize(base::TimeDelta duration,
int hardware_buffer_size) {
const double requested_buffer_size = duration.InSecondsF() * sample_rate;
+ // On OSX the preferred buffer size is larger than the minimum, however we
+ // allow values down to the minimum if requested explicitly.
+#if defined(OS_MACOSX)
+ hardware_buffer_size = limits::kMinimumOutputBufferSize;
+#endif
+
DCHECK_NE(0, hardware_buffer_size);
// Round the requested size to the nearest multiple of the hardware size
@@ -139,7 +146,8 @@ int AudioLatency::GetExactBufferSize(base::TimeDelta duration,
std::round(std::max(requested_buffer_size, 1.0) / hardware_buffer_size) *
hardware_buffer_size;
- return std::max(buffer_size, hardware_buffer_size);
+ return std::min(static_cast<int>(media::limits::kMaximumOutputBufferSize),
+ std::max(buffer_size, hardware_buffer_size));
}
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698