mirror of
https://github.com/androidx/media.git
synced 2025-05-16 20:19:57 +08:00
continueBuffering should return true when ended.
This issue didn't have any material impact on playbacks, but fixing it anyway to be technically correct.
This commit is contained in:
parent
d6ebd49c63
commit
0fdcb3347c
@ -276,13 +276,14 @@ public class ChunkSampleSource implements SampleSource, Loader.Callback {
|
|||||||
boolean haveSamples = false;
|
boolean haveSamples = false;
|
||||||
if (isPendingReset() || mediaChunks.isEmpty()) {
|
if (isPendingReset() || mediaChunks.isEmpty()) {
|
||||||
// No sample available.
|
// No sample available.
|
||||||
} else if (mediaChunks.getFirst().sampleAvailable()) {
|
} else if (sampleAvailableOrFinishedLastChunk(mediaChunks.getFirst())) {
|
||||||
// There's a sample available to be read from the current chunk.
|
// There's a sample available to be read from the current chunk.
|
||||||
haveSamples = true;
|
haveSamples = true;
|
||||||
} else {
|
} else {
|
||||||
// It may be the case that the current chunk has been fully read but not yet discarded and
|
// It may be the case that the current chunk has been fully read but not yet discarded and
|
||||||
// that the next chunk has an available sample. Return true if so, otherwise false.
|
// that the next chunk has an available sample. Return true if so, otherwise false.
|
||||||
haveSamples = mediaChunks.size() > 1 && mediaChunks.get(1).sampleAvailable();
|
haveSamples = mediaChunks.size() > 1
|
||||||
|
&& sampleAvailableOrFinishedLastChunk(mediaChunks.get(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!haveSamples) {
|
if (!haveSamples) {
|
||||||
@ -716,6 +717,10 @@ public class ChunkSampleSource implements SampleSource, Loader.Callback {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean sampleAvailableOrFinishedLastChunk(MediaChunk chunk) throws IOException {
|
||||||
|
return chunk.sampleAvailable() || (chunk.isLastChunk() && chunk.isReadFinished());
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isMediaChunk(Chunk chunk) {
|
private boolean isMediaChunk(Chunk chunk) {
|
||||||
return chunk instanceof MediaChunk;
|
return chunk instanceof MediaChunk;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user