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

Unified Diff: media/base/audio_block_fifo.cc

Issue 557693003: Dynamically allocate more memory to AudioBlockFifo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « media/base/audio_block_fifo.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_block_fifo.cc
diff --git a/media/base/audio_block_fifo.cc b/media/base/audio_block_fifo.cc
index 5e8c9b37949babea29b10a464b2a6e3fd9189610..407150b1dec15b0a603edeb3b3fa330e8c831f75 100644
--- a/media/base/audio_block_fifo.cc
+++ b/media/base/audio_block_fifo.cc
@@ -9,17 +9,13 @@
namespace media {
AudioBlockFifo::AudioBlockFifo(int channels, int frames, int blocks)
- : block_frames_(frames),
+ : channels_(channels),
+ block_frames_(frames),
write_block_(0),
read_block_(0),
available_blocks_(0),
write_pos_(0) {
- // Create |blocks| of audio buses and push them to the containers.
- audio_blocks_.reserve(blocks);
- for (int i = 0; i < blocks; ++i) {
- scoped_ptr<AudioBus> audio_bus = AudioBus::Create(channels, frames);
- audio_blocks_.push_back(audio_bus.release());
- }
+ Append(blocks);
}
AudioBlockFifo::~AudioBlockFifo() {}
@@ -31,6 +27,7 @@ void AudioBlockFifo::Push(const void* source,
DCHECK_GT(frames, 0);
DCHECK_GT(bytes_per_sample, 0);
DCHECK_LT(available_blocks_, static_cast<int>(audio_blocks_.size()));
+ CHECK_LT(frames, GetUnfilledFrames());
const uint8* source_ptr = static_cast<const uint8*>(source);
int frames_to_push = frames;
@@ -54,7 +51,7 @@ void AudioBlockFifo::Push(const void* source,
++available_blocks_;
}
- source_ptr += push_frames * bytes_per_sample * current_block->channels();
+ source_ptr += push_frames * bytes_per_sample * channels_;
frames_to_push -= push_frames;
DCHECK_GE(frames_to_push, 0);
}
@@ -86,4 +83,13 @@ int AudioBlockFifo::GetUnfilledFrames() const {
return unfilled_frames;
}
+void AudioBlockFifo::Append(int blocks) {
DaleCurtis 2014/09/12 17:14:00 Append feels like it may be giving too much of the
+ // Create |blocks| of audio buses and add them to the containers.
+ audio_blocks_.reserve(audio_blocks_.size() + blocks);
+ for (int i = 0; i < blocks; ++i) {
+ scoped_ptr<AudioBus> audio_bus = AudioBus::Create(channels_, block_frames_);
+ audio_blocks_.push_back(audio_bus.release());
+ }
+}
+
} // namespace media
« no previous file with comments | « media/base/audio_block_fifo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698