Bug 1401471. P3 - store the seek target in StreamAction so we won't need to read mChannelOffset outside the cache monitor.
MozReview-Commit-ID: Kkbs3WbSBVm
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -1134,16 +1134,17 @@ MediaCache::Update()
{
NONE,
SEEK,
RESUME,
SUSPEND
} mTag = NONE;
// Members for 'SEEK' only.
bool mResume = false;
+ int64_t mSeekTarget = -1;
};
// The action to use for each stream. We store these so we can make
// decisions while holding the cache lock but implement those decisions
// without holding the cache lock, since we need to call out to
// stream, decoder and element code.
AutoTArray<StreamAction,10> actions;
@@ -1396,16 +1397,17 @@ MediaCache::Update()
"Trying to seek in a non-seekable stream!");
// Round seek offset down to the start of the block. This is essential
// because we don't want to think we have part of a block already
// in mPartialBlockBuffer.
stream->mChannelOffset =
OffsetToBlockIndexUnchecked(desiredOffset) * BLOCK_SIZE;
actions[i].mTag = StreamAction::SEEK;
actions[i].mResume = stream->mCacheSuspended;
+ actions[i].mSeekTarget = stream->mChannelOffset;
// mChannelOffset is updated to a new position. We don't want data from
// the old channel to be written to the wrong position. 0 is a sentinel
// value which will not match any ID passed to NotifyDataReceived().
stream->mLoadID = 0;
} else if (enableReading && stream->mCacheSuspended) {
actions[i].mTag = StreamAction::RESUME;
} else if (!enableReading && !stream->mCacheSuspended) {
actions[i].mTag = StreamAction::SUSPEND;
@@ -1447,19 +1449,19 @@ MediaCache::Update()
for (uint32_t i = 0; i < mStreams.Length(); ++i) {
MediaCacheStream* stream = mStreams[i];
nsresult rv;
switch (actions[i].mTag) {
case StreamAction::SEEK:
LOG("Stream %p CacheSeek to %" PRId64 " (resume=%d)",
stream,
- stream->mChannelOffset,
+ actions[i].mSeekTarget,
actions[i].mResume);
- rv = stream->mClient->CacheClientSeek(stream->mChannelOffset,
+ rv = stream->mClient->CacheClientSeek(actions[i].mSeekTarget,
actions[i].mResume);
break;
case StreamAction::RESUME:
LOG("Stream %p Resumed", stream);
rv = stream->mClient->CacheClientResume();
QueueSuspendedStatusUpdate(stream->mResourceID);
break;
case StreamAction::SUSPEND: