mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +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,36 +314,36 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
MediaCodecInfo codecInfo = null;
|
||||
try {
|
||||
codecInfo = getDecoderInfo(mediaCodecSelector, format, drmSessionRequiresSecureDecoder);
|
||||
if (codecInfo == null && drmSessionRequiresSecureDecoder) {
|
||||
// The drm session indicates that a secure decoder is required, but the device does not have
|
||||
// one. Assuming that supportsFormat indicated support for the media being played, we know
|
||||
// that it does not require a secure output path. Most CDM implementations allow playback to
|
||||
// proceed with a non-secure decoder in this case, so we try our luck.
|
||||
codecInfo = getDecoderInfo(mediaCodecSelector, format, false);
|
||||
if (codecInfo != null) {
|
||||
Log.w(TAG, "Drm session requires secure decoder for " + mimeType + ", but "
|
||||
+ "no secure decoder available. Trying to proceed with " + codecInfo.name + ".");
|
||||
}
|
||||
}
|
||||
} catch (DecoderQueryException e) {
|
||||
throwDecoderInitError(new DecoderInitializationException(format, e,
|
||||
drmSessionRequiresSecureDecoder, DecoderInitializationException.DECODER_QUERY_ERROR));
|
||||
}
|
||||
|
||||
if (codecInfo == null) {
|
||||
throwDecoderInitError(new DecoderInitializationException(format, null,
|
||||
drmSessionRequiresSecureDecoder,
|
||||
DecoderInitializationException.NO_SUITABLE_DECODER_ERROR));
|
||||
try {
|
||||
codecInfo = getDecoderInfo(mediaCodecSelector, format, drmSessionRequiresSecureDecoder);
|
||||
if (codecInfo == null && drmSessionRequiresSecureDecoder) {
|
||||
// The drm session indicates that a secure decoder is required, but the device does not
|
||||
// have one. Assuming that supportsFormat indicated support for the media being played, we
|
||||
// know that it does not require a secure output path. Most CDM implementations allow
|
||||
// playback to proceed with a non-secure decoder in this case, so we try our luck.
|
||||
codecInfo = getDecoderInfo(mediaCodecSelector, format, false);
|
||||
if (codecInfo != null) {
|
||||
Log.w(TAG, "Drm session requires secure decoder for " + mimeType + ", but "
|
||||
+ "no secure decoder available. Trying to proceed with " + codecInfo.name + ".");
|
||||
}
|
||||
}
|
||||
} catch (DecoderQueryException e) {
|
||||
throwDecoderInitError(new DecoderInitializationException(format, e,
|
||||
drmSessionRequiresSecureDecoder, DecoderInitializationException.DECODER_QUERY_ERROR));
|
||||
}
|
||||
|
||||
if (codecInfo == null) {
|
||||
throwDecoderInitError(new DecoderInitializationException(format, null,
|
||||
drmSessionRequiresSecureDecoder,
|
||||
DecoderInitializationException.NO_SUITABLE_DECODER_ERROR));
|
||||
}
|
||||
}
|
||||
|
||||
if (!shouldInitCodec(codecInfo)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.codecInfo = codecInfo;
|
||||
String codecName = codecInfo.name;
|
||||
codecNeedsDiscardToSpsWorkaround = codecNeedsDiscardToSpsWorkaround(codecName, format);
|
||||
codecNeedsFlushWorkaround = codecNeedsFlushWorkaround(codecName);
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ public interface MediaCodecSelector {
|
|||
/**
|
||||
* Selects a decoder to instantiate for audio passthrough.
|
||||
*
|
||||
* @return A {@link MediaCodecInfo} describing the decoder, or null if no suitable decoder
|
||||
* exists.
|
||||
* @return A {@link MediaCodecInfo} describing the decoder, or null if no suitable decoder exists.
|
||||
* @throws DecoderQueryException Thrown if there was an error querying decoders.
|
||||
*/
|
||||
MediaCodecInfo getPassthroughDecoderInfo() throws DecoderQueryException;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public final class MediaCodecUtil {
|
|||
|
||||
/**
|
||||
* Returns information about a decoder suitable for audio passthrough.
|
||||
**
|
||||
*
|
||||
* @return A {@link MediaCodecInfo} describing the decoder, or null if no suitable decoder
|
||||
* exists.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue