| 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 "media/base/audio_fifo.h" | 9 #include "media/base/audio_fifo.h" |
| 10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 // Consumes |frames_to_consume| audio frames from the FIFO and copies | 33 // Consumes |frames_to_consume| audio frames from the FIFO and copies |
| 34 // them to |destination|. If the FIFO does not have enough data, we ask | 34 // them to |destination|. If the FIFO does not have enough data, we ask |
| 35 // the producer to give us more data to fulfill the request using the | 35 // the producer to give us more data to fulfill the request using the |
| 36 // ReadCB implementation. | 36 // ReadCB implementation. |
| 37 void Consume(AudioBus* destination, int frames_to_consume); | 37 void Consume(AudioBus* destination, int frames_to_consume); |
| 38 | 38 |
| 39 // Empties the FIFO without deallocating any memory. | 39 // Empties the FIFO without deallocating any memory. |
| 40 void Clear(); | 40 void Clear(); |
| 41 | 41 |
| 42 // Number of output frames already processed. Can be called by ReadCB to |
| 43 // determine the current audio delay due to buffering. |
| 44 int output_frames_ready() { return output_frames_ready_; } |
| 45 |
| 42 private: | 46 private: |
| 43 // Attempt to fulfill the request using what is available in the FIFO. | 47 // Attempt to fulfill the request using what is available in the FIFO. |
| 44 // Append new data to the |destination| starting at |write_pos|. | 48 // Append new data to the |destination| starting at |write_pos|. |
| 45 void ReadFromFifo( | 49 void ReadFromFifo( |
| 46 AudioBus* destination, int* frames_to_provide, int* write_pos); | 50 AudioBus* destination, int* frames_to_provide, int* write_pos); |
| 47 | 51 |
| 48 // Source of data to the FIFO. | 52 // Source of data to the FIFO. |
| 49 ReadCB read_cb_; | 53 ReadCB read_cb_; |
| 50 | 54 |
| 51 // The actual FIFO. | 55 // The actual FIFO. |
| 52 scoped_ptr<AudioFifo> fifo_; | 56 scoped_ptr<AudioFifo> fifo_; |
| 53 | 57 |
| 54 // Temporary audio bus to hold the data from the producer. | 58 // Temporary audio bus to hold the data from the producer. |
| 55 scoped_ptr<AudioBus> bus_; | 59 scoped_ptr<AudioBus> bus_; |
| 56 | 60 |
| 61 int output_frames_ready_; |
| 62 |
| 57 DISALLOW_COPY_AND_ASSIGN(AudioPullFifo); | 63 DISALLOW_COPY_AND_ASSIGN(AudioPullFifo); |
| 58 }; | 64 }; |
| 59 | 65 |
| 60 } // namespace media | 66 } // namespace media |
| 61 | 67 |
| 62 #endif // MEDIA_BASE_AUDIO_PULL_FIFO_H_ | 68 #endif // MEDIA_BASE_AUDIO_PULL_FIFO_H_ |
| OLD | NEW |