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

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

Issue 10912079: Adds AudioFifo class to Chrome media. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes based on review by 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 | « no previous file | media/base/audio_fifo.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 #ifndef MEDIA_BASE_AUDIO_FIFO_H_
6 #define MEDIA_BASE_AUDIO_FIFO_H_
7
8 #include "media/base/audio_bus.h"
9 #include "media/base/media_export.h"
10
11 namespace media {
12
13 // First-in first-out container for AudioBus elements.
14 // The maximum number of audio frames in the FIFO is set at construction and
15 // can not be extended dynamically. The allocated memory is utilized as a
16 // ring buffer.
17 class MEDIA_EXPORT AudioFifo {
18 public:
19 // Creates a new AudioFifo and allocates |channels| of length |frames|.
20 AudioFifo(int channels, int frames);
21 virtual ~AudioFifo();
22
23 // Pushes all audio channel data from |source| to the FIFO.
24 // Returns false if the allocated space is not sufficient. Partial data is
25 // not written to the FIFO for this overflow case.
26 bool Push(const AudioBus* source);
27
28 // Consumes |destination->frames()| audio frames from the FIFO and copies
29 // them to |destination|.
30 // Returns false if it is not possible to fill up the complete |destination|.
DaleCurtis 2012/09/05 13:09:22 Reword, maybe: "Returns false if there are not eno
henrika (OOO until Aug 14) 2012/09/06 09:40:06 Modified the API.
31 // Partial data is not copied to the audio bus for this underrun case.
32 bool Consume(AudioBus* destination);
33
34 // Empties the FIFO without deallocating any memory.
35 void Clear();
36
37 // Number of actual audio bus frames in the FIFO.
DaleCurtis 2012/09/05 13:09:22 Drop the "bus".
henrika (OOO until Aug 14) 2012/09/05 15:26:32 Done.
DaleCurtis 2012/09/06 11:14:13 Looks unchanged still?
38 int frames_in_fifo() const { return frames_in_fifo_; }
39
40 private:
41 int max_frames() const { return max_frames_in_fifo_; }
42
43 // The actual FIFO is an audio bus implemented as a ring buffer.
44 scoped_ptr<AudioBus> audio_bus_;
45
46 // Maximum number of elements the FIFO can contain.
47 // This size is set by |frames| in the constructor.
DaleCurtis 2012/09/05 13:09:22 s/size/value/
henrika (OOO until Aug 14) 2012/09/05 15:26:32 Done.
48 const int max_frames_in_fifo_;
49
50 // Number of actual elements in the FIFO.
51 int frames_in_fifo_;
52
53 // Current read position.
54 int read_pos_;
55
56 // Current write position.
57 int write_pos_;
58
59 DISALLOW_COPY_AND_ASSIGN(AudioFifo);
60 };
61
62 } // namespace media
63
64 #endif // MEDIA_BASE_AUDIO_FIFO_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_fifo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698