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_PULL_FIFO_H_ | 5 #ifndef MEDIA_BASE_AUDIO_PULL_FIFO_H_ |
6 #define MEDIA_BASE_AUDIO_PULL_FIFO_H_ | 6 #define MEDIA_BASE_AUDIO_PULL_FIFO_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 // Consumes |frames_to_consume| audio frames from the FIFO and copies | 35 // Consumes |frames_to_consume| audio frames from the FIFO and copies |
36 // them to |destination|. If the FIFO does not have enough data, we ask | 36 // them to |destination|. If the FIFO does not have enough data, we ask |
37 // the producer to give us more data to fulfill the request using the | 37 // the producer to give us more data to fulfill the request using the |
38 // ReadCB implementation. | 38 // ReadCB implementation. |
39 void Consume(AudioBus* destination, int frames_to_consume); | 39 void Consume(AudioBus* destination, int frames_to_consume); |
40 | 40 |
41 // Empties the FIFO without deallocating any memory. | 41 // Empties the FIFO without deallocating any memory. |
42 void Clear(); | 42 void Clear(); |
43 | 43 |
| 44 // Returns the size of the fifo in number of frames. |
| 45 int SizeInFrames(); |
| 46 |
44 private: | 47 private: |
45 // Attempt to fulfill the request using what is available in the FIFO. | 48 // Attempt to fulfill the request using what is available in the FIFO. |
46 // Append new data to the |destination| starting at |write_pos|. | 49 // Append new data to the |destination| starting at |write_pos|. |
47 int ReadFromFifo(AudioBus* destination, int frames_to_provide, int write_pos); | 50 int ReadFromFifo(AudioBus* destination, int frames_to_provide, int write_pos); |
48 | 51 |
49 // Source of data to the FIFO. | 52 // Source of data to the FIFO. |
50 const ReadCB read_cb_; | 53 const ReadCB read_cb_; |
51 | 54 |
52 // Temporary audio bus to hold the data from the producer. | 55 // Temporary audio bus to hold the data from the producer. |
53 scoped_ptr<AudioBus> fifo_; | 56 scoped_ptr<AudioBus> fifo_; |
54 int fifo_index_; | 57 int fifo_index_; |
55 | 58 |
56 DISALLOW_COPY_AND_ASSIGN(AudioPullFifo); | 59 DISALLOW_COPY_AND_ASSIGN(AudioPullFifo); |
57 }; | 60 }; |
58 | 61 |
59 } // namespace media | 62 } // namespace media |
60 | 63 |
61 #endif // MEDIA_BASE_AUDIO_PULL_FIFO_H_ | 64 #endif // MEDIA_BASE_AUDIO_PULL_FIFO_H_ |
OLD | NEW |