mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1108917 - Part 2: Allow eviction of entire decoders that are ahead of the current play position. r=ajones
This commit is contained in:
parent
3073c1ec35
commit
4cdb8e73d2
@ -244,11 +244,15 @@ TrackBuffer::EvictData(uint32_t aThreshold)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get a list of initialized decoders, sorted by their start times.
|
||||
nsTArray<SourceBufferDecoder*> decoders;
|
||||
decoders.AppendElements(mInitializedDecoders);
|
||||
decoders.Sort(DecoderSorter());
|
||||
|
||||
for (uint32_t i = 0; i < decoders.Length(); ++i) {
|
||||
// First try to evict data before the current play position, starting
|
||||
// with the earliest time.
|
||||
uint32_t i = 0;
|
||||
for (; i < decoders.Length(); ++i) {
|
||||
MSE_DEBUG("TrackBuffer(%p)::EvictData decoder=%u threshold=%u toEvict=%lld",
|
||||
this, i, aThreshold, toEvict);
|
||||
toEvict -= decoders[i]->GetResource()->EvictData(toEvict);
|
||||
@ -260,6 +264,25 @@ TrackBuffer::EvictData(uint32_t aThreshold)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If we still need to evict more, then try to evict entire decoders,
|
||||
// starting from the end.
|
||||
if (toEvict > 0) {
|
||||
uint32_t end = i;
|
||||
MOZ_ASSERT(decoders[end] == mCurrentDecoder);
|
||||
|
||||
for (i = decoders.Length() - 1; i > end; --i) {
|
||||
MSE_DEBUG("TrackBuffer(%p)::EvictData removing entire decoder=%u from end toEvict=%lld",
|
||||
this, i, toEvict);
|
||||
// TODO: We could implement forward-eviction within a decoder and
|
||||
// be able to evict within the current decoder.
|
||||
toEvict -= decoders[i]->GetResource()->GetSize();
|
||||
RemoveDecoder(decoders[i]);
|
||||
if (toEvict <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return toEvict < (totalSize - aThreshold);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user