Index: media/audio/pulse/pulse_input.cc |
diff --git a/media/audio/pulse/pulse_input.cc b/media/audio/pulse/pulse_input.cc |
index b9d91c6a679d501c194a7d57c8c993839baf3384..4a56d3a6b1407321484b8c00c85b2cbe81f4cf6a 100644 |
--- a/media/audio/pulse/pulse_input.cc |
+++ b/media/audio/pulse/pulse_input.cc |
@@ -270,6 +270,15 @@ void PulseAudioInputStream::ReadData() { |
break; |
const int number_of_frames = length / params_.GetBytesPerFrame(); |
+ if (number_of_frames > fifo_.GetUnfilledFrames()) { |
+ // Dynamically increase capacity to the FIFO to handle larger buffer got |
+ // from Pulse. |
+ const int increase_blocks_of_buffer = static_cast<int>( |
+ (number_of_frames - fifo_.GetUnfilledFrames()) / |
+ params_.frames_per_buffer()) + 1; |
+ fifo_.IncreaseCapacity(increase_blocks_of_buffer); |
+ } |
+ |
fifo_.Push(data, number_of_frames, params_.bits_per_sample() / 8); |
// Checks if we still have data. |