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

Unified Diff: media/audio/audio_util.cc

Issue 11309015: Increase Windows XP hardware buffer size to 4096. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 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
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | media/base/media_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/audio_util.cc
diff --git a/media/audio/audio_util.cc b/media/audio/audio_util.cc
index 8f05410d02980e014311cd3b71214cfbc034ea86..7ab32c540c0791e79cabc846dfeceba52484b50d 100644
--- a/media/audio/audio_util.cc
+++ b/media/audio/audio_util.cc
@@ -19,6 +19,7 @@
#include "base/basictypes.h"
#include "base/logging.h"
+#include "base/string_number_conversions.h"
#include "base/time.h"
#include "media/audio/audio_parameters.h"
#include "media/base/audio_bus.h"
@@ -39,6 +40,21 @@
namespace media {
+// Returns user buffer size as specified on the command line or 0 if no buffer
+// size has been specified.
+static int GetUserBufferSize() {
+ const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
+ int buffer_size = 0;
+ std::string buffer_size_str(cmd_line->GetSwitchValueASCII(
+ switches::kAudioBufferSize));
+ if (!buffer_size_str.empty() &&
scherkus (not reviewing) 2012/10/29 18:23:02 nit: base::StringToInt() will return 0 on empty st
DaleCurtis 2012/10/30 21:52:52 Done.
+ base::StringToInt(buffer_size_str, &buffer_size) && buffer_size > 0) {
+ return buffer_size;
+ }
+
+ return 0;
+}
+
// TODO(fbarchard): Convert to intrinsics for better efficiency.
template<class Fixed>
static int ScaleChannel(int channel, int volume) {
@@ -225,6 +241,10 @@ int GetAudioInputHardwareSampleRate(const std::string& device_id) {
}
size_t GetAudioHardwareBufferSize() {
+ int user_buffer_size = GetUserBufferSize();
+ if (user_buffer_size)
+ return user_buffer_size;
+
// The sizes here were determined by experimentation and are roughly
// the lowest value (for low latency) that still allowed glitch-free
// audio under high loads.
@@ -236,7 +256,7 @@ size_t GetAudioHardwareBufferSize() {
return 128;
#elif defined(OS_WIN)
// Buffer size to use when a proper size can't be determined from the system.
- static const int kFallbackBufferSize = 2048;
+ static const int kFallbackBufferSize = 4096;
scherkus (not reviewing) 2012/10/29 18:23:02 henrika: this is the buffer size change
henrika (OOO until Aug 14) 2012/10/29 18:50:33 Got it. Thanks.
if (!IsWASAPISupported()) {
// Fall back to Windows Wave implementation on Windows XP or lower
@@ -314,6 +334,10 @@ ChannelLayout GetAudioInputHardwareChannelLayout(const std::string& device_id) {
// Computes a buffer size based on the given |sample_rate|. Must be used in
// conjunction with AUDIO_PCM_LINEAR.
size_t GetHighLatencyOutputBufferSize(int sample_rate) {
+ int user_buffer_size = GetUserBufferSize();
+ if (user_buffer_size)
+ return user_buffer_size;
+
// TODO(vrk/crogers): The buffer sizes that this function computes is probably
// overly conservative. However, reducing the buffer size to 2048-8192 bytes
// caused crbug.com/108396. This computation should be revisited while making
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | media/base/media_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698