Bug 1322087. Part 3 - allow MediaResoure::Tell() to be called on the main thread. r=cpearce
authorJW Wang <jwwang@mozilla.com>
Wed, 07 Dec 2016 03:22:32 -1000
changeset 325428 8ded70fe72120a5459451919d88602c8b86bb926
parent 325427 f988f0ed610f7194157c0825c792de963e5ff1e6
child 325429 fa4c79383dbe530bef19fe1979b8d7cc8e87561a
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerscpearce
bugs1322087
milestone53.0a1
Bug 1322087. Part 3 - allow MediaResoure::Tell() to be called on the main thread. r=cpearce It is safe to call Tell() on the main thread because it won't block the main thread like Read() does. MozReview-Commit-ID: 64B41l8fe1
dom/media/MediaCache.cpp
dom/media/MediaResource.cpp
--- a/dom/media/MediaCache.cpp
+++ b/dom/media/MediaCache.cpp
@@ -2191,18 +2191,16 @@ MediaCacheStream::Seek(int32_t aWhence, 
 
   gMediaCache->QueueUpdate();
   return NS_OK;
 }
 
 int64_t
 MediaCacheStream::Tell()
 {
-  NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
-
   ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   return mStreamOffset;
 }
 
 nsresult
 MediaCacheStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
 {
   NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -702,18 +702,16 @@ ChannelMediaResource::MediaReadAt(int64_
     curr += bytesRead;
   }
   bytes->SetLength(curr - start);
   return bytes.forget();
 }
 
 int64_t ChannelMediaResource::Tell()
 {
-  NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
-
   return mCacheStream.Tell();
 }
 
 nsresult ChannelMediaResource::GetCachedRanges(MediaByteRangeSet& aRanges)
 {
   return mCacheStream.GetCachedRanges(aRanges);
 }
 
@@ -1471,18 +1469,16 @@ nsresult FileMediaResource::UnsafeSeek(i
   if (!mSeekable)
     return NS_ERROR_FAILURE;
   EnsureSizeInitialized();
   return mSeekable->Seek(aWhence, aOffset);
 }
 
 int64_t FileMediaResource::Tell()
 {
-  NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
-
   MutexAutoLock lock(mLock);
   EnsureSizeInitialized();
 
   int64_t offset = 0;
   // Return mSize as offset (end of stream) in case of error
   if (!mSeekable || NS_FAILED(mSeekable->Tell(&offset)))
     return mSize;
   return offset;