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) {
|
||||
switch (parserState) {
|
||||
case STATE_READING_HEADER:
|
||||
parseHeader(input);
|
||||
if (parseHeader(input)) {
|
||||
parserState = STATE_READING_TIMESTAMP_AND_COUNT;
|
||||
} else {
|
||||
return RESULT_END_OF_INPUT;
|
||||
}
|
||||
break;
|
||||
case STATE_READING_TIMESTAMP_AND_COUNT:
|
||||
if (parseTimestampAndSampleCount(input)) {
|
||||
@ -114,14 +117,18 @@ public final class RawCcExtractor implements Extractor {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
private void parseHeader(ExtractorInput input) throws IOException, InterruptedException {
|
||||
private boolean parseHeader(ExtractorInput input) throws IOException, InterruptedException {
|
||||
dataScratch.reset();
|
||||
input.readFully(dataScratch.data, 0, HEADER_SIZE);
|
||||
if (input.readFully(dataScratch.data, 0, HEADER_SIZE, true)) {
|
||||
if (dataScratch.readInt() != HEADER_ID) {
|
||||
throw new IOException("Input not RawCC");
|
||||
}
|
||||
version = dataScratch.readUnsignedByte();
|
||||
// no versions use the flag fields yet
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean parseTimestampAndSampleCount(ExtractorInput input) throws IOException,
|
||||
|
Loading…
x
Reference in New Issue
Block a user