Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/multibuffer_data_source.h" | 5 #include "media/blink/multibuffer_data_source.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 return false; | 256 return false; |
| 257 // If init_cb is set, we initialization is not finished yet. | 257 // If init_cb is set, we initialization is not finished yet. |
| 258 if (!init_cb_.is_null()) | 258 if (!init_cb_.is_null()) |
| 259 return false; | 259 return false; |
| 260 // Loader will be false if there was a failure. | 260 // Loader will be false if there was a failure. |
| 261 if (!reader_) | 261 if (!reader_) |
| 262 return false; | 262 return false; |
| 263 return true; | 263 return true; |
| 264 } | 264 } |
| 265 | 265 |
| 266 void MultibufferDataSource::Abort() { | |
| 267 DCHECK(render_task_runner_->BelongsToCurrentThread()); | |
| 268 { | |
| 269 base::AutoLock auto_lock(lock_); | |
| 270 StopInternal_Locked(); | |
| 271 } | |
| 272 StopLoader(); | |
| 273 frame_ = NULL; | |
| 274 } | |
| 275 | |
| 276 void MultibufferDataSource::MediaPlaybackRateChanged(double playback_rate) { | 266 void MultibufferDataSource::MediaPlaybackRateChanged(double playback_rate) { |
| 277 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 267 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 278 DCHECK(reader_.get()); | 268 DCHECK(reader_.get()); |
| 279 | 269 |
| 280 if (playback_rate < 0.0) | 270 if (playback_rate < 0.0) |
| 281 return; | 271 return; |
| 282 | 272 |
| 283 playback_rate_ = playback_rate; | 273 playback_rate_ = playback_rate; |
| 284 cancel_on_defer_ = false; | 274 cancel_on_defer_ = false; |
| 285 UpdateBufferSizes(); | 275 UpdateBufferSizes(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 300 { | 290 { |
| 301 base::AutoLock auto_lock(lock_); | 291 base::AutoLock auto_lock(lock_); |
| 302 StopInternal_Locked(); | 292 StopInternal_Locked(); |
| 303 } | 293 } |
| 304 | 294 |
| 305 render_task_runner_->PostTask(FROM_HERE, | 295 render_task_runner_->PostTask(FROM_HERE, |
| 306 base::Bind(&MultibufferDataSource::StopLoader, | 296 base::Bind(&MultibufferDataSource::StopLoader, |
| 307 weak_factory_.GetWeakPtr())); | 297 weak_factory_.GetWeakPtr())); |
| 308 } | 298 } |
| 309 | 299 |
| 300 void MultibufferDataSource::Abort() { | |
|
hubbe
2016/08/24 23:39:43
DCHECK() that we're on the right thread?
DaleCurtis
2016/08/24 23:41:10
Other data source operations are not DCHECK'd sinc
hubbe
2016/08/24 23:43:29
The previous Abort() had a DCHECK(), unless you're
DaleCurtis
2016/08/24 23:49:41
The previous Abort() method was dead code :)
| |
| 301 base::AutoLock auto_lock(lock_); | |
| 302 DCHECK(init_cb_.is_null()); | |
| 303 if (read_op_) | |
| 304 ReadOperation::Run(std::move(read_op_), kReadError); | |
| 305 } | |
| 306 | |
| 310 void MultibufferDataSource::SetBitrate(int bitrate) { | 307 void MultibufferDataSource::SetBitrate(int bitrate) { |
| 311 render_task_runner_->PostTask( | 308 render_task_runner_->PostTask( |
| 312 FROM_HERE, base::Bind(&MultibufferDataSource::SetBitrateTask, | 309 FROM_HERE, base::Bind(&MultibufferDataSource::SetBitrateTask, |
| 313 weak_factory_.GetWeakPtr(), bitrate)); | 310 weak_factory_.GetWeakPtr(), bitrate)); |
| 314 } | 311 } |
| 315 | 312 |
| 316 void MultibufferDataSource::OnBufferingHaveEnough(bool always_cancel) { | 313 void MultibufferDataSource::OnBufferingHaveEnough(bool always_cancel) { |
| 317 DCHECK(render_task_runner_->BelongsToCurrentThread()); | 314 DCHECK(render_task_runner_->BelongsToCurrentThread()); |
| 318 if (reader_ && (always_cancel || (preload_ == METADATA && | 315 if (reader_ && (always_cancel || (preload_ == METADATA && |
| 319 !media_has_played_ && !IsStreaming()))) { | 316 !media_has_played_ && !IsStreaming()))) { |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 reader_->SetPinRange(back_buffer, kMaxBufferPreload + kPreloadHighExtra); | 593 reader_->SetPinRange(back_buffer, kMaxBufferPreload + kPreloadHighExtra); |
| 597 | 594 |
| 598 if (preload_ == METADATA) { | 595 if (preload_ == METADATA) { |
| 599 reader_->SetPreload(0, 0); | 596 reader_->SetPreload(0, 0); |
| 600 } else { | 597 } else { |
| 601 reader_->SetPreload(preload_high, preload); | 598 reader_->SetPreload(preload_high, preload); |
| 602 } | 599 } |
| 603 } | 600 } |
| 604 | 601 |
| 605 } // namespace media | 602 } // namespace media |
| OLD | NEW |