зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1374173 - Make MediaCacheStream::Seek and Read internal - r=jwwang
MozReview-Commit-ID: 9tPETuUYDrV --HG-- extra : rebase_source : d4b5371851f69eb645602b09970c04f13f44f76c
This commit is contained in:
Родитель
a17a205bc3
Коммит
07609a56a6
|
@ -2243,11 +2243,10 @@ MediaCacheStream::SetPlaybackRate(uint32_t aBytesPerSecond)
|
|||
}
|
||||
|
||||
nsresult
|
||||
MediaCacheStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
MediaCacheStream::SeekInternal(int32_t aWhence, int64_t aOffset)
|
||||
{
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
|
||||
mMediaCache->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
|
||||
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
||||
if (mClosed)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -2301,11 +2300,10 @@ MediaCacheStream::Tell()
|
|||
}
|
||||
|
||||
nsresult
|
||||
MediaCacheStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
||||
MediaCacheStream::ReadInternal(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
||||
{
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
|
||||
mMediaCache->GetReentrantMonitor().AssertCurrentThreadIn();
|
||||
|
||||
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
||||
if (mClosed)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -2374,7 +2372,7 @@ MediaCacheStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
|||
}
|
||||
|
||||
// No data has been read yet, so block
|
||||
mon.Wait();
|
||||
mMediaCache->GetReentrantMonitor().Wait();
|
||||
if (mClosed) {
|
||||
// We may have successfully read some data, but let's just throw
|
||||
// that out.
|
||||
|
@ -2419,9 +2417,9 @@ MediaCacheStream::ReadAt(int64_t aOffset, char* aBuffer,
|
|||
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
|
||||
|
||||
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
||||
nsresult rv = Seek(nsISeekableStream::NS_SEEK_SET, aOffset);
|
||||
nsresult rv = SeekInternal(nsISeekableStream::NS_SEEK_SET, aOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return Read(aBuffer, aCount, aBytes);
|
||||
return ReadInternal(aBuffer, aCount, aBytes);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -335,17 +335,12 @@ 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);
|
||||
|
||||
|
@ -439,6 +434,15 @@ private:
|
|||
// Update mPrincipal given that data has been received from aPrincipal
|
||||
bool UpdatePrincipal(nsIPrincipal* aPrincipal);
|
||||
|
||||
// This can fail when aWhence is NS_SEEK_END and no stream length
|
||||
// is known.
|
||||
nsresult SeekInternal(int32_t aWhence, 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;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче