mirror of
https://github.com/androidx/media.git
synced 2025-05-16 20:19:57 +08:00
Add missing switch case
Before this change, calling read after reaching the end of input in an Ogg file would cause an IllegalStateException. PiperOrigin-RevId: 364758873
This commit is contained in:
parent
bffb68b23b
commit
273d68accd
@ -119,6 +119,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
case STATE_READ_PAYLOAD:
|
||||
castNonNull(oggSeeker);
|
||||
return readPayload(input, seekPosition);
|
||||
case STATE_END_OF_INPUT:
|
||||
return C.RESULT_END_OF_INPUT;
|
||||
default:
|
||||
// Never happens.
|
||||
throw new IllegalStateException();
|
||||
|
@ -16,11 +16,15 @@
|
||||
package com.google.android.exoplayer2.extractor.ogg;
|
||||
|
||||
import static com.google.android.exoplayer2.testutil.TestUtil.getByteArray;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.extractor.PositionHolder;
|
||||
import com.google.android.exoplayer2.testutil.ExtractorAsserts;
|
||||
import com.google.android.exoplayer2.testutil.FakeExtractorInput;
|
||||
import com.google.android.exoplayer2.testutil.FakeExtractorOutput;
|
||||
import java.io.IOException;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -34,6 +38,19 @@ import org.junit.runner.RunWith;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public final class OggExtractorNonParameterizedTest {
|
||||
|
||||
@Test
|
||||
public void read_afterEndOfInput_doesNotThrowIllegalState() throws Exception {
|
||||
byte[] data =
|
||||
getByteArray(ApplicationProvider.getApplicationContext(), "media/ogg/bear_flac.ogg");
|
||||
FakeExtractorInput input = new FakeExtractorInput.Builder().setData(data).build();
|
||||
OggExtractor oggExtractor = new OggExtractor();
|
||||
oggExtractor.init(new FakeExtractorOutput());
|
||||
// We feed data to the extractor until the end of input is reached.
|
||||
while (oggExtractor.read(input, new PositionHolder()) != C.RESULT_END_OF_INPUT) {}
|
||||
// We call read again to check that it does not throw an IllegalStateException.
|
||||
assertThat(oggExtractor.read(input, new PositionHolder())).isEqualTo(C.RESULT_END_OF_INPUT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sniffVorbis() throws Exception {
|
||||
byte[] data =
|
||||
|
Loading…
x
Reference in New Issue
Block a user