mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Discard buffer synchronously after seek before cancelling a load.
This ensures the buffer is not full when the `DefaultLoadControl` determines whether we should continue loading and thus prevents a false warning about not having enough memory left. PiperOrigin-RevId: 342616623
This commit is contained in:
parent
82969c823c
commit
5698eadc08
3 changed files with 15 additions and 0 deletions
|
|
@ -435,6 +435,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
pendingResetPositionUs = positionUs;
|
||||
loadingFinished = false;
|
||||
if (loader.isLoading()) {
|
||||
// Discard as much as we can synchronously.
|
||||
for (SampleQueue sampleQueue : sampleQueues) {
|
||||
sampleQueue.discardToEnd();
|
||||
}
|
||||
loader.cancelLoading();
|
||||
} else {
|
||||
loader.clearFatalError();
|
||||
|
|
|
|||
|
|
@ -315,6 +315,11 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
|
|||
mediaChunks.clear();
|
||||
nextNotifyPrimaryFormatMediaChunkIndex = 0;
|
||||
if (loader.isLoading()) {
|
||||
// Discard as much as we can synchronously.
|
||||
primarySampleQueue.discardToEnd();
|
||||
for (SampleQueue embeddedSampleQueue : embeddedSampleQueues) {
|
||||
embeddedSampleQueue.discardToEnd();
|
||||
}
|
||||
loader.cancelLoading();
|
||||
} else {
|
||||
loader.clearFatalError();
|
||||
|
|
|
|||
|
|
@ -490,6 +490,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
loadingFinished = false;
|
||||
mediaChunks.clear();
|
||||
if (loader.isLoading()) {
|
||||
if (sampleQueuesBuilt) {
|
||||
// Discard as much as we can synchronously.
|
||||
for (SampleQueue sampleQueue : sampleQueues) {
|
||||
sampleQueue.discardToEnd();
|
||||
}
|
||||
}
|
||||
loader.cancelLoading();
|
||||
} else {
|
||||
loader.clearFatalError();
|
||||
|
|
|
|||
Loading…
Reference in a new issue