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

Side by Side Diff: third_party/WebKit/Source/platform/audio/PushPullFIFO.cpp

Issue 2740103005: Fix premature access on m_fifo in AudioDestination. (Closed)
Patch Set: Initial commit 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/audio/PushPullFIFO.h" 5 #include "platform/audio/PushPullFIFO.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "platform/audio/AudioUtilities.h" 8 #include "platform/audio/AudioUtilities.h"
9 #include "wtf/PtrUtil.h" 9 #include "wtf/PtrUtil.h"
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 // Update the number of frames available in FIFO. 77 // Update the number of frames available in FIFO.
78 m_framesAvailable = 78 m_framesAvailable =
79 std::min(m_framesAvailable + inputBusLength, m_fifoLength); 79 std::min(m_framesAvailable + inputBusLength, m_fifoLength);
80 DCHECK_EQ((m_indexRead + m_framesAvailable) % m_fifoLength, m_indexWrite); 80 DCHECK_EQ((m_indexRead + m_framesAvailable) % m_fifoLength, m_indexWrite);
81 } 81 }
82 82
83 // Pull the data out of FIFO to |outputBus|. If remaining frame in the FIFO 83 // Pull the data out of FIFO to |outputBus|. If remaining frame in the FIFO
84 // is less than the frames to pull, provides remaining frame plus the silence. 84 // is less than the frames to pull, provides remaining frame plus the silence.
85 void PushPullFIFO::pull(AudioBus* outputBus, size_t framesRequested) { 85 void PushPullFIFO::pull(AudioBus* outputBus, size_t framesRequested) {
86 #if OS(ANDROID)
87 if (!outputBus) {
88 // Log when outputBus or FIFO object is invalid. (crbug.com/692423)
89 LOG(WARNING) << "[WebAudio/PushPullFIFO::pull <" << static_cast<void*>(this)
90 << ">] |outputBus| is invalid.";
91 // Silently return to avoid crash.
92 return;
93 }
94
95 // The following checks are in place to catch the inexplicable crash.
96 // (crbug.com/692423)
97 if (framesRequested > outputBus->length()) {
98 LOG(WARNING) << "[WebAudio/PushPullFIFO::pull <" << static_cast<void*>(this)
99 << ">] framesRequested > outputBus->length() ("
100 << framesRequested << " > " << outputBus->length() << ")";
101 }
102 if (framesRequested > m_fifoLength) {
103 LOG(WARNING) << "[WebAudio/PushPullFIFO::pull <" << static_cast<void*>(this)
104 << ">] framesRequested > m_fifoLength (" << framesRequested
105 << " > " << m_fifoLength << ")";
106 }
107 if (m_indexRead >= m_fifoLength) {
108 LOG(WARNING) << "[WebAudio/PushPullFIFO::pull <" << static_cast<void*>(this)
109 << ">] m_indexRead >= m_fifoLength (" << m_indexRead
110 << " >= " << m_fifoLength << ")";
111 }
112 #endif
Raymond Toy 2017/03/10 21:11:09 Why get rid of all of these prints? They might not
hongchan 2017/03/10 21:13:55 Hmm. I thought we agreed upon deleting these for t
113 CHECK(outputBus); 86 CHECK(outputBus);
114 SECURITY_CHECK(framesRequested <= outputBus->length()); 87 SECURITY_CHECK(framesRequested <= outputBus->length());
115 SECURITY_CHECK(framesRequested <= m_fifoLength); 88 SECURITY_CHECK(framesRequested <= m_fifoLength);
116 SECURITY_CHECK(m_indexRead < m_fifoLength); 89 SECURITY_CHECK(m_indexRead < m_fifoLength);
117 90
118 const size_t remainder = m_fifoLength - m_indexRead; 91 const size_t remainder = m_fifoLength - m_indexRead;
119 const size_t framesToFill = std::min(m_framesAvailable, framesRequested); 92 const size_t framesToFill = std::min(m_framesAvailable, framesRequested);
120 93
121 for (unsigned i = 0; i < m_fifoBus->numberOfChannels(); ++i) { 94 for (unsigned i = 0; i < m_fifoBus->numberOfChannels(); ++i) {
122 const float* fifoBusChannel = m_fifoBus->channel(i)->data(); 95 const float* fifoBusChannel = m_fifoBus->channel(i)->data();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 m_framesAvailable -= framesToFill; 136 m_framesAvailable -= framesToFill;
164 DCHECK_EQ((m_indexRead + m_framesAvailable) % m_fifoLength, m_indexWrite); 137 DCHECK_EQ((m_indexRead + m_framesAvailable) % m_fifoLength, m_indexWrite);
165 } 138 }
166 139
167 const PushPullFIFOStateForTest PushPullFIFO::getStateForTest() const { 140 const PushPullFIFOStateForTest PushPullFIFO::getStateForTest() const {
168 return {length(), numberOfChannels(), framesAvailable(), m_indexRead, 141 return {length(), numberOfChannels(), framesAvailable(), m_indexRead,
169 m_indexWrite, m_overflowCount, m_underflowCount}; 142 m_indexWrite, m_overflowCount, m_underflowCount};
170 } 143 }
171 144
172 } // namespace blink 145 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698