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 <memory> |
| 9 |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "base/macros.h" | 11 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
12 | 13 |
13 namespace media { | 14 namespace media { |
14 class AudioBus; | 15 class AudioBus; |
15 | 16 |
16 // A FIFO (First In First Out) buffer to handle mismatches in buffer sizes | 17 // A FIFO (First In First Out) buffer to handle mismatches in buffer sizes |
17 // between a producer and consumer. The consumer will pull data from this FIFO. | 18 // between a producer and consumer. The consumer will pull data from this FIFO. |
18 // If data is already available in the FIFO, it is provided to the consumer. | 19 // If data is already available in the FIFO, it is provided to the consumer. |
19 // If insufficient data is available to satisfy the request, the FIFO will ask | 20 // If insufficient data is available to satisfy the request, the FIFO will ask |
20 // the producer for more data to fulfill a request. | 21 // the producer for more data to fulfill a request. |
(...skipping 26 matching lines...) Expand all Loading... |
47 | 48 |
48 private: | 49 private: |
49 // Attempt to fulfill the request using what is available in the FIFO. | 50 // Attempt to fulfill the request using what is available in the FIFO. |
50 // Append new data to the |destination| starting at |write_pos|. | 51 // Append new data to the |destination| starting at |write_pos|. |
51 int ReadFromFifo(AudioBus* destination, int frames_to_provide, int write_pos); | 52 int ReadFromFifo(AudioBus* destination, int frames_to_provide, int write_pos); |
52 | 53 |
53 // Source of data to the FIFO. | 54 // Source of data to the FIFO. |
54 const ReadCB read_cb_; | 55 const ReadCB read_cb_; |
55 | 56 |
56 // Temporary audio bus to hold the data from the producer. | 57 // Temporary audio bus to hold the data from the producer. |
57 scoped_ptr<AudioBus> fifo_; | 58 std::unique_ptr<AudioBus> fifo_; |
58 int fifo_index_; | 59 int fifo_index_; |
59 | 60 |
60 DISALLOW_COPY_AND_ASSIGN(AudioPullFifo); | 61 DISALLOW_COPY_AND_ASSIGN(AudioPullFifo); |
61 }; | 62 }; |
62 | 63 |
63 } // namespace media | 64 } // namespace media |
64 | 65 |
65 #endif // MEDIA_BASE_AUDIO_PULL_FIFO_H_ | 66 #endif // MEDIA_BASE_AUDIO_PULL_FIFO_H_ |
OLD | NEW |