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
de5c7a2f
authored
Jan 26, 2021
by
andrewlewis
Committed by
Oliver Woodman
Feb 01, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Elaborate method comments in transformer audio renderer
#minor-release PiperOrigin-RevId: 353856211
parent
e3ac3929
Show 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 @
de5c7a2f
...
@@ -114,9 +114,10 @@ import java.nio.ByteBuffer;
...
@@ -114,9 +114,10 @@ import java.nio.ByteBuffer;
return
;
return
;
}
}
if
(!
setupDecoder
()
||
!
setupEncoderAndMaybeSonic
()
)
{
if
(!
setupDecoder
())
{
return
;
return
;
}
}
setupEncoderAndMaybeSonic
();
while
(
drainEncoderToFeedMuxer
())
{}
while
(
drainEncoderToFeedMuxer
())
{}
if
(
sonicAudioProcessor
.
isActive
())
{
if
(
sonicAudioProcessor
.
isActive
())
{
...
@@ -128,7 +129,10 @@ import java.nio.ByteBuffer;
...
@@ -128,7 +129,10 @@ import java.nio.ByteBuffer;
while
(
feedDecoderInputFromSource
())
{}
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
()
{
private
boolean
drainEncoderToFeedMuxer
()
{
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
if
(!
hasEncoderOutputFormat
)
{
if
(!
hasEncoderOutputFormat
)
{
...
@@ -167,7 +171,10 @@ import java.nio.ByteBuffer;
...
@@ -167,7 +171,10 @@ import java.nio.ByteBuffer;
return
true
;
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
()
{
private
boolean
drainDecoderToFeedEncoder
()
{
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
...
@@ -199,7 +206,10 @@ import java.nio.ByteBuffer;
...
@@ -199,7 +206,10 @@ import java.nio.ByteBuffer;
return
true
;
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
()
{
private
boolean
drainSonicToFeedEncoder
()
{
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
if
(!
encoder
.
maybeDequeueInputBuffer
(
encoderInputBuffer
))
{
if
(!
encoder
.
maybeDequeueInputBuffer
(
encoderInputBuffer
))
{
...
@@ -219,7 +229,10 @@ import java.nio.ByteBuffer;
...
@@ -219,7 +229,10 @@ import java.nio.ByteBuffer;
return
feedEncoder
(
sonicOutputBuffer
);
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
()
{
private
boolean
drainDecoderToFeedSonic
()
{
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
...
@@ -263,7 +276,10 @@ import java.nio.ByteBuffer;
...
@@ -263,7 +276,10 @@ import java.nio.ByteBuffer;
return
true
;
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
()
{
private
boolean
feedDecoderInputFromSource
()
{
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
if
(!
decoder
.
maybeDequeueInputBuffer
(
decoderInputBuffer
))
{
if
(!
decoder
.
maybeDequeueInputBuffer
(
decoderInputBuffer
))
{
...
@@ -287,10 +303,8 @@ import java.nio.ByteBuffer;
...
@@ -287,10 +303,8 @@ import java.nio.ByteBuffer;
}
}
/**
/**
* Feeds the encoder the {@link ByteBuffer inputBuffer} with the correct {@code timeUs}.
* Feeds the encoder the {@link ByteBuffer inputBuffer} with the correct {@code timeUs}, and
*
* returns whether it may be possible to write more data.
* @param inputBuffer The buffer to be fed.
* @return Whether more input buffers can be queued to the encoder.
*/
*/
private
boolean
feedEncoder
(
ByteBuffer
inputBuffer
)
{
private
boolean
feedEncoder
(
ByteBuffer
inputBuffer
)
{
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
MediaCodecAdapterWrapper
encoder
=
checkNotNull
(
this
.
encoder
);
...
@@ -323,12 +337,15 @@ import java.nio.ByteBuffer;
...
@@ -323,12 +337,15 @@ import java.nio.ByteBuffer;
encoder
.
queueInputBuffer
(
encoderInputBuffer
);
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
);
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
if
(
encoder
!=
null
)
{
if
(
encoder
!=
null
)
{
return
true
;
return
;
}
}
Format
decoderFormat
=
decoder
.
getConfigFormat
();
Format
decoderFormat
=
decoder
.
getConfigFormat
();
...
@@ -349,10 +366,12 @@ import java.nio.ByteBuffer;
...
@@ -349,10 +366,12 @@ import java.nio.ByteBuffer;
throw
ExoPlaybackException
.
createForRenderer
(
throw
ExoPlaybackException
.
createForRenderer
(
e
,
TAG
,
getIndex
(),
encoderFormat
,
/* rendererFormatSupport= */
C
.
FORMAT_HANDLED
);
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
{
private
boolean
setupDecoder
()
throws
ExoPlaybackException
{
if
(
decoder
!=
null
)
{
if
(
decoder
!=
null
)
{
return
true
;
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