mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Only update codecInfo when needed
This avoids calling getDecoderInfo repeatedly in the case where shouldInitCodec return false (e.g. because we don't have a surface and cannot instantiate a dummy surface). Issue: #677 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=157847702
This commit is contained in:
parent
c5cf9090fc
commit
35cc0d65cd
3 changed files with 25 additions and 26 deletions
|
|
@ -314,14 +314,14 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaCodecInfo codecInfo = null;
|
if (codecInfo == null) {
|
||||||
try {
|
try {
|
||||||
codecInfo = getDecoderInfo(mediaCodecSelector, format, drmSessionRequiresSecureDecoder);
|
codecInfo = getDecoderInfo(mediaCodecSelector, format, drmSessionRequiresSecureDecoder);
|
||||||
if (codecInfo == null && drmSessionRequiresSecureDecoder) {
|
if (codecInfo == null && drmSessionRequiresSecureDecoder) {
|
||||||
// The drm session indicates that a secure decoder is required, but the device does not have
|
// The drm session indicates that a secure decoder is required, but the device does not
|
||||||
// one. Assuming that supportsFormat indicated support for the media being played, we know
|
// have one. Assuming that supportsFormat indicated support for the media being played, we
|
||||||
// that it does not require a secure output path. Most CDM implementations allow playback to
|
// know that it does not require a secure output path. Most CDM implementations allow
|
||||||
// proceed with a non-secure decoder in this case, so we try our luck.
|
// playback to proceed with a non-secure decoder in this case, so we try our luck.
|
||||||
codecInfo = getDecoderInfo(mediaCodecSelector, format, false);
|
codecInfo = getDecoderInfo(mediaCodecSelector, format, false);
|
||||||
if (codecInfo != null) {
|
if (codecInfo != null) {
|
||||||
Log.w(TAG, "Drm session requires secure decoder for " + mimeType + ", but "
|
Log.w(TAG, "Drm session requires secure decoder for " + mimeType + ", but "
|
||||||
|
|
@ -338,12 +338,12 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
||||||
drmSessionRequiresSecureDecoder,
|
drmSessionRequiresSecureDecoder,
|
||||||
DecoderInitializationException.NO_SUITABLE_DECODER_ERROR));
|
DecoderInitializationException.NO_SUITABLE_DECODER_ERROR));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!shouldInitCodec(codecInfo)) {
|
if (!shouldInitCodec(codecInfo)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.codecInfo = codecInfo;
|
|
||||||
String codecName = codecInfo.name;
|
String codecName = codecInfo.name;
|
||||||
codecNeedsDiscardToSpsWorkaround = codecNeedsDiscardToSpsWorkaround(codecName, format);
|
codecNeedsDiscardToSpsWorkaround = codecNeedsDiscardToSpsWorkaround(codecName, format);
|
||||||
codecNeedsFlushWorkaround = codecNeedsFlushWorkaround(codecName);
|
codecNeedsFlushWorkaround = codecNeedsFlushWorkaround(codecName);
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,7 @@ public interface MediaCodecSelector {
|
||||||
/**
|
/**
|
||||||
* Selects a decoder to instantiate for audio passthrough.
|
* Selects a decoder to instantiate for audio passthrough.
|
||||||
*
|
*
|
||||||
* @return A {@link MediaCodecInfo} describing the decoder, or null if no suitable decoder
|
* @return A {@link MediaCodecInfo} describing the decoder, or null if no suitable decoder exists.
|
||||||
* exists.
|
|
||||||
* @throws DecoderQueryException Thrown if there was an error querying decoders.
|
* @throws DecoderQueryException Thrown if there was an error querying decoders.
|
||||||
*/
|
*/
|
||||||
MediaCodecInfo getPassthroughDecoderInfo() throws DecoderQueryException;
|
MediaCodecInfo getPassthroughDecoderInfo() throws DecoderQueryException;
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ public final class MediaCodecUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information about a decoder suitable for audio passthrough.
|
* Returns information about a decoder suitable for audio passthrough.
|
||||||
**
|
*
|
||||||
* @return A {@link MediaCodecInfo} describing the decoder, or null if no suitable decoder
|
* @return A {@link MediaCodecInfo} describing the decoder, or null if no suitable decoder
|
||||||
* exists.
|
* exists.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue