Index: content/renderer/media/audio_hardware.cc |
diff --git a/content/renderer/media/audio_hardware.cc b/content/renderer/media/audio_hardware.cc |
index 183ebecd529510bea3e2d132f02ebe447f44ea10..1f49fdb991103682a94fe09a49f9693b51dff643 100644 |
--- a/content/renderer/media/audio_hardware.cc |
+++ b/content/renderer/media/audio_hardware.cc |
@@ -48,6 +48,31 @@ size_t GetOutputBufferSize() { |
return output_buffer_size; |
} |
+size_t GetHighLatencyOutputBufferSize(int sample_rate) { |
vrk (LEFT CHROMIUM)
2012/02/23 01:06:42
In CL 9416085, I deleted another version of this f
Chris Rogers
2012/02/23 19:00:21
The base value of 2048 was chosen as a value not t
|
+ // The minimum number of samples in a hardware packet. |
+ // This value is selected so that we can handle down to 5khz sample rate. |
+ static const size_t kMinSamplesPerHardwarePacket = 1024; |
+ |
+ // The maximum number of samples in a hardware packet. |
+ // This value is selected so that we can handle up to 192khz sample rate. |
+ static const size_t kMaxSamplesPerHardwarePacket = 64 * 1024; |
+ |
+ // This constant governs the hardware audio buffer size, this value should be |
+ // chosen carefully. |
+ // This value is selected so that we have 8192 samples for 48khz streams. |
+ static const size_t kMillisecondsPerHardwarePacket = 170; |
+ |
+ // Select the number of samples that can provide at least |
+ // |kMillisecondsPerHardwarePacket| worth of audio data. |
+ size_t samples = kMinSamplesPerHardwarePacket; |
+ while (samples <= kMaxSamplesPerHardwarePacket && |
+ samples * base::Time::kMillisecondsPerSecond < |
+ sample_rate * kMillisecondsPerHardwarePacket) { |
+ samples *= 2; |
Chris Rogers
2012/02/23 19:00:21
I think this should be fine for now in order to fi
vrk (LEFT CHROMIUM)
2012/02/23 22:33:18
Thanks Chris, that's good to know! Here I have a p
|
+ } |
+ return samples; |
+} |
+ |
uint32 GetInputChannelCount() { |
DCHECK(RenderThreadImpl::current() != NULL); |