From 8a694a97855333849976bea5e558eaa45add0168 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 30 Nov 2019 10:44:49 +0100 Subject: [PATCH] Suggest workaround for error 0xfffffc0e When the hardware encoder is not able to encode at the given definition, it fails with an error 0xfffffc0e. It is documented in the FAQ: But it is better to directly suggest the workaround in the console. --- .../main/java/com/genymobile/scrcpy/Server.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java index d4691e7c..87aeacac 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Server.java +++ b/server/src/main/java/com/genymobile/scrcpy/Server.java @@ -1,6 +1,8 @@ package com.genymobile.scrcpy; import android.graphics.Rect; +import android.media.MediaCodec; +import android.os.Build; import java.io.File; import java.io.IOException; @@ -133,11 +135,25 @@ public final class Server { } } + private static void suggestFix(Throwable e) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (e instanceof MediaCodec.CodecException) { + MediaCodec.CodecException mce = (MediaCodec.CodecException) e; + if (mce.getErrorCode() == 0xfffffc0e) { + Ln.e("The hardware encoder is not able to encode at the given definition."); + Ln.e("Try with a lower definition:"); + Ln.e(" scrcpy -m 1024"); + } + } + } + } + public static void main(String... args) throws Exception { Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { Ln.e("Exception on thread " + t, e); + suggestFix(e); } });