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

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

Issue 10915123: Adds media::AudioPullFifo class to Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: AudioFIFO changes based on comments from Andrew 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
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 #ifndef MEDIA_BASE_AUDIO_PULL_FIFO_H_
6 #define MEDIA_BASE_AUDIO_PULL_FIFO_H_
7
8 #include "base/callback.h"
9 #include "media/base/audio_fifo.h"
10 #include "media/base/media_export.h"
11
12 namespace media {
13
14 // A FIFO (First In First Out) buffer to handle mismatches in buffer sizes
15 // between a provider and consumer. The consumer will pull data from this FIFO.
scherkus (not reviewing) 2012/09/07 14:19:03 s/provider/producer/
henrika (OOO until Aug 14) 2012/09/10 07:23:04 OK. Can be discussed I guess but it sounds better.
16 // If data is already available in the FIFO, it is provided to the consumer.
17 // If insufficient data is available to satisfy the request, the FIFO will ask
18 // the provider for more data to fulfill a request.
19 class MEDIA_EXPORT AudioPullFifo {
20 public:
21 // Callback type for providing more data into the FIFO. Expects AudioBus
22 // to be completely filled with data upon return; zero padded if not enough
23 // frames are available to satisfy the request.
24 typedef base::Callback<void(AudioBus* audio_bus)> ReadCB;
25
26 // Constructs an AudioPullFifo with the specified |read_cb|, which is used to
27 // read audio data of size |read_frames| to the FIFO if data is not already
28 // available. The internal FIFO can contain |channel| number of channels,
29 // where each channel is of length |frames| audio frames.
30 AudioPullFifo(int channels, int frames,
31 const ReadCB& read_cb, int read_frames);
32 virtual ~AudioPullFifo();
33
34 // Consumes |frames_to_consume| audio frames from the FIFO and copies
35 // them to |destination|.
36 // If the FIFO does not have enough data, we ask the provider to give us more
37 // data to fulfill the request using the ReadCB implementation.
38 void Consume(AudioBus* destination, int frames_to_consume);
39
40 private:
41 // Fill the FIFO buffer with at least |frames| number of audio frames.
42 void FillBuffer(int frames);
43
44 // Source of data to the FIFO.
45 ReadCB read_cb_;
46
47 // The actual FIFO.
48 scoped_ptr<AudioFifo> audio_fifo_;
49
50 // Temporary audio bus to hold the data from the provider.
51 scoped_ptr<AudioBus> audio_bus_;
52
53 DISALLOW_COPY_AND_ASSIGN(AudioPullFifo);
54 };
55
56 } // namespace media
57
58 #endif // MEDIA_BASE_AUDIO_PULL_FIFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698