Bug 1358726 - fix the assertion failure in AllocateAndWriteBlock().
block->mOwners might be empty if all streams for the resource id are
closed. We don't bother write the data to the cache since there is no
stream to use it.
MozReview-Commit-ID: KKiyZqLBjim
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -1525,16 +1525,22 @@ MediaCache::AllocateAndWriteBlock(
if (!bo) {
// Roll back mOwners if any allocation fails.
block->mOwners.Clear();
return;
}
bo->mStream = stream;
}
+ if (block->mOwners.IsEmpty()) {
+ // This happens when all streams with the resource id are closed. We can
+ // just return here now and discard the data.
+ return;
+ }
+
// Tell each stream using this resource about the new block.
for (auto& bo : block->mOwners) {
bo.mStreamBlock = streamBlockIndex;
bo.mLastUseTime = now;
bo.mStream->mBlocks[streamBlockIndex] = blockIndex;
if (streamBlockIndex*BLOCK_SIZE < bo.mStream->mStreamOffset) {
bo.mClass = aMode == MediaCacheStream::MODE_PLAYBACK ? PLAYED_BLOCK
: METADATA_BLOCK;