Bug 1361964 - WebMBufferedState::UpdateIndex() should read from cache. r=jya

We don't want to trigger download when calculating buffer ranges since download
changes buffer ranges.

MozReview-Commit-ID: Be8qFUQ5PpR

--HG--
extra : rebase_source : 4fd77e031577332d9d112faef869cd935275b1af
This commit is contained in:
JW Wang 2017-05-04 21:32:13 +08:00
Родитель 96151b2b6b
Коммит 240b996f12
2 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -242,6 +242,17 @@ public:
return bytes.forget();
}
already_AddRefed<MediaByteBuffer> CachedReadAt(int64_t aOffset, uint32_t aCount)
{
RefPtr<MediaByteBuffer> bytes = new MediaByteBuffer();
bool ok = bytes->SetLength(aCount, fallible);
NS_ENSURE_TRUE(ok, nullptr);
char* curr = reinterpret_cast<char*>(bytes->Elements());
nsresult rv = ReadFromCache(curr, aOffset, aCount);
NS_ENSURE_SUCCESS(rv, nullptr);
return bytes.forget();
}
// Report the current offset in bytes from the start of the stream.
// This is used to approximate where we currently are in the playback of a
// media.

Просмотреть файл

@ -449,7 +449,7 @@ void WebMBufferedState::UpdateIndex(const MediaByteRangeSet& aRanges, MediaResou
while (length > 0) {
static const uint32_t BLOCK_SIZE = 1048576;
uint32_t block = std::min(length, BLOCK_SIZE);
RefPtr<MediaByteBuffer> bytes = aResource->MediaReadAt(offset, block);
RefPtr<MediaByteBuffer> bytes = aResource->CachedReadAt(offset, block);
if (!bytes) {
break;
}