diff --git a/libraries/common/src/main/java/androidx/media3/common/VideoFrameProcessor.java b/libraries/common/src/main/java/androidx/media3/common/VideoFrameProcessor.java index c0e3727076..f891f04b3d 100644 --- a/libraries/common/src/main/java/androidx/media3/common/VideoFrameProcessor.java +++ b/libraries/common/src/main/java/androidx/media3/common/VideoFrameProcessor.java @@ -319,8 +319,6 @@ public interface VideoFrameProcessor { * * @throws UnsupportedOperationException If the {@code VideoFrameProcessor} does not accept * {@linkplain #INPUT_TYPE_SURFACE surface input}. - * @throws IllegalStateException If {@link #registerInputStream} is not called before calling this - * method. */ void flush(); diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/DefaultVideoFrameProcessorFlushTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/DefaultVideoFrameProcessorFlushTest.java index 22dc10f884..76020110d1 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/DefaultVideoFrameProcessorFlushTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/DefaultVideoFrameProcessorFlushTest.java @@ -18,7 +18,6 @@ package androidx.media3.effect; import static androidx.media3.common.util.Assertions.checkNotNull; import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmapUnpremultipliedAlpha; import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertThrows; import android.graphics.Bitmap; import androidx.media3.common.C; @@ -54,13 +53,6 @@ public class DefaultVideoFrameProcessorFlushTest { checkNotNull(videoFrameProcessorTestRunner).release(); } - @Test - public void imageInput_flushBeforeInput_throwsException() throws Exception { - videoFrameProcessorTestRunner = createDefaultVideoFrameProcessorTestRunner(testId); - - assertThrows(IllegalStateException.class, videoFrameProcessorTestRunner::flush); - } - // This tests a condition that is difficult to synchronize, and is subject to a race condition. It // may flake/fail if any queued frames are processed in the VideoFrameProcessor thread, before // flush begins and cancels these pending frames. However, this is better than not testing this diff --git a/libraries/effect/src/main/java/androidx/media3/effect/DefaultVideoFrameProcessor.java b/libraries/effect/src/main/java/androidx/media3/effect/DefaultVideoFrameProcessor.java index 8ee6205290..e05c807707 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/DefaultVideoFrameProcessor.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/DefaultVideoFrameProcessor.java @@ -604,6 +604,9 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor { */ @Override public void flush() { + if (!inputSwitcher.hasActiveInput()) { + return; + } try { videoFrameProcessingTaskExecutor.flush(); @@ -612,7 +615,6 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor { inputSwitcher.activeTextureManager().setOnFlushCompleteListener(latch::countDown); videoFrameProcessingTaskExecutor.submit(finalShaderProgramWrapper::flush); latch.await(); - inputSwitcher.activeTextureManager().setOnFlushCompleteListener(null); } catch (InterruptedException e) { Thread.currentThread().interrupt();