OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_FIFO_H_ | 5 #ifndef MEDIA_BASE_AUDIO_FIFO_H_ |
6 #define MEDIA_BASE_AUDIO_FIFO_H_ | 6 #define MEDIA_BASE_AUDIO_FIFO_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "media/base/audio_bus.h" | 11 #include "media/base/audio_bus.h" |
10 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
11 | 13 |
12 namespace media { | 14 namespace media { |
13 | 15 |
14 // First-in first-out container for AudioBus elements. | 16 // First-in first-out container for AudioBus elements. |
15 // The maximum number of audio frames in the FIFO is set at construction and | 17 // The maximum number of audio frames in the FIFO is set at construction and |
16 // can not be extended dynamically. The allocated memory is utilized as a | 18 // can not be extended dynamically. The allocated memory is utilized as a |
17 // ring buffer. | 19 // ring buffer. |
(...skipping 18 matching lines...) Expand all Loading... |
36 // Empties the FIFO without deallocating any memory. | 38 // Empties the FIFO without deallocating any memory. |
37 void Clear(); | 39 void Clear(); |
38 | 40 |
39 // Number of actual audio frames in the FIFO. | 41 // Number of actual audio frames in the FIFO. |
40 int frames() const; | 42 int frames() const; |
41 | 43 |
42 int max_frames() const { return max_frames_; } | 44 int max_frames() const { return max_frames_; } |
43 | 45 |
44 private: | 46 private: |
45 // The actual FIFO is an audio bus implemented as a ring buffer. | 47 // The actual FIFO is an audio bus implemented as a ring buffer. |
46 scoped_ptr<AudioBus> audio_bus_; | 48 std::unique_ptr<AudioBus> audio_bus_; |
47 | 49 |
48 // Maximum number of elements the FIFO can contain. | 50 // Maximum number of elements the FIFO can contain. |
49 // This value is set by |frames| in the constructor. | 51 // This value is set by |frames| in the constructor. |
50 const int max_frames_; | 52 const int max_frames_; |
51 | 53 |
52 // Number of actual elements in the FIFO. | 54 // Number of actual elements in the FIFO. |
53 int frames_pushed_; | 55 int frames_pushed_; |
54 int frames_consumed_; | 56 int frames_consumed_; |
55 | 57 |
56 // Current read position. | 58 // Current read position. |
57 int read_pos_; | 59 int read_pos_; |
58 | 60 |
59 // Current write position. | 61 // Current write position. |
60 int write_pos_; | 62 int write_pos_; |
61 | 63 |
62 DISALLOW_COPY_AND_ASSIGN(AudioFifo); | 64 DISALLOW_COPY_AND_ASSIGN(AudioFifo); |
63 }; | 65 }; |
64 | 66 |
65 } // namespace media | 67 } // namespace media |
66 | 68 |
67 #endif // MEDIA_BASE_AUDIO_FIFO_H_ | 69 #endif // MEDIA_BASE_AUDIO_FIFO_H_ |
OLD | NEW |