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
--- 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;