| 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" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 | 13 |
| 14 // A FIFO (First In First Out) buffer to handle mismatches in buffer sizes | 14 // A FIFO (First In First Out) buffer to handle mismatches in buffer sizes |
| 15 // between a producer and consumer. The consumer will pull data from this FIFO. | 15 // between a producer and consumer. The consumer will pull data from this FIFO. |
| 16 // If data is already available in the FIFO, it is provided to the consumer. | 16 // If data is already available in the FIFO, it is provided to the consumer. |
| 17 // If insufficient data is available to satisfy the request, the FIFO will ask | 17 // If insufficient data is available to satisfy the request, the FIFO will ask |
| 18 // the producer for more data to fulfill a request. | 18 // the producer for more data to fulfill a request. |
| 19 class MEDIA_EXPORT AudioPullFifo { | 19 class MEDIA_EXPORT AudioPullFifo { |
| 20 public: | 20 public: |
| 21 // Callback type for providing more data into the FIFO. Expects AudioBus | 21 // Callback type for providing more data into the FIFO. Expects AudioBus |
| 22 // to be completely filled with data upon return; zero padded if not enough | 22 // to be completely filled with data upon return; zero padded if not enough |
| 23 // frames are available to satisfy the request. | 23 // frames are available to satisfy the request. |frame_delay| is the number |
| 24 typedef base::Callback<void(AudioBus* audio_bus)> ReadCB; | 24 // of output frames already processed and can be used to estimate delay. |
| 25 typedef base::Callback<void(int frame_delay, AudioBus* audio_bus)> ReadCB; |
| 25 | 26 |
| 26 // Constructs an AudioPullFifo with the specified |read_cb|, which is used to | 27 // Constructs an AudioPullFifo with the specified |read_cb|, which is used to |
| 27 // read audio data to the FIFO if data is not already available. The internal | 28 // read audio data to the FIFO if data is not already available. The internal |
| 28 // FIFO can contain |channel| number of channels, where each channel is of | 29 // FIFO can contain |channel| number of channels, where each channel is of |
| 29 // length |frames| audio frames. | 30 // length |frames| audio frames. |
| 30 AudioPullFifo(int channels, int frames, const ReadCB& read_cb); | 31 AudioPullFifo(int channels, int frames, const ReadCB& read_cb); |
| 31 virtual ~AudioPullFifo(); | 32 virtual ~AudioPullFifo(); |
| 32 | 33 |
| 33 // Consumes |frames_to_consume| audio frames from the FIFO and copies | 34 // 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 | 35 // them to |destination|. If the FIFO does not have enough data, we ask |
| (...skipping 18 matching lines...) Expand all Loading... |
| 53 | 54 |
| 54 // Temporary audio bus to hold the data from the producer. | 55 // Temporary audio bus to hold the data from the producer. |
| 55 scoped_ptr<AudioBus> bus_; | 56 scoped_ptr<AudioBus> bus_; |
| 56 | 57 |
| 57 DISALLOW_COPY_AND_ASSIGN(AudioPullFifo); | 58 DISALLOW_COPY_AND_ASSIGN(AudioPullFifo); |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 } // namespace media | 61 } // namespace media |
| 61 | 62 |
| 62 #endif // MEDIA_BASE_AUDIO_PULL_FIFO_H_ | 63 #endif // MEDIA_BASE_AUDIO_PULL_FIFO_H_ |
| OLD | NEW |