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

Unified Diff: third_party/WebKit/Source/platform/audio/AudioDestination.cpp

Issue 2740103005: Fix premature access on m_fifo in AudioDestination. (Closed)
Patch Set: Reverting changes in PushPullFIFO Created 3 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 81e007261640b149d504feb6e3cea39804c10d15..691ffb179e83c9f520c1d35e7ec0999ce6aac965 100644
--- a/third_party/WebKit/Source/platform/audio/AudioDestination.cpp
+++ b/third_party/WebKit/Source/platform/audio/AudioDestination.cpp
@@ -70,7 +70,14 @@ AudioDestination::AudioDestination(AudioIOCallback& callback,
false)),
m_renderBus(AudioBus::create(numberOfOutputChannels,
AudioUtilities::kRenderQuantumFrames)),
+ m_fifo(
+ WTF::wrapUnique(new PushPullFIFO(numberOfOutputChannels, kFIFOSize))),
m_framesElapsed(0) {
+ m_callbackBufferSize = hardwareBufferSize();
+ if (!checkBufferSize()) {
+ NOTREACHED();
+ }
+
// Create WebAudioDevice. blink::WebAudioDevice is designed to support the
// local input (e.g. loopback from OS audio system), but Chromium's media
// renderer does not support it currently. Thus, we use zero for the number
@@ -79,15 +86,6 @@ AudioDestination::AudioDestination(AudioIOCallback& callback,
0, numberOfOutputChannels, latencyHint, this, String(),
std::move(securityOrigin)));
DCHECK(m_webAudioDevice);
-
- m_callbackBufferSize = m_webAudioDevice->framesPerBuffer();
-
- if (!checkBufferSize()) {
- NOTREACHED();
- }
-
- // Create a FIFO.
- m_fifo = WTF::wrapUnique(new PushPullFIFO(numberOfOutputChannels, kFIFOSize));
}
AudioDestination::~AudioDestination() {
@@ -102,6 +100,12 @@ void AudioDestination::render(const WebVector<float*>& destinationData,
CHECK_EQ(destinationData.size(), m_numberOfOutputChannels);
CHECK_EQ(numberOfFrames, m_callbackBufferSize);
+ // Note that this method is called by AudioDeviceThread. If FIFO is not ready,
+ // or the requested render size is greater than FIFO size return here.
+ // (crbug.com/692423)
+ if (!m_fifo || m_fifo->length() < numberOfFrames)
+ return;
+
m_framesElapsed -= std::min(m_framesElapsed, priorFramesSkipped);
double outputPosition =
m_framesElapsed / static_cast<double>(m_webAudioDevice->sampleRate()) -
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698