mirror of
https://github.com/androidx/media.git
synced 2025-04-29 22:36:54 +08:00
Fix a bug that video effects are added twice
The tests passed because of an issue in chaining. The chaining listener allows self-looping, i.e. the producer and the consumer of a frame could be the same instance. Like an effect chain of `a -> a -> b` This didn't fail any test before, because the chaining is rectified when connecting a to b, but it should have failed when connecting a to a. PiperOrigin-RevId: 742215700
This commit is contained in:
parent
73fa820828
commit
ff6537d69b
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package androidx.media3.effect;
|
||||
|
||||
import static androidx.media3.common.util.Assertions.checkArgument;
|
||||
|
||||
import androidx.media3.common.GlObjectsProvider;
|
||||
import androidx.media3.common.GlTextureInfo;
|
||||
import androidx.media3.effect.GlShaderProgram.InputListener;
|
||||
@ -51,6 +53,9 @@ import androidx.media3.effect.GlShaderProgram.OutputListener;
|
||||
GlShaderProgram producingGlShaderProgram,
|
||||
GlShaderProgram consumingGlShaderProgram,
|
||||
VideoFrameProcessingTaskExecutor videoFrameProcessingTaskExecutor) {
|
||||
checkArgument(
|
||||
producingGlShaderProgram != consumingGlShaderProgram,
|
||||
"Creating a self loop in the chain: " + producingGlShaderProgram);
|
||||
this.producingGlShaderProgram = producingGlShaderProgram;
|
||||
frameConsumptionManager =
|
||||
new FrameConsumptionManager(
|
||||
|
@ -782,7 +782,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
||||
@FirstFrameReleaseInstruction int firstFrameReleaseInstruction,
|
||||
List<Effect> videoEffects) {
|
||||
checkState(isInitialized());
|
||||
setPendingVideoEffects(videoEffects);
|
||||
this.videoEffects = ImmutableList.copyOf(videoEffects);
|
||||
this.inputType = inputType;
|
||||
this.inputFormat = format;
|
||||
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
||||
@ -863,7 +863,7 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
||||
if (this.videoEffects.equals(videoEffects)) {
|
||||
return;
|
||||
}
|
||||
setPendingVideoEffects(videoEffects);
|
||||
this.videoEffects = ImmutableList.copyOf(videoEffects);
|
||||
if (inputFormat != null) {
|
||||
registerInputStream(inputFormat);
|
||||
}
|
||||
@ -999,23 +999,6 @@ public final class PlaybackVideoGraphWrapper implements VideoSinkProvider, Video
|
||||
|
||||
// Private methods
|
||||
|
||||
/**
|
||||
* Sets the pending video effects.
|
||||
*
|
||||
* <p>Effects are pending until a new input stream is registered.
|
||||
*/
|
||||
private void setPendingVideoEffects(List<Effect> newVideoEffects) {
|
||||
if (videoGraphFactory.supportsMultipleInputs()) {
|
||||
this.videoEffects = ImmutableList.copyOf(newVideoEffects);
|
||||
} else {
|
||||
this.videoEffects =
|
||||
new ImmutableList.Builder<Effect>()
|
||||
.addAll(newVideoEffects)
|
||||
.addAll(compositionEffects)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerInputStream(Format inputFormat) {
|
||||
Format adjustedInputFormat =
|
||||
inputFormat
|
||||
|
Loading…
x
Reference in New Issue
Block a user