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

Side by Side Diff: media/base/pipeline.cc

Issue 325503003: Fix seeking when the start time is non-zero. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/base/pipeline_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "media/base/pipeline.h" 5 #include "media/base/pipeline.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 // TODO(scherkus): should we run the callback? I'm tempted to say the API 736 // TODO(scherkus): should we run the callback? I'm tempted to say the API
737 // will only execute the first Seek() request. 737 // will only execute the first Seek() request.
738 DVLOG(1) << "Media pipeline has not started, ignoring seek to " 738 DVLOG(1) << "Media pipeline has not started, ignoring seek to "
739 << time.InMicroseconds() << " (current state: " << state_ << ")"; 739 << time.InMicroseconds() << " (current state: " << state_ << ")";
740 return; 740 return;
741 } 741 }
742 742
743 DCHECK(seek_cb_.is_null()); 743 DCHECK(seek_cb_.is_null());
744 744
745 SetState(kSeeking); 745 SetState(kSeeking);
746 base::TimeDelta seek_timestamp = std::max(time, demuxer_->GetStartTime());
747 seek_cb_ = seek_cb; 746 seek_cb_ = seek_cb;
748 audio_ended_ = false; 747 audio_ended_ = false;
749 video_ended_ = false; 748 video_ended_ = false;
750 text_ended_ = false; 749 text_ended_ = false;
751 750
751 // Adjust the seek timestamp by the start time (which may be negative). Don't
752 // use this value with SetTime() since it maps to a [0, duration] based
753 // timeline instead of a [start_time, duration + start_time] one internally.
754 const base::TimeDelta seek_timestamp = time + demuxer_->GetStartTime();
755
752 // Kick off seeking! 756 // Kick off seeking!
753 { 757 {
754 base::AutoLock auto_lock(lock_); 758 base::AutoLock auto_lock(lock_);
755 PauseClockAndStopRendering_Locked(); 759 PauseClockAndStopRendering_Locked();
756 clock_->SetTime(seek_timestamp, seek_timestamp); 760 clock_->SetTime(time, time);
acolwell GONE FROM CHROMIUM 2014/06/09 23:14:46 This makes me really nervous and I'm pretty sure i
757 } 761 }
758 DoSeek(seek_timestamp, base::Bind( 762 DoSeek(seek_timestamp, base::Bind(
759 &Pipeline::OnStateTransition, base::Unretained(this))); 763 &Pipeline::OnStateTransition, base::Unretained(this)));
760 } 764 }
761 765
762 void Pipeline::DoAudioRendererEnded() { 766 void Pipeline::DoAudioRendererEnded() {
763 DCHECK(task_runner_->BelongsToCurrentThread()); 767 DCHECK(task_runner_->BelongsToCurrentThread());
764 768
765 if (state_ != kPlaying) 769 if (state_ != kPlaying)
766 return; 770 return;
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { 981 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() {
978 lock_.AssertAcquired(); 982 lock_.AssertAcquired();
979 if (clock_state_ != CLOCK_WAITING_FOR_AUDIO_TIME_UPDATE) 983 if (clock_state_ != CLOCK_WAITING_FOR_AUDIO_TIME_UPDATE)
980 return; 984 return;
981 985
982 clock_state_ = CLOCK_PLAYING; 986 clock_state_ = CLOCK_PLAYING;
983 clock_->Play(); 987 clock_->Play();
984 } 988 }
985 989
986 } // namespace media 990 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/base/pipeline_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698