| 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..642b17f2a5f658b4a4f016a3cd31b4d5f52e0a76 100644
|
| --- a/third_party/WebKit/Source/platform/audio/PushPullFIFO.cpp
|
| +++ b/third_party/WebKit/Source/platform/audio/PushPullFIFO.cpp
|
| @@ -22,9 +22,7 @@ PushPullFIFO::PushPullFIFO(unsigned number_of_channels, size_t fifo_length)
|
| : fifo_length_(fifo_length),
|
| frames_available_(0),
|
| index_read_(0),
|
| - index_write_(0),
|
| - overflow_count_(0),
|
| - underflow_count_(0) {
|
| + index_write_(0) {
|
| CHECK_LE(fifo_length_, kMaxFIFOLength);
|
| fifo_bus_ = AudioBus::Create(number_of_channels, fifo_length_);
|
| }
|
| @@ -34,6 +32,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 +82,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 +112,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 +165,16 @@ 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_);
|
| +
|
| + // |framesToRender > 0| means the frames in FIFO is not enough to fulfill the
|
| + // requested frames from the audio device.
|
| + 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_};
|
| }
|
|
|
|
|