Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a1d376fa
authored
Sep 07, 2021
by
olly
Committed by
Christos Tsilopoulos
Sep 16, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix incorrect assertion in CacheDataSource
#minor-release #exofixit PiperOrigin-RevId: 395233639
parent
624d212d
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
RELEASENOTES.md
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSource.java
library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest.java
RELEASENOTES.md
View file @
a1d376fa
...
@@ -6,6 +6,9 @@
...
@@ -6,6 +6,9 @@
*
Fix track selection in
`StyledPlayerControlView`
when using
*
Fix track selection in
`StyledPlayerControlView`
when using
`ForwardingPlayer`
.
`ForwardingPlayer`
.
*
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
)
).
...
...
library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSource.java
View file @
a1d376fa
...
@@ -597,14 +597,14 @@ public final class CacheDataSource implements DataSource {
...
@@ -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
);
...
...
library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest.java
View file @
a1d376fa
...
@@ -125,6 +125,28 @@ public final class CacheDataSourceTest {
...
@@ -125,6 +125,28 @@ public final class CacheDataSourceTest {
}
}
@Test
@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
{
public
void
propagatesHttpHeadersUpstream
()
throws
Exception
{
CacheDataSource
cacheDataSource
=
CacheDataSource
cacheDataSource
=
createCacheDataSource
(
/* setReadException= */
false
,
/* unknownLength= */
false
);
createCacheDataSource
(
/* setReadException= */
false
,
/* unknownLength= */
false
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment