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