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 // Audio rendering unit utilizing an AudioRendererSink to output data. | 5 // Audio rendering unit utilizing an AudioRendererSink to output data. |
6 // | 6 // |
7 // This class lives inside three threads during it's lifetime, namely: | 7 // This class lives inside three threads during it's lifetime, namely: |
8 // 1. Render thread. | 8 // 1. Render thread. |
9 // This object is created on the render thread. | 9 // This object is created on the render thread. |
10 // 2. Pipeline thread | 10 // 2. Pipeline thread |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // enough. In such scenarios, the callee should zero out unused portions | 78 // enough. In such scenarios, the callee should zero out unused portions |
79 // of their buffer to playback silence. | 79 // of their buffer to playback silence. |
80 // | 80 // |
81 // FillBuffer() updates the pipeline's playback timestamp. If FillBuffer() is | 81 // FillBuffer() updates the pipeline's playback timestamp. If FillBuffer() is |
82 // not called at the same rate as audio samples are played, then the reported | 82 // not called at the same rate as audio samples are played, then the reported |
83 // timestamp in the pipeline will be ahead of the actual audio playback. In | 83 // timestamp in the pipeline will be ahead of the actual audio playback. In |
84 // this case |playback_delay| should be used to indicate when in the future | 84 // this case |playback_delay| should be used to indicate when in the future |
85 // should the filled buffer be played. If FillBuffer() is called as the audio | 85 // should the filled buffer be played. If FillBuffer() is called as the audio |
86 // hardware plays the buffer, then |playback_delay| should be zero. | 86 // hardware plays the buffer, then |playback_delay| should be zero. |
87 // | 87 // |
88 // FillBuffer() calls SignalEndOfStream() when it reaches end of stream. | |
89 // | |
90 // Safe to call on any thread. | 88 // Safe to call on any thread. |
91 uint32 FillBuffer(uint8* dest, | 89 uint32 FillBuffer(uint8* dest, |
92 uint32 requested_frames, | 90 uint32 requested_frames, |
93 const base::TimeDelta& playback_delay); | 91 const base::TimeDelta& playback_delay); |
94 | 92 |
95 // Called at the end of stream when all the hardware buffers become empty | |
96 // (i.e. when all the data written to the device has been played). | |
97 void SignalEndOfStream(); | |
98 | |
99 // Get the playback rate of |algorithm_|. | 93 // Get the playback rate of |algorithm_|. |
100 float GetPlaybackRate(); | 94 float GetPlaybackRate(); |
101 | 95 |
102 // Convert number of bytes to duration of time using information about the | 96 // Convert number of bytes to duration of time using information about the |
103 // number of channels, sample rate and sample bits. | 97 // number of channels, sample rate and sample bits. |
104 base::TimeDelta ConvertToDuration(int bytes); | 98 base::TimeDelta ConvertToDuration(int bytes); |
105 | 99 |
106 // Estimate earliest time when current buffer can stop playing. | 100 // Estimate earliest time when current buffer can stop playing. |
107 void UpdateEarliestEndTime(int bytes_filled, | 101 void UpdateEarliestEndTime(int bytes_filled, |
108 base::TimeDelta request_delay, | 102 base::TimeDelta request_delay, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 AudioParameters audio_parameters_; | 199 AudioParameters audio_parameters_; |
206 | 200 |
207 AudioDecoder::ReadCB read_cb_; | 201 AudioDecoder::ReadCB read_cb_; |
208 | 202 |
209 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 203 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
210 }; | 204 }; |
211 | 205 |
212 } // namespace media | 206 } // namespace media |
213 | 207 |
214 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ | 208 #endif // MEDIA_FILTERS_AUDIO_RENDERER_IMPL_H_ |
OLD | NEW |