| 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" | |
| 10 #include "media/base/audio_bus.h" | 9 #include "media/base/audio_bus.h" |
| 11 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
| 12 | 11 |
| 13 namespace media { | 12 namespace media { |
| 14 | 13 |
| 15 // First-in first-out container for AudioBus elements. | 14 // First-in first-out container for AudioBus elements. |
| 16 // The FIFO is composed of blocks of AudioBus elements, it accepts interleaved | 15 // 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 | 16 // data as input and will deinterleave it into the FIFO, and it only allows |
| 18 // consuming a whole block of AudioBus element. | 17 // consuming a whole block of AudioBus element. |
| 19 // This class is thread-unsafe. | 18 // This class is thread-unsafe. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // Dynamically increase |blocks| of memory to the FIFO. | 51 // Dynamically increase |blocks| of memory to the FIFO. |
| 53 void IncreaseCapacity(int blocks); | 52 void IncreaseCapacity(int blocks); |
| 54 | 53 |
| 55 private: | 54 private: |
| 56 // Common implementation for Push() and PushSilence. if |source| is nullptr, | 55 // Common implementation for Push() and PushSilence. if |source| is nullptr, |
| 57 // silence will be pushed. To push silence, set source and bytes_per_sample to | 56 // silence will be pushed. To push silence, set source and bytes_per_sample to |
| 58 // nullptr and 0 respectively. | 57 // nullptr and 0 respectively. |
| 59 void PushInternal(const void* source, int frames, int bytes_per_sample); | 58 void PushInternal(const void* source, int frames, int bytes_per_sample); |
| 60 | 59 |
| 61 // The actual FIFO is a vector of audio buses. | 60 // The actual FIFO is a vector of audio buses. |
| 62 ScopedVector<AudioBus> audio_blocks_; | 61 std::vector<std::unique_ptr<AudioBus>> audio_blocks_; |
| 63 | 62 |
| 64 // Number of channels in AudioBus. | 63 // Number of channels in AudioBus. |
| 65 const int channels_; | 64 const int channels_; |
| 66 | 65 |
| 67 // Maximum number of frames of data one block of memory can contain. | 66 // Maximum number of frames of data one block of memory can contain. |
| 68 // This value is set by |frames| in the constructor. | 67 // This value is set by |frames| in the constructor. |
| 69 const int block_frames_; | 68 const int block_frames_; |
| 70 | 69 |
| 71 // Used to keep track which block of memory to be written. | 70 // Used to keep track which block of memory to be written. |
| 72 int write_block_; | 71 int write_block_; |
| 73 | 72 |
| 74 // Used to keep track which block of memory to be consumed. | 73 // Used to keep track which block of memory to be consumed. |
| 75 int read_block_; | 74 int read_block_; |
| 76 | 75 |
| 77 // Number of available blocks of memory to be consumed. | 76 // Number of available blocks of memory to be consumed. |
| 78 int available_blocks_; | 77 int available_blocks_; |
| 79 | 78 |
| 80 // Current write position in the current written block. | 79 // Current write position in the current written block. |
| 81 int write_pos_; | 80 int write_pos_; |
| 82 | 81 |
| 83 DISALLOW_COPY_AND_ASSIGN(AudioBlockFifo); | 82 DISALLOW_COPY_AND_ASSIGN(AudioBlockFifo); |
| 84 }; | 83 }; |
| 85 | 84 |
| 86 } // namespace media | 85 } // namespace media |
| 87 | 86 |
| 88 #endif // MEDIA_BASE_AUDIO_BLOCK_FIFO_H_ | 87 #endif // MEDIA_BASE_AUDIO_BLOCK_FIFO_H_ |
| OLD | NEW |