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
7a1b8a95
authored
Mar 04, 2019
by
aquilescanta
Committed by
Oliver Woodman
Mar 06, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Extract method in MediaCodecRenderer
Deduplicates a bit of code PiperOrigin-RevId: 236621851
parent
8fce3ce6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
23 deletions
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
View file @
7a1b8a95
...
...
@@ -635,22 +635,9 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
renderToEndOfStream
();
return
;
}
if
(
inputFormat
==
null
)
{
// We don't have a format yet, so try and read one.
flagsOnlyBuffer
.
clear
();
int
result
=
readSource
(
formatHolder
,
flagsOnlyBuffer
,
true
);
if
(
result
==
C
.
RESULT_FORMAT_READ
)
{
onInputFormatChanged
(
formatHolder
.
format
);
}
else
if
(
result
==
C
.
RESULT_BUFFER_READ
)
{
// End of stream read having not read a format.
Assertions
.
checkState
(
flagsOnlyBuffer
.
isEndOfStream
());
inputStreamEnded
=
true
;
processEndOfStream
();
return
;
}
else
{
if
(
inputFormat
==
null
&&
!
readToFlagsOnlyBuffer
(
/* requireFormat= */
true
))
{
// We still don't have a format and can't make progress without one.
return
;
}
}
// We have a format.
maybeInitCodec
();
...
...
@@ -666,15 +653,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
// updated, and so that we have the most recent format should the codec be initialized. We may
// also reach the end of the stream. Note that readSource will not read a sample into a
// flags-only buffer.
flagsOnlyBuffer
.
clear
();
int
result
=
readSource
(
formatHolder
,
flagsOnlyBuffer
,
false
);
if
(
result
==
C
.
RESULT_FORMAT_READ
)
{
onInputFormatChanged
(
formatHolder
.
format
);
}
else
if
(
result
==
C
.
RESULT_BUFFER_READ
)
{
Assertions
.
checkState
(
flagsOnlyBuffer
.
isEndOfStream
());
inputStreamEnded
=
true
;
processEndOfStream
();
}
readToFlagsOnlyBuffer
(
/* requireFormat= */
false
);
}
decoderCounters
.
ensureUpdated
();
}
...
...
@@ -737,6 +716,21 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
return
false
;
}
/** Reads into {@link #flagsOnlyBuffer} and returns whether a format was read. */
private
boolean
readToFlagsOnlyBuffer
(
boolean
requireFormat
)
throws
ExoPlaybackException
{
flagsOnlyBuffer
.
clear
();
int
result
=
readSource
(
formatHolder
,
flagsOnlyBuffer
,
requireFormat
);
if
(
result
==
C
.
RESULT_FORMAT_READ
)
{
onInputFormatChanged
(
formatHolder
.
format
);
return
true
;
}
else
if
(
result
==
C
.
RESULT_BUFFER_READ
)
{
Assertions
.
checkState
(
flagsOnlyBuffer
.
isEndOfStream
());
inputStreamEnded
=
true
;
processEndOfStream
();
}
return
false
;
}
private
void
maybeInitCodecWithFallback
(
MediaCrypto
crypto
,
boolean
mediaCryptoRequiresSecureDecoder
)
throws
DecoderInitializationException
{
...
...
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