mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-06 00:10:25 +00:00
Bug 1216460 - [1.1] Refactor data types, fix logs and prevent harmful type promotions in SourceBuffer eviction handling. r=jya
This commit is contained in:
parent
cbc3ebad39
commit
39faf25691
@ -70,7 +70,7 @@ public:
|
||||
// eviction.
|
||||
virtual EvictDataResult
|
||||
EvictData(media::TimeUnit aPlaybackTime,
|
||||
uint32_t aThreshold,
|
||||
int64_t aThreshold,
|
||||
media::TimeUnit* aBufferStartTime) = 0;
|
||||
|
||||
// Evicts data up to aTime.
|
||||
|
@ -134,7 +134,7 @@ SourceBufferResource::ReadFromCache(char* aBuffer, int64_t aOffset, uint32_t aCo
|
||||
}
|
||||
|
||||
uint32_t
|
||||
SourceBufferResource::EvictData(uint64_t aPlaybackOffset, uint32_t aThreshold,
|
||||
SourceBufferResource::EvictData(uint64_t aPlaybackOffset, int64_t aThreshold,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
SBR_DEBUG("EvictData(aPlaybackOffset=%llu,"
|
||||
|
@ -113,7 +113,7 @@ public:
|
||||
}
|
||||
// Remove data from resource if it holds more than the threshold
|
||||
// number of bytes. Returns amount evicted.
|
||||
uint32_t EvictData(uint64_t aPlaybackOffset, uint32_t aThreshold,
|
||||
uint32_t EvictData(uint64_t aPlaybackOffset, int64_t aThreshold,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Remove data from resource before the given offset.
|
||||
|
@ -198,7 +198,7 @@ TrackBuffersManager::RangeRemoval(TimeUnit aStart, TimeUnit aEnd)
|
||||
|
||||
TrackBuffersManager::EvictDataResult
|
||||
TrackBuffersManager::EvictData(TimeUnit aPlaybackTime,
|
||||
uint32_t aThreshold,
|
||||
int64_t aThresholdReduct,
|
||||
TimeUnit* aBufferStartTime)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
@ -353,7 +353,7 @@ TrackBuffersManager::CompleteResetParserState()
|
||||
|
||||
void
|
||||
TrackBuffersManager::DoEvictData(const TimeUnit& aPlaybackTime,
|
||||
uint32_t aSizeToEvict)
|
||||
int64_t aSizeToEvict)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
|
||||
@ -365,7 +365,7 @@ TrackBuffersManager::DoEvictData(const TimeUnit& aPlaybackTime,
|
||||
TimeUnit lowerLimit = std::min(track.mNextSampleTime, aPlaybackTime);
|
||||
uint32_t lastKeyFrameIndex = 0;
|
||||
int64_t toEvict = aSizeToEvict;
|
||||
uint32_t partialEvict = 0;
|
||||
int64_t partialEvict = 0;
|
||||
for (uint32_t i = 0; i < buffer.Length(); i++) {
|
||||
const auto& frame = buffer[i];
|
||||
if (frame->mKeyframe) {
|
||||
@ -382,17 +382,16 @@ TrackBuffersManager::DoEvictData(const TimeUnit& aPlaybackTime,
|
||||
partialEvict += frame->ComputedSizeOfIncludingThis();
|
||||
}
|
||||
|
||||
int64_t finalSize = mSizeSourceBuffer - aSizeToEvict;
|
||||
|
||||
if (lastKeyFrameIndex > 0) {
|
||||
MSE_DEBUG("Step1. Evicting %u bytes prior currentTime",
|
||||
MSE_DEBUG("Step1. Evicting %lld bytes prior currentTime",
|
||||
aSizeToEvict - toEvict);
|
||||
CodedFrameRemoval(
|
||||
TimeInterval(TimeUnit::FromMicroseconds(0),
|
||||
TimeUnit::FromMicroseconds(buffer[lastKeyFrameIndex]->mTime - 1)));
|
||||
}
|
||||
|
||||
if (mSizeSourceBuffer <= finalSize) {
|
||||
const int64_t finalSize = mSizeSourceBuffer - aSizeToEvict;
|
||||
if (mSizeSourceBuffer <= finalSize || !buffer.Length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -415,8 +414,8 @@ TrackBuffersManager::DoEvictData(const TimeUnit& aPlaybackTime,
|
||||
toEvict -= frame->ComputedSizeOfIncludingThis();
|
||||
}
|
||||
if (evictedFramesStartIndex < buffer.Length()) {
|
||||
MSE_DEBUG("Step2. Evicting %u bytes from trailing data",
|
||||
mSizeSourceBuffer - finalSize);
|
||||
MSE_DEBUG("Step2. Evicting %lld bytes from trailing data",
|
||||
mSizeSourceBuffer - finalSize - toEvict);
|
||||
CodedFrameRemoval(
|
||||
TimeInterval(TimeUnit::FromMicroseconds(buffer[evictedFramesStartIndex]->mTime),
|
||||
TimeUnit::FromInfinity()));
|
||||
@ -1630,7 +1629,7 @@ TrackBuffersManager::RemoveFrames(const TimeIntervals& aIntervals,
|
||||
{
|
||||
TrackBuffer& data = aTrackData.mBuffers.LastElement();
|
||||
Maybe<uint32_t> firstRemovedIndex;
|
||||
uint32_t lastRemovedIndex;
|
||||
uint32_t lastRemovedIndex = 0;
|
||||
|
||||
// We loop from aStartIndex to avoid removing frames that we inserted earlier
|
||||
// and part of the current coded frame group. This is allows to handle step
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
|
||||
EvictDataResult
|
||||
EvictData(media::TimeUnit aPlaybackTime,
|
||||
uint32_t aThreshold,
|
||||
int64_t aThresholdReduct,
|
||||
media::TimeUnit* aBufferStartTime) override;
|
||||
|
||||
void EvictBefore(media::TimeUnit aTime) override;
|
||||
@ -200,7 +200,7 @@ private:
|
||||
OnDemuxFailed(TrackType::kAudioTrack, aFailure);
|
||||
}
|
||||
|
||||
void DoEvictData(const media::TimeUnit& aPlaybackTime, uint32_t aThreshold);
|
||||
void DoEvictData(const media::TimeUnit& aPlaybackTime, int64_t aThreshold);
|
||||
|
||||
struct TrackData {
|
||||
TrackData()
|
||||
|
Loading…
Reference in New Issue
Block a user