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 |