Handle empty RawCC files.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=143667717
This commit is contained in:
parent
8a0e76ba32
commit
01d22f8123
@ -83,8 +83,11 @@ public final class RawCcExtractor implements Extractor {
|
|||||||
while (true) {
|
while (true) {
|
||||||
switch (parserState) {
|
switch (parserState) {
|
||||||
case STATE_READING_HEADER:
|
case STATE_READING_HEADER:
|
||||||
parseHeader(input);
|
if (parseHeader(input)) {
|
||||||
parserState = STATE_READING_TIMESTAMP_AND_COUNT;
|
parserState = STATE_READING_TIMESTAMP_AND_COUNT;
|
||||||
|
} else {
|
||||||
|
return RESULT_END_OF_INPUT;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case STATE_READING_TIMESTAMP_AND_COUNT:
|
case STATE_READING_TIMESTAMP_AND_COUNT:
|
||||||
if (parseTimestampAndSampleCount(input)) {
|
if (parseTimestampAndSampleCount(input)) {
|
||||||
@ -114,14 +117,18 @@ public final class RawCcExtractor implements Extractor {
|
|||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseHeader(ExtractorInput input) throws IOException, InterruptedException {
|
private boolean parseHeader(ExtractorInput input) throws IOException, InterruptedException {
|
||||||
dataScratch.reset();
|
dataScratch.reset();
|
||||||
input.readFully(dataScratch.data, 0, HEADER_SIZE);
|
if (input.readFully(dataScratch.data, 0, HEADER_SIZE, true)) {
|
||||||
if (dataScratch.readInt() != HEADER_ID) {
|
if (dataScratch.readInt() != HEADER_ID) {
|
||||||
throw new IOException("Input not RawCC");
|
throw new IOException("Input not RawCC");
|
||||||
|
}
|
||||||
|
version = dataScratch.readUnsignedByte();
|
||||||
|
// no versions use the flag fields yet
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
version = dataScratch.readUnsignedByte();
|
|
||||||
// no versions use the flag fields yet
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean parseTimestampAndSampleCount(ExtractorInput input) throws IOException,
|
private boolean parseTimestampAndSampleCount(ExtractorInput input) throws IOException,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user