Bug 585864 - Increase media cache block size from 4kB to 32kB. r=roc a=roc

This commit is contained in:
Matthew Gregan 2010-08-13 12:41:47 +12:00
Родитель 2b46cf4152
Коммит 2a7633fa12
4 изменённых файлов: 18 добавлений и 2 удалений

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

@ -1204,11 +1204,13 @@ nsMediaCache::Update()
for (PRUint32 j = 0; j < i; ++j) {
nsMediaCacheStream* other = mStreams[j];
if (other->mResourceID == stream->mResourceID &&
!other->mCacheSuspended &&
!other->mClient->IsSuspended() &&
other->mChannelOffset/BLOCK_SIZE == desiredOffset/BLOCK_SIZE) {
// This block is already going to be read by the other stream.
// So don't try to read it from this stream as well.
enableReading = PR_FALSE;
LOG(PR_LOG_DEBUG, ("Stream %p waiting on same block (%lld) from stream %p",
stream, desiredOffset/BLOCK_SIZE, other));
break;
}
}
@ -1451,6 +1453,9 @@ nsMediaCache::OpenStream(nsMediaCacheStream* aStream)
LOG(PR_LOG_DEBUG, ("Stream %p opened", aStream));
mStreams.AppendElement(aStream);
aStream->mResourceID = mNextResourceID++;
// Queue an update since a new stream has been opened.
gMediaCache->QueueUpdate();
}
void

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

@ -210,7 +210,7 @@ class nsMediaCacheStream {
public:
enum {
// This needs to be a power of two
BLOCK_SIZE = 4096
BLOCK_SIZE = 32768
};
enum ReadMode {
MODE_METADATA,

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

@ -804,6 +804,13 @@ nsMediaChannelStream::IsSuspendedByCache()
return mCacheSuspendCount > 0;
}
PRBool
nsMediaChannelStream::IsSuspended()
{
nsAutoLock lock(mLock);
return mSuspendCount > 0;
}
void
nsMediaChannelStream::SetReadMode(nsMediaCacheStream::ReadMode aMode)
{
@ -891,6 +898,7 @@ public:
virtual PRInt64 GetCachedDataEnd(PRInt64 aOffset) { return PR_MAX(aOffset, mSize); }
virtual PRBool IsDataCachedToEndOfStream(PRInt64 aOffset) { return PR_TRUE; }
virtual PRBool IsSuspendedByCache() { return PR_FALSE; }
virtual PRBool IsSuspended() { return PR_FALSE; }
private:
// The file size, or -1 if not known. Immutable after Open().

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

@ -251,6 +251,8 @@ public:
// nsMediaDecoder::NotifySuspendedStatusChanged is called when this
// changes.
virtual PRBool IsSuspendedByCache() = 0;
// Returns true if this stream has been suspended.
virtual PRBool IsSuspended() = 0;
// Reads only data which is cached in the media cache. If you try to read
// any data which overlaps uncached data, or if aCount bytes otherwise can't
// be read, this function will return failure. This function be called from
@ -366,6 +368,7 @@ public:
virtual PRInt64 GetCachedDataEnd(PRInt64 aOffset);
virtual PRBool IsDataCachedToEndOfStream(PRInt64 aOffset);
virtual PRBool IsSuspendedByCache();
virtual PRBool IsSuspended();
class Listener : public nsIStreamListener,
public nsIInterfaceRequestor,