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
3ad1b954
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 checking for BaseRenderer
#exofixit PiperOrigin-RevId: 322567104
parent
6e751c35
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
11 deletions
library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java
View file @
3ad1b954
...
...
@@ -30,11 +30,11 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
private
final
int
trackType
;
private
final
FormatHolder
formatHolder
;
private
RendererConfiguration
configuration
;
@Nullable
private
RendererConfiguration
configuration
;
private
int
index
;
private
int
state
;
private
SampleStream
stream
;
private
Format
[]
streamFormats
;
@Nullable
private
SampleStream
stream
;
@Nullable
private
Format
[]
streamFormats
;
private
long
streamOffsetUs
;
private
long
lastResetPositionUs
;
private
long
readingPositionUs
;
...
...
@@ -144,7 +144,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
@Override
public
final
void
maybeThrowStreamError
()
throws
IOException
{
stream
.
maybeThrowError
();
Assertions
.
checkNotNull
(
stream
)
.
maybeThrowError
();
}
@Override
...
...
@@ -303,16 +303,24 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
return
formatHolder
;
}
/** Returns the formats of the currently enabled stream. */
/**
* Returns the formats of the currently enabled stream.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*/
protected
final
Format
[]
getStreamFormats
()
{
return
streamFormats
;
return
Assertions
.
checkNotNull
(
streamFormats
)
;
}
/**
* Returns the configuration set when the renderer was most recently enabled.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*/
protected
final
RendererConfiguration
getConfiguration
()
{
return
configuration
;
return
Assertions
.
checkNotNull
(
configuration
)
;
}
/**
...
...
@@ -352,6 +360,9 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
* {@link C#RESULT_BUFFER_READ} is only returned if {@link #setCurrentStreamFinal()} has been
* called. {@link C#RESULT_NOTHING_READ} is returned otherwise.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*
* @param formatHolder A {@link FormatHolder} to populate in the case of reading a format.
* @param buffer A {@link DecoderInputBuffer} to populate in the case of reading a sample or the
* end of the stream. If the end of the stream has been reached, the {@link
...
...
@@ -364,7 +375,8 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
@SampleStream
.
ReadDataResult
protected
final
int
readSource
(
FormatHolder
formatHolder
,
DecoderInputBuffer
buffer
,
boolean
formatRequired
)
{
@SampleStream
.
ReadDataResult
int
result
=
stream
.
readData
(
formatHolder
,
buffer
,
formatRequired
);
@SampleStream
.
ReadDataResult
int
result
=
Assertions
.
checkNotNull
(
stream
).
readData
(
formatHolder
,
buffer
,
formatRequired
);
if
(
result
==
C
.
RESULT_BUFFER_READ
)
{
if
(
buffer
.
isEndOfStream
())
{
readingPositionUs
=
C
.
TIME_END_OF_SOURCE
;
...
...
@@ -373,7 +385,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
buffer
.
timeUs
+=
streamOffsetUs
;
readingPositionUs
=
Math
.
max
(
readingPositionUs
,
buffer
.
timeUs
);
}
else
if
(
result
==
C
.
RESULT_FORMAT_READ
)
{
Format
format
=
formatHolder
.
format
;
Format
format
=
Assertions
.
checkNotNull
(
formatHolder
.
format
)
;
if
(
format
.
subsampleOffsetUs
!=
Format
.
OFFSET_SAMPLE_RELATIVE
)
{
format
=
format
...
...
@@ -390,17 +402,23 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
* Attempts to skip to the keyframe before the specified position, or to the end of the stream if
* {@code positionUs} is beyond it.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*
* @param positionUs The position in microseconds.
* @return The number of samples that were skipped.
*/
protected
int
skipSource
(
long
positionUs
)
{
return
stream
.
skipData
(
positionUs
-
streamOffsetUs
);
return
Assertions
.
checkNotNull
(
stream
)
.
skipData
(
positionUs
-
streamOffsetUs
);
}
/**
* Returns whether the upstream source is ready.
*
* <p>This method may be called when the renderer is in the following states: {@link
* #STATE_ENABLED}, {@link #STATE_STARTED}.
*/
protected
final
boolean
isSourceReady
()
{
return
hasReadStreamToEnd
()
?
streamIsFinal
:
stream
.
isReady
();
return
hasReadStreamToEnd
()
?
streamIsFinal
:
Assertions
.
checkNotNull
(
stream
)
.
isReady
();
}
}
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