зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 992ad9a82996 (bug 1085175) for bustage on a CLOSED TREE
This commit is contained in:
Родитель
26ed578115
Коммит
a511495141
|
@ -1173,7 +1173,6 @@ MediaCache::Update()
|
||||||
// Figure out where we should be reading from. It's the first
|
// Figure out where we should be reading from. It's the first
|
||||||
// uncached byte after the current mStreamOffset.
|
// uncached byte after the current mStreamOffset.
|
||||||
int64_t dataOffset = stream->GetCachedDataEndInternal(stream->mStreamOffset);
|
int64_t dataOffset = stream->GetCachedDataEndInternal(stream->mStreamOffset);
|
||||||
MOZ_ASSERT(dataOffset >= 0);
|
|
||||||
|
|
||||||
// Compute where we'd actually seek to to read at readOffset
|
// Compute where we'd actually seek to to read at readOffset
|
||||||
int64_t desiredOffset = dataOffset;
|
int64_t desiredOffset = dataOffset;
|
||||||
|
@ -1706,7 +1705,6 @@ MediaCacheStream::NotifyDataStarted(int64_t aOffset)
|
||||||
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
|
||||||
NS_WARN_IF_FALSE(aOffset == mChannelOffset,
|
NS_WARN_IF_FALSE(aOffset == mChannelOffset,
|
||||||
"Server is giving us unexpected offset");
|
"Server is giving us unexpected offset");
|
||||||
MOZ_ASSERT(aOffset >= 0);
|
|
||||||
mChannelOffset = aOffset;
|
mChannelOffset = aOffset;
|
||||||
if (mStreamLength >= 0) {
|
if (mStreamLength >= 0) {
|
||||||
// If we started reading at a certain offset, then for sure
|
// If we started reading at a certain offset, then for sure
|
||||||
|
@ -2136,28 +2134,23 @@ MediaCacheStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
int64_t oldOffset = mStreamOffset;
|
int64_t oldOffset = mStreamOffset;
|
||||||
int64_t newOffset = mStreamOffset;
|
|
||||||
switch (aWhence) {
|
switch (aWhence) {
|
||||||
case PR_SEEK_END:
|
case PR_SEEK_END:
|
||||||
if (mStreamLength < 0)
|
if (mStreamLength < 0)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
newOffset = mStreamLength + aOffset;
|
mStreamOffset = mStreamLength + aOffset;
|
||||||
break;
|
break;
|
||||||
case PR_SEEK_CUR:
|
case PR_SEEK_CUR:
|
||||||
newOffset += aOffset;
|
mStreamOffset += aOffset;
|
||||||
break;
|
break;
|
||||||
case PR_SEEK_SET:
|
case PR_SEEK_SET:
|
||||||
newOffset = aOffset;
|
mStreamOffset = aOffset;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
NS_ERROR("Unknown whence");
|
NS_ERROR("Unknown whence");
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newOffset < 0)
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
mStreamOffset = newOffset;
|
|
||||||
|
|
||||||
CACHE_LOG(PR_LOG_DEBUG, ("Stream %p Seek to %lld", this, (long long)mStreamOffset));
|
CACHE_LOG(PR_LOG_DEBUG, ("Stream %p Seek to %lld", this, (long long)mStreamOffset));
|
||||||
gMediaCache->NoteSeek(this, oldOffset);
|
gMediaCache->NoteSeek(this, oldOffset);
|
||||||
|
|
||||||
|
@ -2199,10 +2192,11 @@ MediaCacheStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
size = std::min(size, bytesRemaining);
|
size = std::min(size, bytesRemaining);
|
||||||
// Clamp size until 64-bit file size issues are fixed.
|
// Clamp size until 64-bit file size issues (bug 500784) are fixed.
|
||||||
size = std::min(size, int64_t(INT32_MAX));
|
size = std::min(size, int64_t(INT32_MAX));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t bytes;
|
||||||
int32_t cacheBlock = streamBlock < mBlocks.Length() ? mBlocks[streamBlock] : -1;
|
int32_t cacheBlock = streamBlock < mBlocks.Length() ? mBlocks[streamBlock] : -1;
|
||||||
if (cacheBlock < 0) {
|
if (cacheBlock < 0) {
|
||||||
// We don't have a complete cached block here.
|
// We don't have a complete cached block here.
|
||||||
|
@ -2230,10 +2224,7 @@ MediaCacheStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
||||||
// We can just use the data in mPartialBlockBuffer. In fact we should
|
// We can just use the data in mPartialBlockBuffer. In fact we should
|
||||||
// use it rather than waiting for the block to fill and land in
|
// use it rather than waiting for the block to fill and land in
|
||||||
// the cache.
|
// the cache.
|
||||||
int64_t bytes = std::min<int64_t>(size, streamWithPartialBlock->mChannelOffset - mStreamOffset);
|
bytes = std::min<int64_t>(size, streamWithPartialBlock->mChannelOffset - mStreamOffset);
|
||||||
// Clamp bytes until 64-bit file size issues are fixed.
|
|
||||||
bytes = std::min(bytes, int64_t(INT32_MAX));
|
|
||||||
NS_ABORT_IF_FALSE(bytes >= 0 && bytes <= aCount, "Bytes out of range.");
|
|
||||||
memcpy(aBuffer,
|
memcpy(aBuffer,
|
||||||
reinterpret_cast<char*>(streamWithPartialBlock->mPartialBlockBuffer.get()) + offsetInStreamBlock, bytes);
|
reinterpret_cast<char*>(streamWithPartialBlock->mPartialBlockBuffer.get()) + offsetInStreamBlock, bytes);
|
||||||
if (mCurrentMode == MODE_METADATA) {
|
if (mCurrentMode == MODE_METADATA) {
|
||||||
|
@ -2257,7 +2248,6 @@ MediaCacheStream::Read(char* aBuffer, uint32_t aCount, uint32_t* aBytes)
|
||||||
gMediaCache->NoteBlockUsage(this, cacheBlock, mCurrentMode, TimeStamp::Now());
|
gMediaCache->NoteBlockUsage(this, cacheBlock, mCurrentMode, TimeStamp::Now());
|
||||||
|
|
||||||
int64_t offset = cacheBlock*BLOCK_SIZE + offsetInStreamBlock;
|
int64_t offset = cacheBlock*BLOCK_SIZE + offsetInStreamBlock;
|
||||||
int32_t bytes;
|
|
||||||
NS_ABORT_IF_FALSE(size >= 0 && size <= INT32_MAX, "Size out of range.");
|
NS_ABORT_IF_FALSE(size >= 0 && size <= INT32_MAX, "Size out of range.");
|
||||||
nsresult rv = gMediaCache->ReadCacheFile(offset, aBuffer + count, int32_t(size), &bytes);
|
nsresult rv = gMediaCache->ReadCacheFile(offset, aBuffer + count, int32_t(size), &bytes);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
@ -2294,7 +2284,9 @@ MediaCacheStream::ReadAt(int64_t aOffset, char* aBuffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
MediaCacheStream::ReadFromCache(char* aBuffer, int64_t aOffset, int64_t aCount)
|
MediaCacheStream::ReadFromCache(char* aBuffer,
|
||||||
|
int64_t aOffset,
|
||||||
|
int64_t aCount)
|
||||||
{
|
{
|
||||||
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
|
ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
|
||||||
if (mClosed)
|
if (mClosed)
|
||||||
|
@ -2316,7 +2308,7 @@ MediaCacheStream::ReadFromCache(char* aBuffer, int64_t aOffset, int64_t aCount)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
size = std::min(size, bytesRemaining);
|
size = std::min(size, bytesRemaining);
|
||||||
// Clamp size until 64-bit file size issues are fixed.
|
// Clamp size until 64-bit file size issues (bug 500784) are fixed.
|
||||||
size = std::min(size, int64_t(INT32_MAX));
|
size = std::min(size, int64_t(INT32_MAX));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2327,10 +2319,7 @@ MediaCacheStream::ReadFromCache(char* aBuffer, int64_t aOffset, int64_t aCount)
|
||||||
// We can just use the data in mPartialBlockBuffer. In fact we should
|
// We can just use the data in mPartialBlockBuffer. In fact we should
|
||||||
// use it rather than waiting for the block to fill and land in
|
// use it rather than waiting for the block to fill and land in
|
||||||
// the cache.
|
// the cache.
|
||||||
// Clamp bytes until 64-bit file size issues are fixed.
|
bytes = std::min<int64_t>(size, mChannelOffset - streamOffset);
|
||||||
int64_t toCopy = std::min<int64_t>(size, mChannelOffset - streamOffset);
|
|
||||||
bytes = std::min(toCopy, int64_t(INT32_MAX));
|
|
||||||
NS_ABORT_IF_FALSE(bytes >= 0 && bytes <= toCopy, "Bytes out of range.");
|
|
||||||
memcpy(aBuffer + count,
|
memcpy(aBuffer + count,
|
||||||
reinterpret_cast<char*>(mPartialBlockBuffer.get()) + offsetInStreamBlock, bytes);
|
reinterpret_cast<char*>(mPartialBlockBuffer.get()) + offsetInStreamBlock, bytes);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
typedef __int64 int64_t;
|
typedef __int64 int64_t;
|
||||||
typedef unsigned __int64 uint64_t;
|
typedef unsigned __int64 uint64_t;
|
||||||
#define INT64_MAX 9223372036854775807LL
|
|
||||||
#else
|
#else
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2106,9 +2106,6 @@ nestegg_offset_seek(nestegg * ctx, uint64_t offset)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (offset > INT64_MAX)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* Seek and set up parser state for segment-level element (Cluster). */
|
/* Seek and set up parser state for segment-level element (Cluster). */
|
||||||
r = ne_io_seek(ctx->io, offset, NESTEGG_SEEK_SET);
|
r = ne_io_seek(ctx->io, offset, NESTEGG_SEEK_SET);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче