Bug 1120023 - Fix some bugs in MockMediaResource. r=cpearce

If we don't do this, the subsequent changes to DataSourceAdapter will cause
gtest failures in TestMP4Demuxer.
This commit is contained in:
Bobby Holley 2015-01-10 02:05:28 -08:00
parent ce40739fa6
commit 7f0e239ab3
2 changed files with 7 additions and 2 deletions

View File

@ -49,7 +49,8 @@ MockMediaResource::ReadAt(int64_t aOffset, char* aBuffer, uint32_t aCount,
}
fseek(mFileHandle, aOffset, SEEK_SET);
*aBytes = (uint32_t) fread(aBuffer, aCount, 1, mFileHandle);
size_t objectsRead = fread(aBuffer, aCount, 1, mFileHandle);
*aBytes = objectsRead == 1 ? aCount : 0;
mEntry--;

View File

@ -59,8 +59,12 @@ public:
virtual nsresult ReadFromCache(char* aBuffer, int64_t aOffset,
uint32_t aCount) MOZ_OVERRIDE
{
return NS_OK;
uint32_t bytesRead = 0;
nsresult rv = ReadAt(aOffset, aBuffer, aCount, &bytesRead);
NS_ENSURE_SUCCESS(rv, rv);
return bytesRead == aCount ? NS_OK : NS_ERROR_FAILURE;
}
virtual bool IsTransportSeekable() MOZ_OVERRIDE { return true; }
virtual nsresult Open(nsIStreamListener** aStreamListener) MOZ_OVERRIDE;
virtual nsresult GetCachedRanges(nsTArray<MediaByteRange>& aRanges)