Chromium Code Reviews| Index: third_party/WebKit/Source/platform/audio/AudioDestination.cpp |
| diff --git a/third_party/WebKit/Source/platform/audio/AudioDestination.cpp b/third_party/WebKit/Source/platform/audio/AudioDestination.cpp |
| index 28649d669065421f369ffef2790765bb29decc5a..3c105a56172bb52ac15c73412e59a1531ee22501 100644 |
| --- a/third_party/WebKit/Source/platform/audio/AudioDestination.cpp |
| +++ b/third_party/WebKit/Source/platform/audio/AudioDestination.cpp |
| @@ -27,6 +27,8 @@ |
| */ |
| #include "platform/audio/AudioDestination.h" |
| + |
| +#include "platform/Histogram.h" |
| #include "platform/audio/AudioFIFO.h" |
| #include "platform/audio/AudioPullFIFO.h" |
| #include "public/platform/Platform.h" |
| @@ -54,8 +56,17 @@ AudioDestination::AudioDestination(AudioIOCallback& callback, const String& inpu |
| , m_sampleRate(sampleRate) |
| , m_isPlaying(false) |
| { |
| + // Histogram for audioHardwareBufferSize |
| + DEFINE_STATIC_LOCAL(SparseHistogram, hardwareBufferSizeHistogram, |
| + ("WebAudio.AudioDestination.HardwareBuffersize")); |
| + // Histogram for the actual callback size used. Typically, this is the same as |
| + // audioHardwareBufferSize, but can be adjusted depending on some heuristics below. |
| + DEFINE_STATIC_LOCAL(SparseHistogram, callbackBufferSizeHistogram, |
|
Mark P
2016/05/03 21:35:23
Sparse histograms are slow. see here for details:
Raymond Toy
2016/05/03 21:43:20
This is updated only when the AudioContext is crea
|
| + ("WebAudio.AudioDestination.CallbackBufferSize")); |
| + |
| // Use the optimal buffer size recommended by the audio backend. |
| - m_callbackBufferSize = Platform::current()->audioHardwareBufferSize(); |
| + size_t recommendedHardwareBufferSize = Platform::current()->audioHardwareBufferSize(); |
| + m_callbackBufferSize = recommendedHardwareBufferSize; |
| #if OS(ANDROID) |
| // The optimum low-latency hardware buffer size is usually too small on Android for WebAudio to |
| @@ -81,6 +92,10 @@ AudioDestination::AudioDestination(AudioIOCallback& callback, const String& inpu |
| m_audioDevice = adoptPtr(Platform::current()->createAudioDevice(m_callbackBufferSize, numberOfInputChannels, numberOfOutputChannels, sampleRate, this, inputDeviceId, securityOrigin)); |
| ASSERT(m_audioDevice); |
| + // Record the sizes if we successfully created an output device. |
| + hardwareBufferSizeHistogram.sample(recommendedHardwareBufferSize); |
| + callbackBufferSizeHistogram.sample(m_callbackBufferSize); |
| + |
| // Create a FIFO to handle the possibility of the callback size |
| // not being a multiple of the render size. If the FIFO already |
| // contains enough data, the data will be provided directly. |