Flush: Disallow flushing when there's no active input.
Throws when calling flush when there's no active input, for example before an input stream is registered or after all output streams have ended. PiperOrigin-RevId: 577165419
This commit is contained in:
parent
dd6306e1ba
commit
fed88cf6f5
@ -18,6 +18,7 @@ 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;
|
||||
@ -60,20 +61,10 @@ public class DefaultVideoFrameProcessorFlushTest {
|
||||
|
||||
@Test
|
||||
@RequiresNonNull({"testId"})
|
||||
public void imageInput_flushBeforeInput_outputsAllFrames() throws Exception {
|
||||
public void imageInput_flushBeforeInput_throwsException() throws Exception {
|
||||
videoFrameProcessorTestRunner = createDefaultVideoFrameProcessorTestRunner(testId);
|
||||
Bitmap bitmap = readBitmapUnpremultipliedAlpha(ORIGINAL_PNG_ASSET_PATH);
|
||||
int inputFrameCount = 3;
|
||||
|
||||
videoFrameProcessorTestRunner.flush();
|
||||
videoFrameProcessorTestRunner.queueInputBitmap(
|
||||
bitmap,
|
||||
/* durationUs= */ inputFrameCount * C.MICROS_PER_SECOND,
|
||||
/* offsetToAddUs= */ 0L,
|
||||
/* frameRate= */ 1);
|
||||
videoFrameProcessorTestRunner.endFrameProcessing();
|
||||
|
||||
assertThat(outputFrameCount).isEqualTo(inputFrameCount);
|
||||
assertThrows(IllegalStateException.class, videoFrameProcessorTestRunner::flush);
|
||||
}
|
||||
|
||||
// This tests a condition that is difficult to synchronize, and is subject to a race condition. It
|
||||
|
@ -559,9 +559,6 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
|
||||
*/
|
||||
@Override
|
||||
public void flush() {
|
||||
if (!inputSwitcher.hasActiveInput()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
videoFrameProcessingTaskExecutor.flush();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user