Commit 110785be authored by scherkus@chromium.org's avatar scherkus@chromium.org

Return 0 instead of AVERROR_EOF for reads at or past the end of a file.

I'm not sure if it's because the files listed in the bug report were improperly muxed, but FFmpeg was attempting to read past the end of the file and apparently returning AVERROR_EOF instead of 0 makes a huge difference.

BUG=47489
TEST=media_unittests, files linked in bug report

Review URL: http://codereview.chromium.org/6249013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72350 0039d316-1c4b-4281-b951-d872f2087c98
parent 8b6911d9
...@@ -336,11 +336,11 @@ int FFmpegDemuxer::Read(int size, uint8* data) { ...@@ -336,11 +336,11 @@ int FFmpegDemuxer::Read(int size, uint8* data) {
if (read_has_failed_) if (read_has_failed_)
return AVERROR_IO; return AVERROR_IO;
// If the read position exceeds the size of the data source. We should return // Even though FFmpeg defines AVERROR_EOF, it's not to be used with I/O
// end-of-file directly. // routines. Instead return 0 for any read at or past EOF.
int64 file_size; int64 file_size;
if (data_source_->GetSize(&file_size) && read_position_ >= file_size) if (data_source_->GetSize(&file_size) && read_position_ >= file_size)
return AVERROR_EOF; return 0;
// Asynchronous read from data source. // Asynchronous read from data source.
data_source_->Read(read_position_, size, data, data_source_->Read(read_position_, size, data,
......
...@@ -682,8 +682,8 @@ TEST_F(FFmpegDemuxerTest, ProtocolRead) { ...@@ -682,8 +682,8 @@ TEST_F(FFmpegDemuxerTest, ProtocolRead) {
EXPECT_TRUE(demuxer->GetPosition(&position)); EXPECT_TRUE(demuxer->GetPosition(&position));
EXPECT_EQ(1024, position); EXPECT_EQ(1024, position);
// Third read will get an end-of-file error. // Third read will get an end-of-file error, which is represented as zero.
EXPECT_EQ(AVERROR_EOF, demuxer->Read(512, kBuffer)); EXPECT_EQ(0, demuxer->Read(512, kBuffer));
// This read complete signal is generated when demuxer is stopped. // This read complete signal is generated when demuxer is stopped.
EXPECT_CALL(*demuxer, SignalReadCompleted(DataSource::kReadError)); EXPECT_CALL(*demuxer, SignalReadCompleted(DataSource::kReadError));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment