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/buffered_data_source.h" | 5 #include "media/blink/buffered_data_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "media/base/media_log.h" | 10 #include "media/base/media_log.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 return; | 309 return; |
310 | 310 |
311 position = read_op_->position(); | 311 position = read_op_->position(); |
312 size = read_op_->size(); | 312 size = read_op_->size(); |
313 } | 313 } |
314 | 314 |
315 // First we prepare the intermediate read buffer for BufferedResourceLoader | 315 // First we prepare the intermediate read buffer for BufferedResourceLoader |
316 // to write to. | 316 // to write to. |
317 if (size > intermediate_read_buffer_size_) { | 317 if (size > intermediate_read_buffer_size_) { |
318 intermediate_read_buffer_.reset(new uint8[size]); | 318 intermediate_read_buffer_.reset(new uint8[size]); |
319 intermediate_read_buffer_size_ = size; | |
xhwang
2014/09/23 20:56:22
Thanks for fixing this! The fix looks good. But I
| |
319 } | 320 } |
320 | 321 |
321 // Perform the actual read with BufferedResourceLoader. | 322 // Perform the actual read with BufferedResourceLoader. |
322 loader_->Read(position, | 323 loader_->Read(position, |
323 size, | 324 size, |
324 intermediate_read_buffer_.get(), | 325 intermediate_read_buffer_.get(), |
325 base::Bind(&BufferedDataSource::ReadCallback, | 326 base::Bind(&BufferedDataSource::ReadCallback, |
326 weak_factory_.GetWeakPtr())); | 327 weak_factory_.GetWeakPtr())); |
327 } | 328 } |
328 | 329 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 } | 527 } |
527 | 528 |
528 // If media is currently playing or the page indicated preload=auto or the | 529 // If media is currently playing or the page indicated preload=auto or the |
529 // the server does not support the byte range request or we do not want to go | 530 // the server does not support the byte range request or we do not want to go |
530 // too far ahead of the read head, use threshold strategy to enable/disable | 531 // too far ahead of the read head, use threshold strategy to enable/disable |
531 // deferring when the buffer is full/depleted. | 532 // deferring when the buffer is full/depleted. |
532 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); | 533 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); |
533 } | 534 } |
534 | 535 |
535 } // namespace media | 536 } // namespace media |
OLD | NEW |