OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "media/filters/audio_renderer_base.h" | 5 #include "media/filters/audio_renderer_base.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "media/base/filter_host.h" | 10 #include "media/base/filter_host.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 const uint32 kZeroLength = 8192; | 185 const uint32 kZeroLength = 8192; |
186 dest_written = std::min(kZeroLength, dest_len); | 186 dest_written = std::min(kZeroLength, dest_len); |
187 memset(dest, 0, dest_written); | 187 memset(dest, 0, dest_written); |
188 return dest_written; | 188 return dest_written; |
189 } | 189 } |
190 | 190 |
191 // Save a local copy of last fill buffer time and reset the member. | 191 // Save a local copy of last fill buffer time and reset the member. |
192 last_fill_buffer_time = last_fill_buffer_time_; | 192 last_fill_buffer_time = last_fill_buffer_time_; |
193 last_fill_buffer_time_ = base::TimeDelta(); | 193 last_fill_buffer_time_ = base::TimeDelta(); |
194 | 194 |
195 // Check if we finally reached end of stream by emptying |algorithm_|. | 195 // Use two conditions to determine the end of playback: |
196 if (algorithm_->IsQueueEmpty()) { | 196 // 1. Algorithm has no audio data. |
| 197 // 2. Browser process has no audio data. |
| 198 if (algorithm_->IsQueueEmpty() && !playback_delay.ToInternalValue()) { |
197 if (recieved_end_of_stream_ && !rendered_end_of_stream_) { | 199 if (recieved_end_of_stream_ && !rendered_end_of_stream_) { |
198 rendered_end_of_stream_ = true; | 200 rendered_end_of_stream_ = true; |
199 host()->NotifyEnded(); | 201 host()->NotifyEnded(); |
200 } | 202 } |
201 } else { | 203 } else { |
202 // Otherwise fill the buffer. | 204 // Otherwise fill the buffer. |
203 dest_written = algorithm_->FillBuffer(dest, dest_len); | 205 dest_written = algorithm_->FillBuffer(dest, dest_len); |
204 } | 206 } |
205 | 207 |
206 // Get the current time. | 208 // Get the current time. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 248 |
247 void AudioRendererBase::SetPlaybackRate(float playback_rate) { | 249 void AudioRendererBase::SetPlaybackRate(float playback_rate) { |
248 algorithm_->set_playback_rate(playback_rate); | 250 algorithm_->set_playback_rate(playback_rate); |
249 } | 251 } |
250 | 252 |
251 float AudioRendererBase::GetPlaybackRate() { | 253 float AudioRendererBase::GetPlaybackRate() { |
252 return algorithm_->playback_rate(); | 254 return algorithm_->playback_rate(); |
253 } | 255 } |
254 | 256 |
255 } // namespace media | 257 } // namespace media |
OLD | NEW |