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

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

Issue 2777903005: Add WebThread in AudioDestination to support AudioWorkletThread (Closed)
Patch Set: Addressing feedback 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
Index: third_party/WebKit/Source/platform/audio/PushPullFIFO.cpp
diff --git a/third_party/WebKit/Source/platform/audio/PushPullFIFO.cpp b/third_party/WebKit/Source/platform/audio/PushPullFIFO.cpp
index 73b1ef44bf04591cdc283b1de4bf808e7b6e8ee8..dca17659afa49db997bfa41c5421307c038c8ecd 100644
--- a/third_party/WebKit/Source/platform/audio/PushPullFIFO.cpp
+++ b/third_party/WebKit/Source/platform/audio/PushPullFIFO.cpp
@@ -34,6 +34,8 @@ PushPullFIFO::~PushPullFIFO() {}
// Push the data from |inputBus| to FIFO. The size of push is determined by
// the length of |inputBus|.
void PushPullFIFO::push(const AudioBus* inputBus) {
+ MutexLocker lock(m_threadMutex);
+
CHECK(inputBus);
CHECK_EQ(inputBus->length(), AudioUtilities::kRenderQuantumFrames);
SECURITY_CHECK(inputBus->length() <= m_fifoLength);
@@ -83,6 +85,8 @@ void PushPullFIFO::push(const AudioBus* inputBus) {
// Pull the data out of FIFO to |outputBus|. If remaining frame in the FIFO
// is less than the frames to pull, provides remaining frame plus the silence.
void PushPullFIFO::pull(AudioBus* outputBus, size_t framesRequested) {
+ MutexLocker lock(m_threadMutex);
+
#if OS(ANDROID)
if (!outputBus) {
// Log when outputBus or FIFO object is invalid. (crbug.com/692423)
@@ -164,7 +168,18 @@ void PushPullFIFO::pull(AudioBus* outputBus, size_t framesRequested) {
DCHECK_EQ((m_indexRead + m_framesAvailable) % m_fifoLength, m_indexWrite);
}
+size_t PushPullFIFO::framesAvailable() const {
+ MutexLocker lock(m_threadMutex);
+ return m_framesAvailable;
o1ka 2017/03/30 13:17:05 This is correct but unfortunate to have a lock her
hongchan 2017/03/30 18:36:00 Acknowledged.
+}
+
+AudioBus* PushPullFIFO::getFIFOBusForTest() const {
+ MutexLocker lock(m_threadMutex);
+ return m_fifoBus.get();
+}
+
const PushPullFIFOStateForTest PushPullFIFO::getStateForTest() const {
+ MutexLocker lock(m_threadMutex);
return {length(), numberOfChannels(), framesAvailable(), m_indexRead,
m_indexWrite, m_overflowCount, m_underflowCount};
}

Powered by Google App Engine
This is Rietveld 408576698