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
0efec5f6
authored
Jul 22, 2020
by
ibaker
Committed by
Oliver Woodman
Jul 24, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Enable nullness checks for the text package
PiperOrigin-RevId: 322539147
parent
1c6aaac9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
library/core/src/main/java/com/google/android/exoplayer2/text/TextRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/text/TextRenderer.java
View file @
0efec5f6
...
...
@@ -159,7 +159,7 @@ public final class TextRenderer extends BaseRenderer implements Callback {
replaceDecoder
();
}
else
{
releaseBuffers
();
decoder
.
flush
();
Assertions
.
checkNotNull
(
decoder
)
.
flush
();
}
}
...
...
@@ -170,9 +170,9 @@ public final class TextRenderer extends BaseRenderer implements Callback {
}
if
(
nextSubtitle
==
null
)
{
decoder
.
setPositionUs
(
positionUs
);
Assertions
.
checkNotNull
(
decoder
)
.
setPositionUs
(
positionUs
);
try
{
nextSubtitle
=
decoder
.
dequeueOutputBuffer
();
nextSubtitle
=
Assertions
.
checkNotNull
(
decoder
)
.
dequeueOutputBuffer
();
}
catch
(
SubtitleDecoderException
e
)
{
handleDecoderError
(
e
);
return
;
...
...
@@ -194,8 +194,8 @@ public final class TextRenderer extends BaseRenderer implements Callback {
textRendererNeedsUpdate
=
true
;
}
}
if
(
nextSubtitle
!=
null
)
{
SubtitleOutputBuffer
nextSubtitle
=
this
.
nextSubtitle
;
if
(
nextSubtitle
.
isEndOfStream
())
{
if
(!
textRendererNeedsUpdate
&&
getNextEventTime
()
==
Long
.
MAX_VALUE
)
{
if
(
decoderReplacementState
==
REPLACEMENT_STATE_WAIT_END_OF_STREAM
)
{
...
...
@@ -210,14 +210,16 @@ public final class TextRenderer extends BaseRenderer implements Callback {
if
(
subtitle
!=
null
)
{
subtitle
.
release
();
}
nextSubtitleEventIndex
=
nextSubtitle
.
getNextEventTimeIndex
(
positionUs
);
subtitle
=
nextSubtitle
;
nextSubtitle
=
null
;
nextSubtitleEventIndex
=
subtitle
.
getNextEventTimeIndex
(
positionUs
);
this
.
nextSubtitle
=
null
;
textRendererNeedsUpdate
=
true
;
}
}
if
(
textRendererNeedsUpdate
)
{
// If textRendererNeedsUpdate then subtitle must be non-null.
Assertions
.
checkNotNull
(
subtitle
);
// textRendererNeedsUpdate is set and we're playing. Update the renderer.
updateOutput
(
subtitle
.
getCues
(
positionUs
));
}
...
...
@@ -227,17 +229,18 @@ public final class TextRenderer extends BaseRenderer implements Callback {
}
try
{
@Nullable
SubtitleInputBuffer
nextInputBuffer
=
this
.
nextInputBuffer
;
while
(!
inputStreamEnded
)
{
if
(
nextInputBuffer
==
null
)
{
nextInputBuffer
=
decoder
.
dequeueInputBuffer
();
nextInputBuffer
=
Assertions
.
checkNotNull
(
decoder
)
.
dequeueInputBuffer
();
if
(
nextInputBuffer
==
null
)
{
return
;
}
}
if
(
decoderReplacementState
==
REPLACEMENT_STATE_SIGNAL_END_OF_STREAM
)
{
nextInputBuffer
.
setFlags
(
C
.
BUFFER_FLAG_END_OF_STREAM
);
decoder
.
queueInputBuffer
(
nextInputBuffer
);
nextInputBuffer
=
null
;
Assertions
.
checkNotNull
(
decoder
)
.
queueInputBuffer
(
nextInputBuffer
);
this
.
nextInputBuffer
=
null
;
decoderReplacementState
=
REPLACEMENT_STATE_WAIT_END_OF_STREAM
;
return
;
}
...
...
@@ -248,13 +251,18 @@ public final class TextRenderer extends BaseRenderer implements Callback {
inputStreamEnded
=
true
;
waitingForKeyFrame
=
false
;
}
else
{
nextInputBuffer
.
subsampleOffsetUs
=
formatHolder
.
format
.
subsampleOffsetUs
;
@Nullable
Format
format
=
formatHolder
.
format
;
if
(
format
==
null
)
{
// We haven't received a format yet.
return
;
}
nextInputBuffer
.
subsampleOffsetUs
=
format
.
subsampleOffsetUs
;
nextInputBuffer
.
flip
();
waitingForKeyFrame
&=
!
nextInputBuffer
.
isKeyFrame
();
}
if
(!
waitingForKeyFrame
)
{
decoder
.
queueInputBuffer
(
nextInputBuffer
);
nextInputBuffer
=
null
;
Assertions
.
checkNotNull
(
decoder
)
.
queueInputBuffer
(
nextInputBuffer
);
this
.
nextInputBuffer
=
null
;
}
}
else
if
(
result
==
C
.
RESULT_NOTHING_READ
)
{
return
;
...
...
@@ -300,14 +308,14 @@ public final class TextRenderer extends BaseRenderer implements Callback {
private
void
releaseDecoder
()
{
releaseBuffers
();
decoder
.
release
();
Assertions
.
checkNotNull
(
decoder
)
.
release
();
decoder
=
null
;
decoderReplacementState
=
REPLACEMENT_STATE_NONE
;
}
private
void
initDecoder
()
{
waitingForKeyFrame
=
true
;
decoder
=
decoderFactory
.
createDecoder
(
streamFormat
);
decoder
=
decoderFactory
.
createDecoder
(
Assertions
.
checkNotNull
(
streamFormat
)
);
}
private
void
replaceDecoder
()
{
...
...
@@ -316,6 +324,7 @@ public final class TextRenderer extends BaseRenderer implements Callback {
}
private
long
getNextEventTime
()
{
Assertions
.
checkNotNull
(
subtitle
);
return
nextSubtitleEventIndex
==
C
.
INDEX_UNSET
||
nextSubtitleEventIndex
>=
subtitle
.
getEventTimeCount
()
?
Long
.
MAX_VALUE
:
subtitle
.
getEventTime
(
nextSubtitleEventIndex
);
...
...
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