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