mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Fix incorrect assertion in CacheDataSource
#minor-release #exofixit PiperOrigin-RevId: 395233639
This commit is contained in:
parent
624d212df2
commit
a1d376fae1
3 changed files with 27 additions and 2 deletions
|
|
@ -6,6 +6,9 @@
|
|||
* Fix track selection in `StyledPlayerControlView` when using
|
||||
`ForwardingPlayer`.
|
||||
* Fix `FlagSet#equals` on API levels below 24.
|
||||
* Fix `NullPointerException` being thrown from `CacheDataSource` when
|
||||
reading a fully cached resource with `DataSpec.position` equal to the
|
||||
resource length.
|
||||
* Extractors:
|
||||
* Support TS packets without PTS flag
|
||||
([#9294](https://github.com/google/ExoPlayer/issues/9294)).
|
||||
|
|
|
|||
|
|
@ -597,14 +597,14 @@ public final class CacheDataSource implements DataSource {
|
|||
|
||||
@Override
|
||||
public int read(byte[] buffer, int offset, int length) throws IOException {
|
||||
DataSpec requestDataSpec = checkNotNull(this.requestDataSpec);
|
||||
DataSpec currentDataSpec = checkNotNull(this.currentDataSpec);
|
||||
if (length == 0) {
|
||||
return 0;
|
||||
}
|
||||
if (bytesRemaining == 0) {
|
||||
return C.RESULT_END_OF_INPUT;
|
||||
}
|
||||
DataSpec requestDataSpec = checkNotNull(this.requestDataSpec);
|
||||
DataSpec currentDataSpec = checkNotNull(this.currentDataSpec);
|
||||
try {
|
||||
if (readPosition >= checkCachePosition) {
|
||||
openNextSource(requestDataSpec, true);
|
||||
|
|
|
|||
|
|
@ -124,6 +124,28 @@ public final class CacheDataSourceTest {
|
|||
assertCacheAndRead(boundedDataSpec, /* unknownLength= */ false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cacheAndReadFromLength_readsZeroBytes() throws Exception {
|
||||
// Read and cache all data from upstream.
|
||||
CacheDataSource cacheDataSource =
|
||||
createCacheDataSource(
|
||||
/* setReadException= */ false, /* unknownLength= */ false, /* cacheKeyFactory= */ null);
|
||||
assertReadDataContentLength(
|
||||
cacheDataSource,
|
||||
unboundedDataSpec,
|
||||
/* unknownLength= */ false,
|
||||
/* customCacheKey= */ false);
|
||||
|
||||
// Read from position == length.
|
||||
cacheDataSource =
|
||||
createCacheDataSource(
|
||||
/* setReadException= */ true, /* unknownLength= */ false, /* cacheKeyFactory= */ null);
|
||||
assertReadData(
|
||||
cacheDataSource,
|
||||
unboundedDataSpec.buildUpon().setPosition(TEST_DATA.length).build(),
|
||||
/* unknownLength= */ false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propagatesHttpHeadersUpstream() throws Exception {
|
||||
CacheDataSource cacheDataSource =
|
||||
|
|
|
|||
Loading…
Reference in a new issue