| Index: media/base/audio_fifo.cc
|
| diff --git a/media/base/audio_fifo.cc b/media/base/audio_fifo.cc
|
| index 87a5d823c41b2c11aef41ae376bf5709fc3febbd..ded104426bb62199064e698fcbfbcdce7190c11c 100644
|
| --- a/media/base/audio_fifo.cc
|
| +++ b/media/base/audio_fifo.cc
|
| @@ -35,12 +35,12 @@ AudioFifo::AudioFifo(int channels, int frames)
|
|
|
| AudioFifo::~AudioFifo() {}
|
|
|
| -bool AudioFifo::Push(const AudioBus* source) {
|
| +bool AudioFifo::Push(const AudioBus* source, int frames) {
|
| DCHECK(source);
|
| DCHECK_EQ(source->channels(), audio_bus_->channels());
|
|
|
| // Ensure that there is space for the new data in the FIFO.
|
| - const int source_size = source->frames();
|
| + const int source_size = frames;
|
| if (frames_in_fifo_ + source_size > max_frames()) {
|
| DLOG(ERROR) << "FIFO overflow.";
|
| return false;
|
| @@ -71,7 +71,8 @@ bool AudioFifo::Push(const AudioBus* source) {
|
| return true;
|
| }
|
|
|
| -bool AudioFifo::Consume(AudioBus* destination, int frames_to_consume) {
|
| +bool AudioFifo::Consume(AudioBus* destination, int start_frame,
|
| + int frames_to_consume) {
|
| DCHECK(destination);
|
| DCHECK_EQ(destination->channels(), audio_bus_->channels());
|
|
|
| @@ -83,8 +84,8 @@ bool AudioFifo::Consume(AudioBus* destination, int frames_to_consume) {
|
|
|
| // A copy from the FIFO to |destination| will only be performed if the
|
| // allocated memory in |destination| is sufficient.
|
| - if (frames_to_consume > destination->frames()) {
|
| - DLOG(ERROR) << "Insufficient space in destination.";
|
| + if (frames_to_consume + start_frame > destination->frames()) {
|
| + LOG(ERROR) << "Insufficient space in destination.";
|
| return false;
|
| }
|
|
|
| @@ -102,10 +103,11 @@ bool AudioFifo::Consume(AudioBus* destination, int frames_to_consume) {
|
| const float* src = audio_bus_->channel(ch);
|
|
|
| // Copy a selected part of the FIFO to the destination.
|
| - memcpy(&dest[0], &src[read_pos_], consume_size * sizeof(src[0]));
|
| + memcpy(&dest[start_frame], &src[read_pos_], consume_size * sizeof(src[0]));
|
| if (wrap_size > 0) {
|
| // Wrapping is needed: copy remaining part to the destination.
|
| - memcpy(&dest[consume_size], &src[0], wrap_size * sizeof(src[0]));
|
| + memcpy(&dest[consume_size + start_frame], &src[0],
|
| + wrap_size * sizeof(src[0]));
|
| }
|
| }
|
|
|
|
|