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

Unified Diff: media/blink/multibuffer_data_source.cc

Issue 1991033002: Make http/tests/media/audio-seekable-contains-zero-without-ranges.html work with multibuffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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 | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/multibuffer_data_source.cc
diff --git a/media/blink/multibuffer_data_source.cc b/media/blink/multibuffer_data_source.cc
index d86637d474349ac2da9195c431d14b6e81b35f63..2045629d420faf4c443f7d0a74b3bc135665638d 100644
--- a/media/blink/multibuffer_data_source.cc
+++ b/media/blink/multibuffer_data_source.cc
@@ -398,6 +398,16 @@ void MultibufferDataSource::ReadTask() {
bytes_read =
static_cast<int>(std::min<int64_t>(available, read_op_->size()));
bytes_read = reader_->TryRead(read_op_->data(), bytes_read);
+
+ if (bytes_read == 0 && total_bytes_ == kPositionNotSpecified) {
+ // We've reached the end of the file and we didn't know the total size
+ // before. Update the total size so Read()s past the end of the file will
+ // fail like they would if we had known the file size at the beginning.
+ total_bytes_ = reader_->Tell();
+ if (total_bytes_ != kPositionNotSpecified)
+ host_->SetTotalBytes(total_bytes_);
+ }
+
ReadOperation::Run(std::move(read_op_), bytes_read);
} else {
reader_->Wait(1, base::Bind(&MultibufferDataSource::ReadTask,
« no previous file with comments | « no previous file | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698