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 fdfafd7a37b7ebf3252a98ece9924cee92556794..f342effbba773159e674980ed62aadcec8d9aeb4 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* input_bus) { |
| + MutexLocker locker(lock_); |
| + |
| CHECK(input_bus); |
| CHECK_EQ(input_bus->length(), AudioUtilities::kRenderQuantumFrames); |
| SECURITY_CHECK(input_bus->length() <= fifo_length_); |
| @@ -82,14 +84,16 @@ void PushPullFIFO::Push(const AudioBus* input_bus) { |
| // 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* output_bus, size_t frames_requested) { |
| +size_t PushPullFIFO::Pull(AudioBus* output_bus, size_t frames_requested) { |
| + MutexLocker locker(lock_); |
| + |
| #if OS(ANDROID) |
| if (!output_bus) { |
| // Log when outputBus or FIFO object is invalid. (crbug.com/692423) |
| LOG(WARNING) << "[WebAudio/PushPullFIFO::pull <" << static_cast<void*>(this) |
| << ">] |outputBus| is invalid."; |
| // Silently return to avoid crash. |
| - return; |
| + return 0; |
| } |
| // The following checks are in place to catch the inexplicable crash. |
| @@ -110,6 +114,7 @@ void PushPullFIFO::Pull(AudioBus* output_bus, size_t frames_requested) { |
| << " >= " << fifo_length_ << ")"; |
| } |
| #endif |
| + |
| CHECK(output_bus); |
| SECURITY_CHECK(frames_requested <= output_bus->length()); |
| SECURITY_CHECK(frames_requested <= fifo_length_); |
| @@ -162,10 +167,17 @@ void PushPullFIFO::Pull(AudioBus* output_bus, size_t frames_requested) { |
| // Update the number of frames in FIFO. |
| frames_available_ -= frames_to_fill; |
| DCHECK_EQ((index_read_ + frames_available_) % fifo_length_, index_write_); |
| + |
| + // Number of frames to render via WebAudio graph. |framesToRender > 0| means |
| + // the frames in FIFO is not enough to fulfill the requested frames from the |
| + // audio device. |
|
o1ka
2017/04/18 14:14:57
Better to put this comment into the method descrip
hongchan
2017/04/18 18:16:09
I moved the comment about the return value to the
|
| + return frames_requested > frames_available_ |
| + ? frames_requested - frames_available_ |
| + : 0; |
| } |
| const PushPullFIFOStateForTest PushPullFIFO::GetStateForTest() const { |
| - return {length(), NumberOfChannels(), FramesAvailable(), index_read_, |
| + return {length(), NumberOfChannels(), frames_available_, index_read_, |
| index_write_, overflow_count_, underflow_count_}; |
| } |