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

Unified Diff: media/audio/pulse/pulse_input.cc

Issue 557693003: Dynamically allocate more memory to AudioBlockFifo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed the comments. Created 6 years, 3 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
« no previous file with comments | « no previous file | media/base/audio_block_fifo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | media/base/audio_block_fifo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698