diff --git a/packager/media/base/demuxer.cc b/packager/media/base/demuxer.cc index 3f46b2100b..d30c33c501 100644 --- a/packager/media/base/demuxer.cc +++ b/packager/media/base/demuxer.cc @@ -159,11 +159,10 @@ Status Demuxer::Parse() { return init_parsing_status_; int64_t bytes_read = media_file_->Read(buffer_.get(), kBufSize); - if (bytes_read <= 0) { - if (media_file_->Eof()) { - parser_->Flush(); - return Status(error::END_OF_STREAM, ""); - } + if (bytes_read == 0) { + parser_->Flush(); + return Status(error::END_OF_STREAM, ""); + } else if (bytes_read < 0) { return Status(error::FILE_FAILURE, "Cannot read file " + file_name_); } diff --git a/packager/media/formats/mp4/single_segment_segmenter.cc b/packager/media/formats/mp4/single_segment_segmenter.cc index eef1aee99b..74cf3218d9 100644 --- a/packager/media/formats/mp4/single_segment_segmenter.cc +++ b/packager/media/formats/mp4/single_segment_segmenter.cc @@ -117,9 +117,11 @@ Status SingleSegmentSegmenter::DoFinalize() { const int kBufSize = 0x200000; // 2MB. scoped_ptr buf(new uint8_t[kBufSize]); - while (!temp_file->Eof()) { + while (true) { int64_t size = temp_file->Read(buf.get(), kBufSize); - if (size <= 0) { + if (size == 0) { + break; + } else if (size < 0) { return Status(error::FILE_FAILURE, "Failed to read file " + temp_file_name_); }