Rollback of 7e6236cfdb
*** Original commit ***
Rollback of fc539da061
*** Original commit ***
Release SequenceAssetLoader when ended
Before, the SequenceAssetLoader was released at the end of the export.
Release resources earlier if possible.
***
***
PiperOrigin-RevId: 520036433
This commit is contained in:
parent
24a164827e
commit
1dbb19a44c
@ -94,6 +94,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
private boolean audioLoopingEnded;
|
private boolean audioLoopingEnded;
|
||||||
private boolean videoLoopingEnded;
|
private boolean videoLoopingEnded;
|
||||||
private int processedInputsSize;
|
private int processedInputsSize;
|
||||||
|
private boolean released;
|
||||||
|
|
||||||
private volatile long currentAssetDurationUs;
|
private volatile long currentAssetDurationUs;
|
||||||
|
|
||||||
@ -165,7 +166,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release() {
|
public void release() {
|
||||||
currentAssetLoader.release();
|
if (!released) {
|
||||||
|
currentAssetLoader.release();
|
||||||
|
released = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -368,13 +372,15 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
long globalTimestampUs = totalDurationUs + inputBuffer.timeUs - currentAssetStartTimeUs;
|
long globalTimestampUs = totalDurationUs + inputBuffer.timeUs - currentAssetStartTimeUs;
|
||||||
if (isLooping && globalTimestampUs >= maxSequenceDurationUs) {
|
if (isLooping && globalTimestampUs >= maxSequenceDurationUs) {
|
||||||
if (isMaxSequenceDurationUsFinal && !audioLoopingEnded) {
|
if (isMaxSequenceDurationUsFinal && !audioLoopingEnded) {
|
||||||
nonEndedTracks.decrementAndGet();
|
|
||||||
checkNotNull(inputBuffer.data).limit(0);
|
checkNotNull(inputBuffer.data).limit(0);
|
||||||
inputBuffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
|
inputBuffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
|
||||||
// We know that queueInputBuffer() will always return true for the underlying
|
// We know that queueInputBuffer() will always return true for the underlying
|
||||||
// SampleConsumer so there is no need to handle the case where the sample wasn't queued.
|
// SampleConsumer so there is no need to handle the case where the sample wasn't queued.
|
||||||
checkState(sampleConsumer.queueInputBuffer());
|
checkState(sampleConsumer.queueInputBuffer());
|
||||||
audioLoopingEnded = true;
|
audioLoopingEnded = true;
|
||||||
|
if (nonEndedTracks.decrementAndGet() == 0) {
|
||||||
|
release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -387,8 +393,13 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
if (nonEndedTracks.get() == 0) {
|
if (nonEndedTracks.get() == 0) {
|
||||||
switchAssetLoader();
|
switchAssetLoader();
|
||||||
}
|
}
|
||||||
return true;
|
} else {
|
||||||
|
checkState(sampleConsumer.queueInputBuffer());
|
||||||
|
if (nonEndedTracks.get() == 0) {
|
||||||
|
release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkState(sampleConsumer.queueInputBuffer());
|
checkState(sampleConsumer.queueInputBuffer());
|
||||||
@ -448,13 +459,17 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void signalEndOfVideoInput() {
|
public void signalEndOfVideoInput() {
|
||||||
nonEndedTracks.decrementAndGet();
|
|
||||||
boolean videoEnded =
|
boolean videoEnded =
|
||||||
isLooping ? videoLoopingEnded : currentMediaItemIndex == editedMediaItems.size() - 1;
|
isLooping ? videoLoopingEnded : currentMediaItemIndex == editedMediaItems.size() - 1;
|
||||||
if (videoEnded) {
|
if (videoEnded) {
|
||||||
sampleConsumer.signalEndOfVideoInput();
|
sampleConsumer.signalEndOfVideoInput();
|
||||||
} else if (nonEndedTracks.get() == 0) {
|
}
|
||||||
switchAssetLoader();
|
if (nonEndedTracks.decrementAndGet() == 0) {
|
||||||
|
if (videoEnded) {
|
||||||
|
release();
|
||||||
|
} else {
|
||||||
|
switchAssetLoader();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,5 +494,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
currentAssetLoader.start();
|
currentAssetLoader.start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void release() {
|
||||||
|
handler.post(SequenceAssetLoader.this::release);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user