Title: [95508] trunk/Source/WebKit/chromium
- Revision
- 95508
- Author
- commit-qu...@webkit.org
- Date
- 2011-09-19 19:07:23 -0700 (Mon, 19 Sep 2011)
Log Message
Ask for audio hardware buffer size instead of using hardwired constants.
https://bugs.webkit.org/show_bug.cgi?id=67952
Patch by Raymond Toy <r...@google.com> on 2011-09-19
Reviewed by Kenneth Russell.
* public/WebKitPlatformSupport.h:
(WebKit::WebKitPlatformSupport::audioHardwareBufferSize): Declare
new member function audioHardwareBufferSize.
* src/AudioDestinationChromium.cpp:
(WebCore::AudioDestinationChromium::AudioDestinationChromium):
Call audioHardwareBufferSize() to get buffer size; update
m_callbackBuffersize and m_renderCountPerCallback appropriately.
Remove global variables callbackBufferSize and
renderCountPerCallback. Add constant for maximum
allowed buffer size and verify we don't exceed it.
(WebCore::AudioDestinationChromium::render): Use new member
variables instead of globals.
* src/AudioDestinationChromium.h:
Define new member variables m_callbackBufferSize and
m_renderCountPerCallback
Modified Paths
Diff
Modified: trunk/Source/WebKit/chromium/ChangeLog (95507 => 95508)
--- trunk/Source/WebKit/chromium/ChangeLog 2011-09-20 01:53:00 UTC (rev 95507)
+++ trunk/Source/WebKit/chromium/ChangeLog 2011-09-20 02:07:23 UTC (rev 95508)
@@ -1,3 +1,26 @@
+2011-09-19 Raymond Toy <r...@google.com>
+
+ Ask for audio hardware buffer size instead of using hardwired constants.
+ https://bugs.webkit.org/show_bug.cgi?id=67952
+
+ Reviewed by Kenneth Russell.
+
+ * public/WebKitPlatformSupport.h:
+ (WebKit::WebKitPlatformSupport::audioHardwareBufferSize): Declare
+ new member function audioHardwareBufferSize.
+ * src/AudioDestinationChromium.cpp:
+ (WebCore::AudioDestinationChromium::AudioDestinationChromium):
+ Call audioHardwareBufferSize() to get buffer size; update
+ m_callbackBuffersize and m_renderCountPerCallback appropriately.
+ Remove global variables callbackBufferSize and
+ renderCountPerCallback. Add constant for maximum
+ allowed buffer size and verify we don't exceed it.
+ (WebCore::AudioDestinationChromium::render): Use new member
+ variables instead of globals.
+ * src/AudioDestinationChromium.h:
+ Define new member variables m_callbackBufferSize and
+ m_renderCountPerCallback
+
2011-09-19 Adam Barth <aba...@webkit.org>
Always enable ENABLE(EVENTSOURCE)
Modified: trunk/Source/WebKit/chromium/public/WebKitPlatformSupport.h (95507 => 95508)
--- trunk/Source/WebKit/chromium/public/WebKitPlatformSupport.h 2011-09-20 01:53:00 UTC (rev 95507)
+++ trunk/Source/WebKit/chromium/public/WebKitPlatformSupport.h 2011-09-20 02:07:23 UTC (rev 95508)
@@ -308,6 +308,7 @@
// Audio --------------------------------------------------------------
virtual double audioHardwareSampleRate() { return 0; }
+ virtual size_t audioHardwareBufferSize() { return 0; }
virtual WebAudioDevice* createAudioDevice(size_t bufferSize, unsigned numberOfChannels, double sampleRate, WebAudioDevice::RenderCallback*) { return 0; }
// FileSystem ----------------------------------------------------------
Modified: trunk/Source/WebKit/chromium/src/AudioDestinationChromium.cpp (95507 => 95508)
--- trunk/Source/WebKit/chromium/src/AudioDestinationChromium.cpp 2011-09-20 01:53:00 UTC (rev 95507)
+++ trunk/Source/WebKit/chromium/src/AudioDestinationChromium.cpp 2011-09-20 02:07:23 UTC (rev 95508)
@@ -40,21 +40,11 @@
namespace WebCore {
-// Buffer size that the Chromium audio system will call us back with.
-#if OS(DARWIN)
-// For Mac OS X the chromium audio backend uses a low-latency CoreAudio API, so a low buffer size is possible.
-const unsigned callbackBufferSize = 128;
-#else
-// This value may need to be tuned based on the OS.
-// FIXME: It may be possible to reduce this value once real-time threads
-// and other Chromium audio improvements are made.
-const unsigned callbackBufferSize = 2048;
-#endif
-
// Buffer size at which the web audio engine will render.
const unsigned renderBufferSize = 128;
-const unsigned renderCountPerCallback = callbackBufferSize / renderBufferSize;
+// Maximum allowed buffer size
+const size_t maximumCallbackBufferSize = 16384;
// FIXME: add support for multi-channel.
const unsigned numberOfChannels = 2;
@@ -71,7 +61,22 @@
, m_sampleRate(sampleRate)
, m_isPlaying(false)
{
- m_audioDevice = adoptPtr(webKitPlatformSupport()->createAudioDevice(callbackBufferSize, numberOfChannels, sampleRate, this));
+ // Get the minimum usable buffer size. We'll round this value up
+ // to a multiple of our render size.
+ size_t callbackSize = webKitPlatformSupport()->audioHardwareBufferSize();
+
+ // Figure out how many render calls per call back, rounding up if needed.
+ m_renderCountPerCallback = (callbackSize + renderBufferSize - 1) / renderBufferSize;
+
+ m_callbackBufferSize = m_renderCountPerCallback * renderBufferSize;
+
+ bool isSizeGood = m_callbackBufferSize >= renderBufferSize
+ && m_callbackBufferSize <= maximumCallbackBufferSize;
+ ASSERT(isSizeGood);
+ if (!isSizeGood)
+ return;
+
+ m_audioDevice = adoptPtr(webKitPlatformSupport()->createAudioDevice(m_callbackBufferSize, numberOfChannels, sampleRate, this));
ASSERT(m_audioDevice.get());
}
@@ -110,14 +115,14 @@
return;
}
- bool isBufferSizeGood = numberOfFrames == callbackBufferSize;
+ bool isBufferSizeGood = numberOfFrames == m_callbackBufferSize;
if (!isBufferSizeGood) {
ASSERT_NOT_REACHED();
return;
}
// Split up the callback buffer into smaller chunks which we'll render one after the other.
- for (unsigned i = 0; i < renderCountPerCallback; ++i) {
+ for (unsigned i = 0; i < m_renderCountPerCallback; ++i) {
m_renderBus.setChannelMemory(0, audioData[0] + i * renderBufferSize, renderBufferSize);
m_renderBus.setChannelMemory(1, audioData[1] + i * renderBufferSize, renderBufferSize);
m_provider.provideInput(&m_renderBus, renderBufferSize);
Modified: trunk/Source/WebKit/chromium/src/AudioDestinationChromium.h (95507 => 95508)
--- trunk/Source/WebKit/chromium/src/AudioDestinationChromium.h 2011-09-20 01:53:00 UTC (rev 95507)
+++ trunk/Source/WebKit/chromium/src/AudioDestinationChromium.h 2011-09-20 02:07:23 UTC (rev 95508)
@@ -60,6 +60,8 @@
double m_sampleRate;
bool m_isPlaying;
OwnPtr<WebKit::WebAudioDevice> m_audioDevice;
+ size_t m_callbackBufferSize;
+ unsigned m_renderCountPerCallback;
};
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes