Bug 1401471. P4 - always access mChannelOffset within the cache monitor. r=gerald
authorJW Wang <jwwang@mozilla.com>
Wed, 20 Sep 2017 16:23:21 +0800
changeset 382413 f62add4838600d2c7405eec95fc5d965161123c7
parent 382412 2682041ff5dc11fc2b25394facc674ca13b8789f
child 382414 75c688fefb300e8b2be69e33665f5e2fcf24d559
push id32558
push userkwierso@gmail.com
push dateFri, 22 Sep 2017 21:29:46 +0000
treeherdermozilla-central@61e58a7d800b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1401471
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1401471. P4 - always access mChannelOffset within the cache monitor. r=gerald MozReview-Commit-ID: KIQU3PrBUj1
dom/media/MediaCache.cpp
dom/media/MediaCache.h
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -457,17 +457,16 @@ MediaCacheStream::MediaCacheStream(Chann
                                    bool aIsPrivateBrowsing)
   : mMediaCache(nullptr)
   , mClient(aClient)
   , mDidNotifyDataEnded(false)
   , mResourceID(0)
   , mIsTransportSeekable(false)
   , mCacheSuspended(false)
   , mChannelEnded(false)
-  , mChannelOffset(0)
   , mStreamLength(-1)
   , mStreamOffset(0)
   , mPlaybackBytesPerSecond(10000)
   , mPinCount(0)
   , mCurrentMode(MODE_PLAYBACK)
   , mMetadataInPartialBlockBuffer(false)
   , mIsPrivateBrowsing(aIsPrivateBrowsing)
 {
@@ -2201,17 +2200,17 @@ MediaCacheStream::GetLength()
 {
   ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
   return mStreamLength;
 }
 
 int64_t
 MediaCacheStream::GetOffset() const
 {
-  MOZ_ASSERT(NS_IsMainThread());
+  ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
   return mChannelOffset;
 }
 
 int64_t
 MediaCacheStream::GetNextCachedData(int64_t aOffset)
 {
   ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
   return GetNextCachedDataInternal(aOffset);
--- a/dom/media/MediaCache.h
+++ b/dom/media/MediaCache.h
@@ -455,25 +455,25 @@ private:
   // The last reported seekability state for the underlying channel
   bool mIsTransportSeekable;
   // True if the cache has suspended our channel because the cache is
   // full and the priority of the data that would be received is lower
   // than the priority of the data already in the cache
   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;
 
   // 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
   // block, or -1 if the block is not cached.
   nsTArray<int32_t> mBlocks;
   // The list of read-ahead blocks, ordered by stream offset; the first
   // block is the earliest in the stream (so the last block will be the
   // least valuable).