mirror of
https://github.com/androidx/media.git
synced 2025-05-17 04:29:55 +08:00
FlacExtractor: add condition for zero-length reads
This improves readability by making clearer that reading no bytes from the input in readFrames() is an expected case if the buffer is full. PiperOrigin-RevId: 288711841
This commit is contained in:
parent
216518eb0e
commit
79edf7cce2
@ -256,15 +256,18 @@ public final class FlacExtractor implements Extractor {
|
||||
|
||||
// Copy more bytes into the buffer.
|
||||
int currentLimit = buffer.limit();
|
||||
int bytesRead =
|
||||
input.read(
|
||||
buffer.data, /* offset= */ currentLimit, /* length= */ BUFFER_LENGTH - currentLimit);
|
||||
boolean foundEndOfInput = bytesRead == C.RESULT_END_OF_INPUT;
|
||||
if (!foundEndOfInput) {
|
||||
buffer.setLimit(currentLimit + bytesRead);
|
||||
} else if (buffer.bytesLeft() == 0) {
|
||||
outputSampleMetadata();
|
||||
return Extractor.RESULT_END_OF_INPUT;
|
||||
boolean foundEndOfInput = false;
|
||||
if (currentLimit < BUFFER_LENGTH) {
|
||||
int bytesRead =
|
||||
input.read(
|
||||
buffer.data, /* offset= */ currentLimit, /* length= */ BUFFER_LENGTH - currentLimit);
|
||||
foundEndOfInput = bytesRead == C.RESULT_END_OF_INPUT;
|
||||
if (!foundEndOfInput) {
|
||||
buffer.setLimit(currentLimit + bytesRead);
|
||||
} else if (buffer.bytesLeft() == 0) {
|
||||
outputSampleMetadata();
|
||||
return Extractor.RESULT_END_OF_INPUT;
|
||||
}
|
||||
}
|
||||
|
||||
// Search for a frame.
|
||||
|
Loading…
x
Reference in New Issue
Block a user