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

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

Issue 396263004: Switch the input code to use AudioBlockFifo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_AUDIO_BLOCK_FIFO_H_ 5 #ifndef MEDIA_BASE_AUDIO_BLOCK_FIFO_H_
6 #define MEDIA_BASE_AUDIO_BLOCK_FIFO_H_ 6 #define MEDIA_BASE_AUDIO_BLOCK_FIFO_H_
7 7
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "media/base/audio_bus.h" 9 #include "media/base/audio_bus.h"
10 #include "media/base/media_export.h" 10 #include "media/base/media_export.h"
(...skipping 21 matching lines...) Expand all
32 // contains the consumed audio data to avoid copying. 32 // contains the consumed audio data to avoid copying.
33 // Consume() will crash if the FIFO does not contain a block of data. 33 // Consume() will crash if the FIFO does not contain a block of data.
34 const AudioBus* Consume(); 34 const AudioBus* Consume();
35 35
36 // Empties the FIFO without deallocating any memory. 36 // Empties the FIFO without deallocating any memory.
37 void Clear(); 37 void Clear();
38 38
39 // Number of available block of memory ready to be consumed in the FIFO. 39 // Number of available block of memory ready to be consumed in the FIFO.
40 int available_blocks() const { return available_blocks_; } 40 int available_blocks() const { return available_blocks_; }
41 41
42 // Number of available frames of data in the FIFO.
43 int available_frames() const {
44 return available_blocks_ * block_frames_ + write_pos_;
DaleCurtis 2014/07/18 18:21:54 Needs to be non-hacker style since it's doing math
no longer working on chromium 2014/07/21 15:13:30 Thanks, I forgot it again. Done.
45 }
46
42 // Number of unfilled frames in the whole FIFO. 47 // Number of unfilled frames in the whole FIFO.
43 int GetUnfilledFrames() const; 48 int GetUnfilledFrames() const;
44 49
45 private: 50 private:
46 // The actual FIFO is a vector of audio buses. 51 // The actual FIFO is a vector of audio buses.
47 ScopedVector<AudioBus> audio_blocks_; 52 ScopedVector<AudioBus> audio_blocks_;
48 53
49 // Maximum number of frames of data one block of memory can contain. 54 // Maximum number of frames of data one block of memory can contain.
50 // This value is set by |frames| in the constructor. 55 // This value is set by |frames| in the constructor.
51 const int block_frames_; 56 const int block_frames_;
52 57
53 // Used to keep track which block of memory to be written. 58 // Used to keep track which block of memory to be written.
54 int write_block_; 59 int write_block_;
55 60
56 // Used to keep track which block of memory to be consumed. 61 // Used to keep track which block of memory to be consumed.
57 int read_block_; 62 int read_block_;
58 63
59 // Number of available blocks of memory to be consumed. 64 // Number of available blocks of memory to be consumed.
60 int available_blocks_; 65 int available_blocks_;
61 66
62 // Current write position in the current written block. 67 // Current write position in the current written block.
63 int write_pos_; 68 int write_pos_;
64 69
65 DISALLOW_COPY_AND_ASSIGN(AudioBlockFifo); 70 DISALLOW_COPY_AND_ASSIGN(AudioBlockFifo);
66 }; 71 };
67 72
68 } // namespace media 73 } // namespace media
69 74
70 #endif // MEDIA_BASE_AUDIO_BLOCK_FIFO_H_ 75 #endif // MEDIA_BASE_AUDIO_BLOCK_FIFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698