Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 740663002: Relanding 'Ignore seek operations to the current time in pause state' patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed issue with paused time Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 295
296 void WebMediaPlayerImpl::pause() { 296 void WebMediaPlayerImpl::pause() {
297 DVLOG(1) << __FUNCTION__; 297 DVLOG(1) << __FUNCTION__;
298 DCHECK(main_task_runner_->BelongsToCurrentThread()); 298 DCHECK(main_task_runner_->BelongsToCurrentThread());
299 299
300 const bool was_already_paused = paused_ || playback_rate_ == 0; 300 const bool was_already_paused = paused_ || playback_rate_ == 0;
301 paused_ = true; 301 paused_ = true;
302 pipeline_.SetPlaybackRate(0.0f); 302 pipeline_.SetPlaybackRate(0.0f);
303 if (data_source_) 303 if (data_source_)
304 data_source_->MediaIsPaused(); 304 data_source_->MediaIsPaused();
305 paused_time_ = pipeline_.GetMediaTime(); 305
306 // FIXME: In some cases GetMediaTime() returns a value less than duration
philipj_slow 2014/11/20 15:27:21 Would it also fix the problem to always clamp curr
DaleCurtis 2014/11/20 19:02:27 Instead, can you try modifying GetMediaTime() in m
philipj_slow 2014/11/20 19:10:43 Wouldn't that have the same problem, that currentT
DaleCurtis 2014/11/20 19:14:39 Pipeline already clamps currentTime to duration if
philipj_slow 2014/11/21 00:26:38 D'oh! If I had read the comment carefully, I would
Srirama 2014/11/21 04:05:44 But here we are trying to correct/manipulate the c
307 // even though playback has ended.
308 if (ended_)
309 paused_time_ = pipeline_.GetMediaDuration();
310 else
311 paused_time_ = pipeline_.GetMediaTime();
306 312
307 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PAUSE)); 313 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PAUSE));
308 314
309 if (!was_already_paused && delegate_) 315 if (!was_already_paused && delegate_)
310 delegate_->DidPause(this); 316 delegate_->DidPause(this);
311 } 317 }
312 318
313 bool WebMediaPlayerImpl::supportsSave() const { 319 bool WebMediaPlayerImpl::supportsSave() const {
314 DCHECK(main_task_runner_->BelongsToCurrentThread()); 320 DCHECK(main_task_runner_->BelongsToCurrentThread());
315 return supports_save_; 321 return supports_save_;
(...skipping 14 matching lines...) Expand all
330 pending_seek_ = true; 336 pending_seek_ = true;
331 pending_seek_seconds_ = seconds; 337 pending_seek_seconds_ = seconds;
332 if (chunk_demuxer_) 338 if (chunk_demuxer_)
333 chunk_demuxer_->CancelPendingSeek(seek_time); 339 chunk_demuxer_->CancelPendingSeek(seek_time);
334 return; 340 return;
335 } 341 }
336 342
337 media_log_->AddEvent(media_log_->CreateSeekEvent(seconds)); 343 media_log_->AddEvent(media_log_->CreateSeekEvent(seconds));
338 344
339 // Update our paused time. 345 // Update our paused time.
340 if (paused_) 346 // In paused state ignore the seek operations to current time and generate
341 paused_time_ = seek_time; 347 // buffer state change event to eventually fire seeking and seeked events
348 if (paused_) {
349 if (paused_time_ != seek_time) {
350 paused_time_ = seek_time;
351 } else {
352 main_task_runner_->PostTask(
353 FROM_HERE,
354 base::Bind(&WebMediaPlayerImpl::OnPipelineBufferingStateChanged,
355 AsWeakPtr(),
356 BUFFERING_HAVE_ENOUGH));
357 return;
358 }
359 }
342 360
343 seeking_ = true; 361 seeking_ = true;
344 362
345 if (chunk_demuxer_) 363 if (chunk_demuxer_)
346 chunk_demuxer_->StartWaitingForSeek(seek_time); 364 chunk_demuxer_->StartWaitingForSeek(seek_time);
347 365
348 // Kick off the asynchronous seek! 366 // Kick off the asynchronous seek!
349 pipeline_.Seek( 367 pipeline_.Seek(
350 seek_time, 368 seek_time,
351 BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnPipelineSeeked, true)); 369 BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnPipelineSeeked, true));
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 compositor_task_runner_->PostTask(FROM_HERE, 1044 compositor_task_runner_->PostTask(FROM_HERE,
1027 base::Bind(&GetCurrentFrameAndSignal, 1045 base::Bind(&GetCurrentFrameAndSignal,
1028 base::Unretained(compositor_), 1046 base::Unretained(compositor_),
1029 &video_frame, 1047 &video_frame,
1030 &event)); 1048 &event));
1031 event.Wait(); 1049 event.Wait();
1032 return video_frame; 1050 return video_frame;
1033 } 1051 }
1034 1052
1035 } // namespace media 1053 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698