зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1374441 - Backed out bug 1374173 (MediaCacheStream Seek&Read refactoring) - r=jwwang
Bug 1374173 seems to be the cause of all MediaCache intermittent assertion failures. It's not an important bug, so let's back-out and verify that intermittents disappear. MozReview-Commit-ID: 2X8iW1hWu99 --HG-- extra : rebase_source : e22443a5b9d5ba9a6ce4b126953a880e8e469cd2
This commit is contained in:
Родитель
35931ba727
Коммит
3faa7098b0
|
@ -2243,20 +2243,36 @@ MediaCacheStream::SetPlaybackRate(uint32_t aBytesPerSecond)
|
|||
}
|
||||
|
||||
nsresult
|
||||
MediaCacheStream::SeekInternal(int64_t aOffset)
|
||||
MediaCacheStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
{
|
||||
if (aOffset < 0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
|
||||
|
||||
mMediaCache->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
|
||||
if (mClosed) {
|
||||
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
||||
if (mClosed)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
int64_t oldOffset = mStreamOffset;
|
||||
mStreamOffset = aOffset;
|
||||
int64_t newOffset = mStreamOffset;
|
||||
switch (aWhence) {
|
||||
case PR_SEEK_END:
|
||||
if (mStreamLength < 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
newOffset = mStreamLength + aOffset;
|
||||
break;
|
||||
case PR_SEEK_CUR:
|
||||
newOffset += aOffset;
|
||||
break;
|
||||
case PR_SEEK_SET:
|
||||
newOffset = aOffset;
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("Unknown whence");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (newOffset < 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
mStreamOffset = newOffset;
|
||||
|
||||
LOG("Stream %p Seek to %" PRId64, this, mStreamOffset);
|
||||
mMediaCache->NoteSeek(this, oldOffset);
|
||||
|
@ -2285,10 +2301,11 @@ MediaCacheStream::Tell()
|
|||
}
|
||||
|
||||
nsresult
|
||||
MediaCacheStream::ReadInternal(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
||||
MediaCacheStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
||||
{
|
||||
mMediaCache->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
|
||||
|
||||
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
||||
if (mClosed)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -2357,7 +2374,7 @@ MediaCacheStream::ReadInternal(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
|||
}
|
||||
|
||||
// No data has been read yet, so block
|
||||
mMediaCache->GetReentrantMonitor().Wait();
|
||||
mon.Wait();
|
||||
if (mClosed) {
|
||||
// We may have successfully read some data, but let's just throw
|
||||
// that out.
|
||||
|
@ -2402,9 +2419,9 @@ MediaCacheStream::ReadAt(int64_t aOffset, char* aBuffer,
|
|||
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
|
||||
|
||||
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
||||
nsresult rv = SeekInternal(aOffset);
|
||||
nsresult rv = Seek(nsISeekableStream::NS_SEEK_SET, aOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return ReadInternal(aBuffer, aCount, aBytes);
|
||||
return Read(aBuffer, aCount, aBytes);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -335,12 +335,17 @@ 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.
|
||||
// This can fail when aWhence is NS_SEEK_END and no stream length
|
||||
// is known.
|
||||
nsresult Seek(int32_t aWhence, int64_t aOffset);
|
||||
int64_t Tell();
|
||||
// Seeks to aOffset in the stream then performs a Read operation.
|
||||
// *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,
|
||||
// this will block until the data is available or the stream is
|
||||
// closed, otherwise it won't block.
|
||||
nsresult Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes);
|
||||
// Seeks to aOffset in the stream then performs a Read operation. See
|
||||
// 'Read' for argument and return details.
|
||||
nsresult ReadAt(int64_t aOffset, char* aBuffer,
|
||||
uint32_t aCount, uint32_t* aBytes);
|
||||
|
||||
|
@ -434,13 +439,6 @@ private:
|
|||
// Update mPrincipal given that data has been received from aPrincipal
|
||||
bool UpdatePrincipal(nsIPrincipal* aPrincipal);
|
||||
|
||||
nsresult SeekInternal(int64_t aOffset);
|
||||
// *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,
|
||||
// this will block until the data is available or the stream is
|
||||
// closed, otherwise it won't block.
|
||||
nsresult ReadInternal(char* aBuffer, uint32_t aCount, uint32_t* aBytes);
|
||||
|
||||
// Instance of MediaCache to use with this MediaCacheStream.
|
||||
RefPtr<MediaCache> mMediaCache;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче