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

Side by Side Diff: media/base/audio_pull_fifo.cc

Issue 10915123: Adds media::AudioPullFifo class to Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added TODOs from Dale Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/audio_pull_fifo.h ('k') | media/base/audio_pull_fifo_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <algorithm>
6
7 #include "media/base/audio_pull_fifo.h"
8
9 #include "base/logging.h"
10
11 namespace media {
12
13 AudioPullFifo::AudioPullFifo(int channels, int frames, const ReadCB& read_cb)
14 : read_cb_(read_cb) {
15 fifo_.reset(new AudioFifo(channels, frames));
16 bus_ = AudioBus::Create(channels, frames);
17 }
18
19 AudioPullFifo::~AudioPullFifo() {
20 read_cb_.Reset();
21 }
22
23 void AudioPullFifo::Consume(AudioBus* destination, int frames_to_consume) {
24 DCHECK(destination);
DaleCurtis 2012/09/07 16:24:01 Add a DCHECK_LE(frames_to_consume, destination->fr
henrika (OOO until Aug 14) 2012/09/10 07:23:04 Done.
25
26 int frames_to_write = frames_to_consume;
27 int frames_left = std::min(fifo_->frames(), frames_to_consume);
28 fifo_->Consume(destination, 0, frames_left);
29 frames_to_write -= frames_left;
30 int write_pos = frames_left;
31
32 while (frames_to_write > 0) {
33 read_cb_.Run(bus_.get());
DaleCurtis 2012/09/07 16:24:01 This is the part we can optimize later, as right n
34 fifo_->Push(bus_.get());
35 int to_consume = std::min(bus_->frames(), frames_to_write);
36 fifo_->Consume(destination, write_pos, to_consume);
37 write_pos += to_consume;
38 frames_to_write -= to_consume;
39 }
40 }
41
42 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_pull_fifo.h ('k') | media/base/audio_pull_fifo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698