OLD | NEW |
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/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
11 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 // First-in first-out container for AudioBus elements. | 15 // First-in first-out container for AudioBus elements. |
16 // The FIFO is composed of blocks of AudioBus elements, it accepts interleaved | 16 // The FIFO is composed of blocks of AudioBus elements, it accepts interleaved |
17 // data as input and will deinterleave it into the FIFO, and it only allows | 17 // data as input and will deinterleave it into the FIFO, and it only allows |
18 // consuming a whole block of AudioBus element. | 18 // consuming a whole block of AudioBus element. |
19 // This class is thread-unsafe. | 19 // This class is thread-unsafe. |
| 20 // |
| 21 // NOTE: Consider using the more-efficient and easier-to-use AudioRechunker |
| 22 // instead of this FIFO implementation. |
20 class MEDIA_EXPORT AudioBlockFifo { | 23 class MEDIA_EXPORT AudioBlockFifo { |
21 public: | 24 public: |
22 // Creates a new AudioBlockFifo and allocates |blocks| memory, each block | 25 // Creates a new AudioBlockFifo and allocates |blocks| memory, each block |
23 // of memory can store |channels| of length |frames| data. | 26 // of memory can store |channels| of length |frames| data. |
24 AudioBlockFifo(int channels, int frames, int blocks); | 27 AudioBlockFifo(int channels, int frames, int blocks); |
25 virtual ~AudioBlockFifo(); | 28 virtual ~AudioBlockFifo(); |
26 | 29 |
27 // Pushes interleaved audio data from |source| to the FIFO. | 30 // Pushes interleaved audio data from |source| to the FIFO. |
28 // The method will deinterleave the data into a audio bus. | 31 // The method will deinterleave the data into a audio bus. |
29 // Push() will crash if the allocated space is insufficient. | 32 // Push() will crash if the allocated space is insufficient. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 74 |
72 // Current write position in the current written block. | 75 // Current write position in the current written block. |
73 int write_pos_; | 76 int write_pos_; |
74 | 77 |
75 DISALLOW_COPY_AND_ASSIGN(AudioBlockFifo); | 78 DISALLOW_COPY_AND_ASSIGN(AudioBlockFifo); |
76 }; | 79 }; |
77 | 80 |
78 } // namespace media | 81 } // namespace media |
79 | 82 |
80 #endif // MEDIA_BASE_AUDIO_BLOCK_FIFO_H_ | 83 #endif // MEDIA_BASE_AUDIO_BLOCK_FIFO_H_ |
OLD | NEW |