Bug 1415766. P2 - move Seek() to private and tighten up some assertions. r=bechen,gerald

MozReview-Commit-ID: BBsXqKUrOi1

--HG--
extra : rebase_source : 1b785f50254ba824037b983896fc40e91eff801a
extra : intermediate-source : 6971ed66e78c4e1956bf0e382a04c1c8816dbaf8
extra : source : 6590c3f4691e9730858689839a5eb7b7143ceafb
This commit is contained in:
JW Wang 2017-11-02 14:46:24 +08:00
Родитель cd5164d38d
Коммит c51610e0e4
2 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -2415,18 +2415,18 @@ MediaCacheStream::SetPlaybackRate(uint32_t aBytesPerSecond)
nsresult
MediaCacheStream::Seek(int64_t aOffset)
{
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
MOZ_ASSERT(!NS_IsMainThread());
mMediaCache->GetReentrantMonitor().AssertCurrentThreadIn();
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
if (!IsOffsetAllowed(aOffset)) {
return NS_ERROR_ILLEGAL_VALUE;
}
if (mClosed) {
return NS_ERROR_FAILURE;
return NS_ERROR_ABORT;
}
int64_t oldOffset = mStreamOffset;
int64_t newOffset = aOffset;
if (!IsOffsetAllowed(newOffset)) {
return NS_ERROR_FAILURE;
}
mStreamOffset = newOffset;
mStreamOffset = aOffset;
LOG("Stream %p Seek to %" PRId64, this, mStreamOffset);
mMediaCache->NoteSeek(this, oldOffset);
mMediaCache->QueueUpdate();

Просмотреть файл

@ -339,7 +339,6 @@ public:
// These methods must be called on a different thread from the main
// thread. They should always be called on the same thread for a given
// stream.
nsresult Seek(int64_t aOffset);
int64_t Tell();
// *aBytes gets the number of bytes that were actually read. This can
// be less than aCount. If the first byte of data is not in the cache,
@ -433,6 +432,9 @@ private:
Result<uint32_t, nsresult> ReadBlockFromCache(int64_t aOffset,
Span<char> aBuffer);
// Non-main thread only.
nsresult Seek(int64_t aOffset);
// Returns the end of the bytes starting at the given offset
// which are in cache.
// This method assumes that the cache monitor is held and can be called on