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

Unified Diff: media/base/pipeline_impl.cc

Issue 3045021: Fixing crash in buffer bar painting code (Closed)
Patch Set: Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/pipeline_impl.cc
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index ec0f7911ab559363637fef76153df11523310132..e15492e3e01f90337a853abc0e7dc64d7fca6c51 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -294,6 +294,15 @@ PipelineError PipelineImpl::GetError() const {
void PipelineImpl::SetCurrentReadPosition(int64 offset) {
AutoLock auto_lock(lock_);
+
+ // The current read position should never be ahead of the buffered byte
+ // position but threading issues between BufferedDataSource::DoneRead_Locked()
+ // and BufferedDataSource::NetworkEventCallback() can cause them to be
+ // temporarily out of sync. The easiest fix for this is to cap both
+ // buffered_bytes_ and current_bytes_ to always be legal values in
+ // SetCurrentReadPosition() and in SetBufferedBytes().
+ if (offset > buffered_bytes_)
+ buffered_bytes_ = offset;
current_bytes_ = offset;
}
@@ -449,6 +458,10 @@ void PipelineImpl::SetTotalBytes(int64 total_bytes) {
void PipelineImpl::SetBufferedBytes(int64 buffered_bytes) {
DCHECK(IsRunning());
AutoLock auto_lock(lock_);
+
+ // See comments in SetCurrentReadPosition() about capping.
+ if (buffered_bytes < current_bytes_)
+ current_bytes_ = buffered_bytes;
buffered_bytes_ = buffered_bytes;
}
« 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