OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/renderers/renderer_impl.h" | 5 #include "media/renderers/renderer_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 RendererImpl::RendererImpl( | 28 RendererImpl::RendererImpl( |
29 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 29 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
30 scoped_ptr<AudioRenderer> audio_renderer, | 30 scoped_ptr<AudioRenderer> audio_renderer, |
31 scoped_ptr<VideoRenderer> video_renderer) | 31 scoped_ptr<VideoRenderer> video_renderer) |
32 : state_(STATE_UNINITIALIZED), | 32 : state_(STATE_UNINITIALIZED), |
33 task_runner_(task_runner), | 33 task_runner_(task_runner), |
34 audio_renderer_(audio_renderer.Pass()), | 34 audio_renderer_(audio_renderer.Pass()), |
35 video_renderer_(video_renderer.Pass()), | 35 video_renderer_(video_renderer.Pass()), |
36 time_source_(NULL), | 36 time_source_(NULL), |
37 time_ticking_(false), | 37 time_ticking_(false), |
38 playback_rate_(0), | 38 playback_rate_(0.0), |
39 audio_buffering_state_(BUFFERING_HAVE_NOTHING), | 39 audio_buffering_state_(BUFFERING_HAVE_NOTHING), |
40 video_buffering_state_(BUFFERING_HAVE_NOTHING), | 40 video_buffering_state_(BUFFERING_HAVE_NOTHING), |
41 audio_ended_(false), | 41 audio_ended_(false), |
42 video_ended_(false), | 42 video_ended_(false), |
43 cdm_context_(nullptr), | 43 cdm_context_(nullptr), |
44 underflow_disabled_for_testing_(false), | 44 underflow_disabled_for_testing_(false), |
45 clockless_video_playback_enabled_for_testing_(false), | 45 clockless_video_playback_enabled_for_testing_(false), |
46 video_underflow_threshold_( | 46 video_underflow_threshold_( |
47 base::TimeDelta::FromMilliseconds(kDefaultVideoUnderflowThresholdMs)), | 47 base::TimeDelta::FromMilliseconds(kDefaultVideoUnderflowThresholdMs)), |
48 weak_factory_(this) { | 48 weak_factory_(this) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 162 } |
163 | 163 |
164 time_source_->SetMediaTime(time); | 164 time_source_->SetMediaTime(time); |
165 | 165 |
166 if (audio_renderer_) | 166 if (audio_renderer_) |
167 audio_renderer_->StartPlaying(); | 167 audio_renderer_->StartPlaying(); |
168 if (video_renderer_) | 168 if (video_renderer_) |
169 video_renderer_->StartPlayingFrom(time); | 169 video_renderer_->StartPlayingFrom(time); |
170 } | 170 } |
171 | 171 |
172 void RendererImpl::SetPlaybackRate(float playback_rate) { | 172 void RendererImpl::SetPlaybackRate(double playback_rate) { |
173 DVLOG(1) << __FUNCTION__ << "(" << playback_rate << ")"; | 173 DVLOG(1) << __FUNCTION__ << "(" << playback_rate << ")"; |
174 DCHECK(task_runner_->BelongsToCurrentThread()); | 174 DCHECK(task_runner_->BelongsToCurrentThread()); |
175 | 175 |
176 // Playback rate changes are only carried out while playing. | 176 // Playback rate changes are only carried out while playing. |
177 if (state_ != STATE_PLAYING) | 177 if (state_ != STATE_PLAYING) |
178 return; | 178 return; |
179 | 179 |
180 time_source_->SetPlaybackRate(playback_rate); | 180 time_source_->SetPlaybackRate(playback_rate); |
181 | 181 |
182 const float old_rate = playback_rate_; | 182 const double old_rate = playback_rate_; |
183 playback_rate_ = playback_rate; | 183 playback_rate_ = playback_rate; |
184 if (!time_ticking_ || !video_renderer_) | 184 if (!time_ticking_ || !video_renderer_) |
185 return; | 185 return; |
186 | 186 |
187 if (old_rate == 0 && playback_rate > 0) | 187 if (old_rate == 0 && playback_rate > 0) |
188 video_renderer_->OnTimeStateChanged(true); | 188 video_renderer_->OnTimeStateChanged(true); |
189 else if (old_rate > 0 && playback_rate == 0) | 189 else if (old_rate > 0 && playback_rate == 0) |
190 video_renderer_->OnTimeStateChanged(false); | 190 video_renderer_->OnTimeStateChanged(false); |
191 } | 191 } |
192 | 192 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 } | 630 } |
631 | 631 |
632 // After OnError() returns, the pipeline may destroy |this|. | 632 // After OnError() returns, the pipeline may destroy |this|. |
633 base::ResetAndReturn(&error_cb_).Run(error); | 633 base::ResetAndReturn(&error_cb_).Run(error); |
634 | 634 |
635 if (!flush_cb_.is_null()) | 635 if (!flush_cb_.is_null()) |
636 base::ResetAndReturn(&flush_cb_).Run(); | 636 base::ResetAndReturn(&flush_cb_).Run(); |
637 } | 637 } |
638 | 638 |
639 } // namespace media | 639 } // namespace media |
OLD | NEW |