| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 | 266 |
| 267 void WebMediaPlayerImpl::pause() { | 267 void WebMediaPlayerImpl::pause() { |
| 268 DVLOG(1) << __FUNCTION__; | 268 DVLOG(1) << __FUNCTION__; |
| 269 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 269 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 270 | 270 |
| 271 const bool was_already_paused = paused_ || playback_rate_ == 0; | 271 const bool was_already_paused = paused_ || playback_rate_ == 0; |
| 272 paused_ = true; | 272 paused_ = true; |
| 273 pipeline_.SetPlaybackRate(0.0f); | 273 pipeline_.SetPlaybackRate(0.0f); |
| 274 if (data_source_) | 274 if (data_source_) |
| 275 data_source_->MediaIsPaused(); | 275 data_source_->MediaIsPaused(); |
| 276 paused_time_ = pipeline_.GetMediaTime(); | 276 UpdatePausedTime(); |
| 277 | 277 |
| 278 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PAUSE)); | 278 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PAUSE)); |
| 279 | 279 |
| 280 if (!was_already_paused && delegate_) | 280 if (!was_already_paused && delegate_) |
| 281 delegate_->DidPause(this); | 281 delegate_->DidPause(this); |
| 282 } | 282 } |
| 283 | 283 |
| 284 bool WebMediaPlayerImpl::supportsSave() const { | 284 bool WebMediaPlayerImpl::supportsSave() const { |
| 285 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 285 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 286 return supports_save_; | 286 return supports_save_; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 return; | 706 return; |
| 707 } | 707 } |
| 708 | 708 |
| 709 if (status != PIPELINE_OK) { | 709 if (status != PIPELINE_OK) { |
| 710 OnPipelineError(status); | 710 OnPipelineError(status); |
| 711 return; | 711 return; |
| 712 } | 712 } |
| 713 | 713 |
| 714 // Update our paused time. | 714 // Update our paused time. |
| 715 if (paused_) | 715 if (paused_) |
| 716 paused_time_ = pipeline_.GetMediaTime(); | 716 UpdatePausedTime(); |
| 717 | 717 |
| 718 should_notify_time_changed_ = time_changed; | 718 should_notify_time_changed_ = time_changed; |
| 719 } | 719 } |
| 720 | 720 |
| 721 void WebMediaPlayerImpl::OnPipelineEnded() { | 721 void WebMediaPlayerImpl::OnPipelineEnded() { |
| 722 DVLOG(1) << __FUNCTION__; | 722 DVLOG(1) << __FUNCTION__; |
| 723 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 723 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 724 | 724 |
| 725 // Ignore state changes until we've completed all outstanding seeks. | 725 // Ignore state changes until we've completed all outstanding seeks. |
| 726 if (seeking_ || pending_seek_) | 726 if (seeking_ || pending_seek_) |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 base::WaitableEvent event(false, false); | 986 base::WaitableEvent event(false, false); |
| 987 compositor_task_runner_->PostTask(FROM_HERE, | 987 compositor_task_runner_->PostTask(FROM_HERE, |
| 988 base::Bind(&GetCurrentFrameAndSignal, | 988 base::Bind(&GetCurrentFrameAndSignal, |
| 989 base::Unretained(compositor_), | 989 base::Unretained(compositor_), |
| 990 &video_frame, | 990 &video_frame, |
| 991 &event)); | 991 &event)); |
| 992 event.Wait(); | 992 event.Wait(); |
| 993 return video_frame; | 993 return video_frame; |
| 994 } | 994 } |
| 995 | 995 |
| 996 void WebMediaPlayerImpl::UpdatePausedTime() { |
| 997 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 998 |
| 999 // pause() may be called after playback has ended and the HTMLMediaElement |
| 1000 // requires that currentTime() == duration() after ending. We want to ensure |
| 1001 // |paused_time_| matches currentTime() in this case or a future seek() may |
| 1002 // incorrectly discard what it thinks is a seek to the existing time. |
| 1003 paused_time_ = |
| 1004 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); |
| 1005 } |
| 1006 |
| 996 } // namespace media | 1007 } // namespace media |
| OLD | NEW |