mirror of
https://github.com/androidx/media.git
synced 2025-04-29 22:36:54 +08:00
Handle RawAssetLoader feeding data while Transformer is being ended
PiperOrigin-RevId: 743017931
This commit is contained in:
parent
cf3faf9cff
commit
c8a34ec846
@ -520,6 +520,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
||||
|
||||
private volatile @MonotonicNonNull FrameInfo nextInputFrameInfo;
|
||||
private volatile boolean inputStreamEnded;
|
||||
private volatile boolean released;
|
||||
|
||||
private DefaultVideoFrameProcessor(
|
||||
Context context,
|
||||
@ -613,7 +614,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
||||
@Override
|
||||
public boolean queueInputBitmap(Bitmap inputBitmap, TimestampIterator timestampIterator) {
|
||||
checkState(!inputStreamEnded);
|
||||
if (!inputStreamRegisteredCondition.isOpen()) {
|
||||
if (!inputStreamRegisteredCondition.isOpen() || released) {
|
||||
return false;
|
||||
}
|
||||
if (ColorInfo.isTransferHdr(outputColorInfo)) {
|
||||
@ -633,7 +634,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
||||
@Override
|
||||
public boolean queueInputTexture(int textureId, long presentationTimeUs) {
|
||||
checkState(!inputStreamEnded);
|
||||
if (!inputStreamRegisteredCondition.isOpen()) {
|
||||
if (!inputStreamRegisteredCondition.isOpen() || released) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -714,6 +715,9 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
||||
@Override
|
||||
public void registerInputStream(
|
||||
@InputType int inputType, Format format, List<Effect> effects, long offsetToAddUs) {
|
||||
if (released) {
|
||||
return;
|
||||
}
|
||||
// This method is only called after all samples in the current input stream are registered or
|
||||
// queued.
|
||||
DebugTraceUtil.logEvent(
|
||||
@ -760,7 +764,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
||||
checkState(!inputStreamEnded);
|
||||
checkStateNotNull(
|
||||
nextInputFrameInfo, "registerInputStream must be called before registering input frames");
|
||||
if (!inputStreamRegisteredCondition.isOpen()) {
|
||||
if (!inputStreamRegisteredCondition.isOpen() || released) {
|
||||
return false;
|
||||
}
|
||||
inputSwitcher.activeTextureManager().registerInputFrame(nextInputFrameInfo);
|
||||
@ -808,6 +812,9 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
||||
DebugTraceUtil.logEvent(COMPONENT_VFP, EVENT_RECEIVE_END_OF_ALL_INPUT, C.TIME_END_OF_SOURCE);
|
||||
checkState(!inputStreamEnded);
|
||||
inputStreamEnded = true;
|
||||
if (released) {
|
||||
return;
|
||||
}
|
||||
inputSwitcher.signalEndOfCurrentInputStream();
|
||||
}
|
||||
|
||||
@ -849,6 +856,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
released = true;
|
||||
try {
|
||||
videoFrameProcessingTaskExecutor.release(/* releaseTask= */ this::releaseGlObjects);
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -406,7 +406,6 @@ public final class MultipleInputVideoGraph implements VideoGraph {
|
||||
for (int i = 0; i < preProcessors.size(); i++) {
|
||||
preProcessors.get(preProcessors.keyAt(i)).release();
|
||||
}
|
||||
preProcessors.clear();
|
||||
|
||||
if (videoCompositor != null) {
|
||||
videoCompositor.release();
|
||||
|
@ -301,10 +301,8 @@ public class SingleInputVideoGraph implements VideoGraph {
|
||||
if (released) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (videoFrameProcessor != null) {
|
||||
videoFrameProcessor.release();
|
||||
videoFrameProcessor = null;
|
||||
}
|
||||
released = true;
|
||||
}
|
||||
|
@ -629,6 +629,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@Nullable
|
||||
@Override
|
||||
public SampleConsumer onOutputFormat(Format assetLoaderOutputFormat) throws ExportException {
|
||||
if (released) {
|
||||
return null;
|
||||
}
|
||||
synchronized (assetLoaderLock) {
|
||||
if (!assetLoaderInputTracker.hasRegisteredAllTracks()) {
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user