mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 19:13:03 +00:00
Ensure MediaCodecHelper is initialized before evaluating codecs
This commit is contained in:
parent
a56689aea3
commit
bfa5a6349e
@ -38,6 +38,7 @@ public class MediaCodecHelper {
|
||||
private static final List<String> refFrameInvalidationHevcPrefixes;
|
||||
|
||||
private static boolean isLowEndSnapdragon = false;
|
||||
private static boolean initialized = false;
|
||||
|
||||
static {
|
||||
directSubmitPrefixes = new LinkedList<>();
|
||||
@ -171,6 +172,10 @@ public class MediaCodecHelper {
|
||||
}
|
||||
|
||||
public static void initialize(Context context, String glRenderer) {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
ActivityManager activityManager =
|
||||
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
ConfigurationInfo configInfo = activityManager.getDeviceConfigurationInfo();
|
||||
@ -214,9 +219,15 @@ public class MediaCodecHelper {
|
||||
blacklistedDecoderPrefixes.add("OMX.qcom.video.decoder.hevc");
|
||||
}
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
private static boolean isDecoderInList(List<String> decoderList, String decoderName) {
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("MediaCodecHelper must be initialized before use");
|
||||
}
|
||||
|
||||
for (String badPrefix : decoderList) {
|
||||
if (decoderName.length() >= badPrefix.length()) {
|
||||
String prefix = decoderName.substring(0, badPrefix.length());
|
||||
@ -374,6 +385,10 @@ public class MediaCodecHelper {
|
||||
// because we want to evaluate the decoders in our list's order
|
||||
// rather than MediaCodecList's order
|
||||
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("MediaCodecHelper must be initialized before use");
|
||||
}
|
||||
|
||||
for (String preferredDecoder : preferredDecoders) {
|
||||
for (MediaCodecInfo codecInfo : getMediaCodecList()) {
|
||||
// Skip encoders
|
||||
|
@ -134,6 +134,10 @@ public class StreamSettings extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
// This must be called to do runtime initialization before calling functions that evaluate
|
||||
// decoder lists.
|
||||
MediaCodecHelper.initialize(getContext(), GlPreferences.readPreferences(getContext()).glRenderer);
|
||||
|
||||
MediaCodecInfo avcDecoder = MediaCodecHelper.findProbableSafeDecoder("video/avc", -1);
|
||||
MediaCodecInfo hevcDecoder = MediaCodecHelper.findProbableSafeDecoder("video/hevc", -1);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user