Bug 1190258: [MSE] P3. Use actual allocated size rather than logical size when calculating eviction rate. r=gerald

This makes eviction slightly more aggressive and ensure we are actually under the memory threshold.
This commit is contained in:
Jean-Yves Avenard 2015-08-05 21:45:53 +10:00
parent 08b31d655d
commit 6937eee720
2 changed files with 8 additions and 4 deletions

View File

@ -394,6 +394,10 @@ public:
const uint8_t* Data() const { return mData; }
// Size of buffer.
size_t Size() const { return mSize; }
size_t ComputedSizeOfIncludingThis() const
{
return sizeof(*this) + mCapacity;
}
const CryptoSample& mCrypto;
nsRefPtr<MediaByteBuffer> mExtraData;

View File

@ -430,7 +430,7 @@ TrackBuffersManager::DoEvictData(const TimeUnit& aPlaybackTime,
if (frame->mTime >= lowerLimit.ToMicroseconds()) {
break;
}
partialEvict += sizeof(*frame) + frame->Size();
partialEvict += frame->ComputedSizeOfIncludingThis();
}
int64_t finalSize = mSizeSourceBuffer - aSizeToEvict;
@ -468,7 +468,7 @@ TrackBuffersManager::DoEvictData(const TimeUnit& aPlaybackTime,
if (frame->mTime <= upperLimit.ToMicroseconds()) {
break;
}
partialEvict += sizeof(*frame) + frame->Size();
partialEvict += frame->ComputedSizeOfIncludingThis();
}
if (lastKeyFrameIndex < buffer.Length()) {
MSE_DEBUG("Step2. Evicting %u bytes from trailing data",
@ -1400,7 +1400,7 @@ TrackBuffersManager::ProcessFrames(TrackBuffer& aSamples, TrackData& aTrackData)
}
samplesRange += sampleInterval;
sizeNewSamples += sizeof(*sample) + sample->Size();
sizeNewSamples += sample->ComputedSizeOfIncludingThis();
sample->mTime = sampleInterval.mStart.ToMicroseconds();
sample->mTimecode = decodeTimestamp.ToMicroseconds();
sample->mTrackInfo = trackBuffer.mLastInfo;
@ -1606,7 +1606,7 @@ TrackBuffersManager::RemoveFrames(const TimeIntervals& aIntervals,
if (sample->mDuration > maxSampleDuration) {
maxSampleDuration = sample->mDuration;
}
aTrackData.mSizeBuffer -= sizeof(*sample) + sample->Size();
aTrackData.mSizeBuffer -= sample->ComputedSizeOfIncludingThis();
}
removedIntervals.SetFuzz(TimeUnit::FromMicroseconds(maxSampleDuration));