зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1415766. P1 - we never pass anything other than NS_SEEK_SET to Seek(). r=bechen,gerald
MozReview-Commit-ID: AgvapCwwSpr --HG-- extra : rebase_source : 2ba05b44f228c3d9a9440202c024abbd5487282f extra : intermediate-source : f2ec0fec7c544171e7567beed322349dfb8e59a8 extra : source : 8e34a87b250f800897a761d2ccd408959007d02b
This commit is contained in:
Родитель
f9f14101f3
Коммит
cd5164d38d
|
@ -25,7 +25,6 @@
|
|||
#include "nsContentUtils.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrincipal.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
@ -2414,41 +2413,22 @@ MediaCacheStream::SetPlaybackRate(uint32_t aBytesPerSecond)
|
|||
}
|
||||
|
||||
nsresult
|
||||
MediaCacheStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
MediaCacheStream::Seek(int64_t aOffset)
|
||||
{
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
|
||||
|
||||
ReentrantMonitorAutoEnter mon(mMediaCache->GetReentrantMonitor());
|
||||
if (mClosed)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
int64_t oldOffset = mStreamOffset;
|
||||
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");
|
||||
if (mClosed) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
int64_t oldOffset = mStreamOffset;
|
||||
int64_t newOffset = aOffset;
|
||||
if (!IsOffsetAllowed(newOffset)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mStreamOffset = newOffset;
|
||||
|
||||
LOG("Stream %p Seek to %" PRId64, this, mStreamOffset);
|
||||
mMediaCache->NoteSeek(this, oldOffset);
|
||||
|
||||
mMediaCache->QueueUpdate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2669,7 +2649,7 @@ 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 = Seek(aOffset);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return Read(aBuffer, aCount, aBytes);
|
||||
}
|
||||
|
|
|
@ -339,9 +339,7 @@ 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);
|
||||
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,
|
||||
|
|
Загрузка…
Ссылка в новой задаче