OLD | NEW |
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 if (running_) { | 156 if (running_) { |
157 task_runner_->PostTask( | 157 task_runner_->PostTask( |
158 FROM_HERE, | 158 FROM_HERE, |
159 base::Bind( | 159 base::Bind( |
160 &Pipeline::VolumeChangedTask, weak_factory_.GetWeakPtr(), volume)); | 160 &Pipeline::VolumeChangedTask, weak_factory_.GetWeakPtr(), volume)); |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 TimeDelta Pipeline::GetMediaTime() const { | 164 TimeDelta Pipeline::GetMediaTime() const { |
165 base::AutoLock auto_lock(lock_); | 165 base::AutoLock auto_lock(lock_); |
166 if (!renderer_) | 166 return renderer_ ? std::min(renderer_->GetMediaTime(), duration_) |
167 return TimeDelta(); | 167 : TimeDelta(); |
168 | |
169 // TODO(sriram): In some cases GetMediaTime() returns a value few | |
170 // milliseconds less than duration, even though playback has ended | |
171 // http://crbug.com/438581 | |
172 TimeDelta media_time = renderer_->GetMediaTime(); | |
173 if (renderer_ended_) | |
174 return duration_; | |
175 | |
176 return std::min(media_time, duration_); | |
177 } | 168 } |
178 | 169 |
179 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const { | 170 Ranges<TimeDelta> Pipeline::GetBufferedTimeRanges() const { |
180 base::AutoLock auto_lock(lock_); | 171 base::AutoLock auto_lock(lock_); |
181 return buffered_time_ranges_; | 172 return buffered_time_ranges_; |
182 } | 173 } |
183 | 174 |
184 TimeDelta Pipeline::GetMediaDuration() const { | 175 TimeDelta Pipeline::GetMediaDuration() const { |
185 base::AutoLock auto_lock(lock_); | 176 base::AutoLock auto_lock(lock_); |
186 return duration_; | 177 return duration_; |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 metadata_cb_.Run(metadata); | 749 metadata_cb_.Run(metadata); |
759 } | 750 } |
760 | 751 |
761 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { | 752 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { |
762 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; | 753 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; |
763 DCHECK(task_runner_->BelongsToCurrentThread()); | 754 DCHECK(task_runner_->BelongsToCurrentThread()); |
764 buffering_state_cb_.Run(new_buffering_state); | 755 buffering_state_cb_.Run(new_buffering_state); |
765 } | 756 } |
766 | 757 |
767 } // namespace media | 758 } // namespace media |
OLD | NEW |