From eace06432d8fe8ef57417063c5f61ff78cc745eb Mon Sep 17 00:00:00 2001 From: JW Wang Date: Wed, 20 Sep 2017 16:23:21 +0800 Subject: [PATCH] Bug 1401471. P4 - always access mChannelOffset within the cache monitor. r=gerald MozReview-Commit-ID: KIQU3PrBUj1 --HG-- extra : rebase_source : 8984d39f5b0b29fe3233c96e5431e8641dd918fd extra : source : 8f07a48d4ac13162add83cce8677322e148d6f74 --- dom/media/MediaCache.cpp | 3 +-- dom/media/MediaCache.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dom/media/MediaCache.cpp b/dom/media/MediaCache.cpp index 83ae2e6fdb49..cc85b4b9f139 100644 --- a/dom/media/MediaCache.cpp +++ b/dom/media/MediaCache.cpp @@ -462,7 +462,6 @@ MediaCacheStream::MediaCacheStream(ChannelMediaResource* aClient, , mIsTransportSeekable(false) , mCacheSuspended(false) , mChannelEnded(false) - , mChannelOffset(0) , mStreamLength(-1) , mStreamOffset(0) , mPlaybackBytesPerSecond(10000) @@ -2206,7 +2205,7 @@ MediaCacheStream::GetLength() int64_t MediaCacheStream::GetOffset() const { - MOZ_ASSERT(NS_IsMainThread()); + ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor()); return mChannelOffset; } diff --git a/dom/media/MediaCache.h b/dom/media/MediaCache.h index 8fe2d5d75f03..fbb4c8045f9f 100644 --- a/dom/media/MediaCache.h +++ b/dom/media/MediaCache.h @@ -460,8 +460,6 @@ private: bool mCacheSuspended; // True if the channel ended and we haven't seeked it again. bool mChannelEnded; - // The offset where the next data from the channel will arrive - int64_t mChannelOffset; // The reported or discovered length of the data, or -1 if nothing is // known int64_t mStreamLength; @@ -469,6 +467,8 @@ private: // The following fields are protected by the cache's monitor can can be written // by any thread. + // The offset where the next data from the channel will arrive + int64_t mChannelOffset = 0; // The offset where the reader is positioned in the stream int64_t mStreamOffset; // For each block in the stream data, maps to the cache entry for the