mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix incorrect assertion in CacheDataSource
#minor-release #exofixit PiperOrigin-RevId: 395233639
This commit is contained in:
parent
11d2d7daf9
commit
b6089758ff
3 changed files with 27 additions and 2 deletions
|
|
@ -14,6 +14,9 @@
|
||||||
* Remove `ExoPlayerLibraryInfo.GL_ASSERTIONS_ENABLED`. Use
|
* Remove `ExoPlayerLibraryInfo.GL_ASSERTIONS_ENABLED`. Use
|
||||||
`GlUtil.glAssertionsEnabled` instead.
|
`GlUtil.glAssertionsEnabled` instead.
|
||||||
* Fix `FlagSet#equals` on API levels below 24.
|
* 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:
|
* Extractors:
|
||||||
* Support TS packets without PTS flag
|
* Support TS packets without PTS flag
|
||||||
([#9294](https://github.com/google/ExoPlayer/issues/9294)).
|
([#9294](https://github.com/google/ExoPlayer/issues/9294)).
|
||||||
|
|
|
||||||
|
|
@ -597,14 +597,14 @@ public final class CacheDataSource implements DataSource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int read(byte[] buffer, int offset, int length) throws IOException {
|
public int read(byte[] buffer, int offset, int length) throws IOException {
|
||||||
DataSpec requestDataSpec = checkNotNull(this.requestDataSpec);
|
|
||||||
DataSpec currentDataSpec = checkNotNull(this.currentDataSpec);
|
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (bytesRemaining == 0) {
|
if (bytesRemaining == 0) {
|
||||||
return C.RESULT_END_OF_INPUT;
|
return C.RESULT_END_OF_INPUT;
|
||||||
}
|
}
|
||||||
|
DataSpec requestDataSpec = checkNotNull(this.requestDataSpec);
|
||||||
|
DataSpec currentDataSpec = checkNotNull(this.currentDataSpec);
|
||||||
try {
|
try {
|
||||||
if (readPosition >= checkCachePosition) {
|
if (readPosition >= checkCachePosition) {
|
||||||
openNextSource(requestDataSpec, true);
|
openNextSource(requestDataSpec, true);
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,28 @@ public final class CacheDataSourceTest {
|
||||||
assertCacheAndRead(boundedDataSpec, /* unknownLength= */ false);
|
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
|
@Test
|
||||||
public void propagatesHttpHeadersUpstream() throws Exception {
|
public void propagatesHttpHeadersUpstream() throws Exception {
|
||||||
CacheDataSource cacheDataSource =
|
CacheDataSource cacheDataSource =
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue