Chromium Code Reviews| 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}; |
| } |