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

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: 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') | media/base/audio_fifo.cc » ('J')
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. Each channel is stored in planar format
16 // and guaranteed to be aligned by AudioBus::kChannelAlignment. The allocated
Chris Rogers 2012/09/04 20:07:20 comment nit: I'd simply remove this comment about
henrika (OOO until Aug 14) 2012/09/05 10:14:36 Done.
17 // memory is utilized as a circular queue.
Chris Rogers 2012/09/04 20:07:20 nit: My preference is to avoid the word "queue" an
henrika (OOO until Aug 14) 2012/09/05 10:14:36 Done.
18 class MEDIA_EXPORT AudioFifo {
19 public:
20 // Creates a new AudioFifo and allocates |channels| of length |frames|.
21 AudioFifo(int channels, int frames);
22 virtual ~AudioFifo();
23
24 // Appends all audio channel data from |source| to the FIFO.
25 // Returns false if the allocated space is not sufficient.
Chris Rogers 2012/09/04 20:07:20 and I would add that "partial data is not written"
henrika (OOO until Aug 14) 2012/09/05 10:14:36 Done.
26 bool Append(const AudioBus* source);
DaleCurtis 2012/09/05 10:34:18 Do we expect a recoverable / normal case where App
henrika (OOO until Aug 14) 2012/09/05 12:49:04 I discussed this off-line with Chris and his sugge
DaleCurtis 2012/09/05 13:09:22 I'd just prefer to not have to worry about the ret
27
28 // Removes |destination->frames()| audio frames from the FIFO and copies
29 // them to |destination|.
Chris Rogers 2012/09/04 20:07:20 and "Returns false if there's not enough data, not
henrika (OOO until Aug 14) 2012/09/05 10:14:36 Done.
30 bool Remove(AudioBus* destination);
DaleCurtis 2012/09/05 10:34:18 Kind of a misleading name, since it doesn't remove
henrika (OOO until Aug 14) 2012/09/05 12:49:04 Chris and I discussed this as well and landed at t
31
32 // Empties the FIFO without deallocating any memory.
33 void Clear();
34
35 // Helper methods.
36 int size() const { return size_; }
Chris Rogers 2012/09/04 20:07:20 I would tend to call this "available()" or "frames
henrika (OOO until Aug 14) 2012/09/05 10:14:36 I will wait for feedback from Dale as well. But av
DaleCurtis 2012/09/05 10:34:18 +1 for frames_available(). size() is inconsistent
henrika (OOO until Aug 14) 2012/09/05 12:49:04 OK, now I understand the point of using available.
37 int max_size() const { return audio_bus_->frames(); }
DaleCurtis 2012/09/05 10:34:18 Needed publicly?
henrika (OOO until Aug 14) 2012/09/05 12:49:04 nope; I just liked it. Will remove.
38 int channels() const { return audio_bus_->channels(); }
DaleCurtis 2012/09/05 10:34:18 Ditto.
henrika (OOO until Aug 14) 2012/09/05 12:49:04 got it, will remove.
39 bool empty() const { return (size_ == 0); }
40 bool full() const { return (size_ == max_size()); }
DaleCurtis 2012/09/05 10:34:18 Ditto / needed at all?
henrika (OOO until Aug 14) 2012/09/05 12:49:04 I dropped two of them but would like to keep these
DaleCurtis 2012/09/05 13:09:22 Seems you dropped them anyway? If you need them th
41
42 private:
43 // The actual FIFO is an audio bus implemented as a circular queue.
Chris Rogers 2012/09/04 20:07:20 queue -> buffer
henrika (OOO until Aug 14) 2012/09/05 10:14:36 Done.
44 scoped_ptr<AudioBus> audio_bus_;
45
46 // Number of actual elements in the FIFO.
47 int size_;
Chris Rogers 2012/09/04 20:07:20 size_ -> available_
henrika (OOO until Aug 14) 2012/09/05 10:14:36 I am inspired by: STL where queue::size() returns
48
49 // Current read position.
50 int read_pos_;
51
52 // Current write position.
53 int write_pos_;
54
55 DISALLOW_COPY_AND_ASSIGN(AudioFifo);
56 };
57
58 } // namespace media
59
60 #endif // MEDIA_BASE_AUDIO_FIFO_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/audio_fifo.cc » ('j') | media/base/audio_fifo.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698