OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, | 5 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, |
6 // potential deadlocks, etc... | 6 // potential deadlocks, etc... |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/condition_variable.h" | 10 #include "base/condition_variable.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 return loaded_; | 287 return loaded_; |
288 } | 288 } |
289 | 289 |
290 PipelineError PipelineImpl::GetError() const { | 290 PipelineError PipelineImpl::GetError() const { |
291 AutoLock auto_lock(lock_); | 291 AutoLock auto_lock(lock_); |
292 return error_; | 292 return error_; |
293 } | 293 } |
294 | 294 |
295 void PipelineImpl::SetCurrentReadPosition(int64 offset) { | 295 void PipelineImpl::SetCurrentReadPosition(int64 offset) { |
296 AutoLock auto_lock(lock_); | 296 AutoLock auto_lock(lock_); |
| 297 |
| 298 // The current read position should never be ahead of the buffered byte |
| 299 // position but threading issues between BufferedDataSource::DoneRead_Locked() |
| 300 // and BufferedDataSource::NetworkEventCallback() can cause them to be |
| 301 // temporarily out of sync. The easiest fix for this is to cap both |
| 302 // buffered_bytes_ and current_bytes_ to always be legal values in |
| 303 // SetCurrentReadPosition() and in SetBufferedBytes(). |
| 304 if (offset > buffered_bytes_) |
| 305 buffered_bytes_ = offset; |
297 current_bytes_ = offset; | 306 current_bytes_ = offset; |
298 } | 307 } |
299 | 308 |
300 int64 PipelineImpl::GetCurrentReadPosition() { | 309 int64 PipelineImpl::GetCurrentReadPosition() { |
301 AutoLock auto_lock(lock_); | 310 AutoLock auto_lock(lock_); |
302 return current_bytes_; | 311 return current_bytes_; |
303 } | 312 } |
304 | 313 |
305 void PipelineImpl::SetPipelineEndedCallback(PipelineCallback* ended_callback) { | 314 void PipelineImpl::SetPipelineEndedCallback(PipelineCallback* ended_callback) { |
306 DCHECK(!IsRunning()) | 315 DCHECK(!IsRunning()) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 451 |
443 void PipelineImpl::SetTotalBytes(int64 total_bytes) { | 452 void PipelineImpl::SetTotalBytes(int64 total_bytes) { |
444 DCHECK(IsRunning()); | 453 DCHECK(IsRunning()); |
445 AutoLock auto_lock(lock_); | 454 AutoLock auto_lock(lock_); |
446 total_bytes_ = total_bytes; | 455 total_bytes_ = total_bytes; |
447 } | 456 } |
448 | 457 |
449 void PipelineImpl::SetBufferedBytes(int64 buffered_bytes) { | 458 void PipelineImpl::SetBufferedBytes(int64 buffered_bytes) { |
450 DCHECK(IsRunning()); | 459 DCHECK(IsRunning()); |
451 AutoLock auto_lock(lock_); | 460 AutoLock auto_lock(lock_); |
| 461 |
| 462 // See comments in SetCurrentReadPosition() about capping. |
| 463 if (buffered_bytes < current_bytes_) |
| 464 current_bytes_ = buffered_bytes; |
452 buffered_bytes_ = buffered_bytes; | 465 buffered_bytes_ = buffered_bytes; |
453 } | 466 } |
454 | 467 |
455 void PipelineImpl::SetVideoSize(size_t width, size_t height) { | 468 void PipelineImpl::SetVideoSize(size_t width, size_t height) { |
456 DCHECK(IsRunning()); | 469 DCHECK(IsRunning()); |
457 AutoLock auto_lock(lock_); | 470 AutoLock auto_lock(lock_); |
458 video_width_ = width; | 471 video_width_ = width; |
459 video_height_ = height; | 472 video_height_ = height; |
460 } | 473 } |
461 | 474 |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 filters_.front()->Stop(NewCallback( | 1038 filters_.front()->Stop(NewCallback( |
1026 this, &PipelineImpl::OnFilterStateTransition)); | 1039 this, &PipelineImpl::OnFilterStateTransition)); |
1027 } else { | 1040 } else { |
1028 state_ = kStopped; | 1041 state_ = kStopped; |
1029 message_loop_->PostTask(FROM_HERE, | 1042 message_loop_->PostTask(FROM_HERE, |
1030 NewRunnableMethod(this, &PipelineImpl::FinishDestroyingFiltersTask)); | 1043 NewRunnableMethod(this, &PipelineImpl::FinishDestroyingFiltersTask)); |
1031 } | 1044 } |
1032 } | 1045 } |
1033 | 1046 |
1034 } // namespace media | 1047 } // namespace media |
OLD | NEW |