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
b1df2f4e
authored
Jan 26, 2021
by
andrewlewis
Committed by
kim-vde
Jan 26, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Elaborate method comments in transformer audio renderer
#minor-release PiperOrigin-RevId: 353856211
parent
3c17aeb7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
15 deletions
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerAudioRenderer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerAudioRenderer.java
View file @
b1df2f4e
...
...
@@ -114,9 +114,10 @@ import java.nio.ByteBuffer;
return
;
}
if
(!
setupDecoder
()
||
!
setupEncoderAndMaybeSonic
()
)
{
if
(!
setupDecoder
())
{
return
;
}
setupEncoderAndMaybeSonic
();
while
(
drainEncoderToFeedMuxer
())
{}
if
(
sonicAudioProcessor
.
isActive
())
{
...
...
@@ -128,7 +129,10 @@ import java.nio.ByteBuffer;
while
(
feedDecoderInputFromSource
())
{}
}
/** Returns whether it may be possible to process more data with this method. */
/**
* Attempts to write encoder output data to the muxer, and returns whether it may be possible to
* write more data immediately by calling this method again.
*/
private
boolean
drainEncoderToFeedMuxer
()
{
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
if
(!
hasEncoderOutputFormat
)
{
...
...
@@ -167,7 +171,10 @@ import java.nio.ByteBuffer;
return
true
;
}
/** Returns whether it may be possible to process more data with this method. */
/**
* Attempts to pass decoder output data to the encoder, and returns whether it may be possible to
* pass more data immediately by calling this method again.
*/
private
boolean
drainDecoderToFeedEncoder
()
{
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
...
...
@@ -199,7 +206,10 @@ import java.nio.ByteBuffer;
return
true
;
}
/** Returns whether it may be possible to process more data with this method. */
/**
* Attempts to pass audio processor output data to the encoder, and returns whether it may be
* possible to pass more data immediately by calling this method again.
*/
private
boolean
drainSonicToFeedEncoder
()
{
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
if
(!
encoder
.
maybeDequeueInputBuffer
(
encoderInputBuffer
))
{
...
...
@@ -219,7 +229,10 @@ import java.nio.ByteBuffer;
return
feedEncoder
(
sonicOutputBuffer
);
}
/** Returns whether it may be possible to process more data with this method. */
/**
* Attempts to process decoder output audio, and returns whether it may be possible to process
* more data immediately by calling this method again.
*/
private
boolean
drainDecoderToFeedSonic
()
{
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
...
...
@@ -263,7 +276,10 @@ import java.nio.ByteBuffer;
return
true
;
}
/** Returns whether it may be possible to process more data with this method. */
/**
* Attempts to pass input data to the decoder, and returns whether it may be possible to pass more
* data immediately by calling this method again.
*/
private
boolean
feedDecoderInputFromSource
()
{
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
if
(!
decoder
.
maybeDequeueInputBuffer
(
decoderInputBuffer
))
{
...
...
@@ -287,10 +303,8 @@ import java.nio.ByteBuffer;
}
/**
* Feeds the encoder the {@link ByteBuffer inputBuffer} with the correct {@code timeUs}.
*
* @param inputBuffer The buffer to be fed.
* @return Whether more input buffers can be queued to the encoder.
* Feeds the encoder the {@link ByteBuffer inputBuffer} with the correct {@code timeUs}, and
* returns whether it may be possible to write more data.
*/
private
boolean
feedEncoder
(
ByteBuffer
inputBuffer
)
{
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
...
...
@@ -323,12 +337,15 @@ import java.nio.ByteBuffer;
encoder
.
queueInputBuffer
(
encoderInputBuffer
);
}
/** Returns whether the encoder has been setup. */
private
boolean
setupEncoderAndMaybeSonic
()
throws
ExoPlaybackException
{
/**
* Configures the {@link #encoder} and Sonic (if applicable), if they have not been configured
* yet.
*/
private
void
setupEncoderAndMaybeSonic
()
throws
ExoPlaybackException
{
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
if
(
encoder
!=
null
)
{
return
true
;
return
;
}
Format
decoderFormat
=
decoder
.
getConfigFormat
();
...
...
@@ -349,10 +366,12 @@ import java.nio.ByteBuffer;
throw
ExoPlaybackException
.
createForRenderer
(
e
,
TAG
,
getIndex
(),
encoderFormat
,
/* rendererFormatSupport= */
C
.
FORMAT_HANDLED
);
}
return
true
;
}
/** Returns whether the decoder has been setup. */
/**
* Attempts to configure the {@link #decoder} if it has not been configured yet, and returns
* whether the decoder has been configured.
*/
private
boolean
setupDecoder
()
throws
ExoPlaybackException
{
if
(
decoder
!=
null
)
{
return
true
;
...
...
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