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
54156838
authored
Jul 01, 2020
by
krocard
Committed by
Oliver Woodman
Jul 03, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Merge `onOutputCodecBypassFormatChanged` and `onOutputFormatChanged`
PiperOrigin-RevId: 319230328
parent
69187523
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
40 deletions
library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java
View file @
54156838
...
...
@@ -387,11 +387,11 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
@Override
protected
void
configureOutput
(
Format
outputFormat
)
throws
ExoPlaybackException
{
Format
audioSinkInputFormat
;
if
(
codecPassthroughFormat
!=
null
)
{
@C
.
Encoding
int
passthroughEncoding
=
getPassthroughEncoding
(
codecPassthroughFormat
);
// TODO(b/112299307): Passthrough can have become unavailable since usePassthrough was called.
Assertions
.
checkState
(
passthroughEncoding
!=
C
.
ENCODING_INVALID
);
audioSinkInputFormat
=
outputFormat
.
buildUpon
().
setEncoding
(
passthroughEncoding
).
build
(
);
@Nullable
int
[]
channelMap
=
null
;
if
(
codecPassthroughFormat
!=
null
)
{
// Raw codec passthrough
audioSinkInputFormat
=
getFormatWithEncodingForPassthrough
(
codecPassthroughFormat
);
}
else
if
(
getCodec
()
==
null
)
{
// Codec bypass passthrough
audioSinkInputFormat
=
getFormatWithEncodingForPassthrough
(
outputFormat
);
}
else
{
MediaFormat
mediaFormat
=
getCodec
().
getOutputFormat
();
@C
.
Encoding
int
encoding
;
...
...
@@ -407,14 +407,13 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
.
setChannelCount
(
mediaFormat
.
getInteger
(
MediaFormat
.
KEY_CHANNEL_COUNT
))
.
setSampleRate
(
mediaFormat
.
getInteger
(
MediaFormat
.
KEY_SAMPLE_RATE
))
.
build
();
}
@Nullable
int
[]
channelMap
=
null
;
if
(
codecNeedsDiscardChannelsWorkaround
&&
audioSinkInputFormat
.
channelCount
==
6
&&
outputFormat
.
channelCount
<
6
)
{
channelMap
=
new
int
[
outputFormat
.
channelCount
];
for
(
int
i
=
0
;
i
<
outputFormat
.
channelCount
;
i
++)
{
channelMap
[
i
]
=
i
;
if
(
codecNeedsDiscardChannelsWorkaround
&&
audioSinkInputFormat
.
channelCount
==
6
&&
outputFormat
.
channelCount
<
6
)
{
channelMap
=
new
int
[
outputFormat
.
channelCount
];
for
(
int
i
=
0
;
i
<
outputFormat
.
channelCount
;
i
++)
{
channelMap
[
i
]
=
i
;
}
}
}
try
{
...
...
@@ -424,19 +423,6 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
}
}
@Override
protected
void
onOutputBypassFormatChanged
(
Format
outputFormat
)
throws
ExoPlaybackException
{
@C
.
Encoding
int
passthroughEncoding
=
getPassthroughEncoding
(
outputFormat
);
// TODO(b/112299307): Passthrough can have become unavailable since usePassthrough was called.
Assertions
.
checkState
(
passthroughEncoding
!=
C
.
ENCODING_INVALID
);
Format
format
=
outputFormat
.
buildUpon
().
setEncoding
(
passthroughEncoding
).
build
();
try
{
audioSink
.
configure
(
format
,
/* specifiedBufferSize= */
0
,
/* outputChannels= */
null
);
}
catch
(
AudioSink
.
ConfigurationException
e
)
{
throw
createRendererException
(
e
,
outputFormat
);
}
}
/**
* Returns the {@link C.Encoding} constant to use for passthrough of the given format, or {@link
* C#ENCODING_INVALID} if passthrough is not possible.
...
...
@@ -799,6 +785,13 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
}
}
private
Format
getFormatWithEncodingForPassthrough
(
Format
outputFormat
)
{
@C
.
Encoding
int
passthroughEncoding
=
getPassthroughEncoding
(
outputFormat
);
// TODO(b/112299307): Passthrough can have become unavailable since usePassthrough was called.
Assertions
.
checkState
(
passthroughEncoding
!=
C
.
ENCODING_INVALID
);
return
outputFormat
.
buildUpon
().
setEncoding
(
passthroughEncoding
).
build
();
}
/**
* Returns whether the device's decoders are known to not support setting the codec operating
* rate.
...
...
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
View file @
54156838
...
...
@@ -1514,19 +1514,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
}
/**
* Called when the output {@link Format} changes in bypass mode (no codec used).
*
* <p>The default implementation is a no-op.
*
* @param outputFormat The new output {@link MediaFormat}.
* @throws ExoPlaybackException Thrown if an error occurs handling the new output media format.
*/
// TODO(b/154849417): merge with {@link #onOutputFormatChanged(Format)}.
protected
void
onOutputBypassFormatChanged
(
Format
outputFormat
)
throws
ExoPlaybackException
{
// Do nothing.
}
/**
* Handles supplemental data associated with an input buffer.
*
* <p>The default implementation is a no-op.
...
...
@@ -2132,7 +2119,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
if
(!
batchBuffer
.
isEmpty
()
&&
waitingForFirstSampleInFormat
)
{
// This is the first buffer in a new format, the output format must be updated.
outputFormat
=
Assertions
.
checkNotNull
(
inputFormat
);
onOutput
Bypass
FormatChanged
(
outputFormat
);
onOutputFormatChanged
(
outputFormat
);
waitingForFirstSampleInFormat
=
false
;
}
...
...
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