From 80c0780b7779acc27a563ee5acdd3ac645108763 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sun, 19 Feb 2023 15:24:08 +0100 Subject: [PATCH] Disable audio before Android 11 The permission "android.permission.RECORD_AUDIO" has been added for shell in Android 11. Moreover, on lower versions, it may make the server segfault on the device (happened on a Nexus 5 with Android 6.0.1). Refs PR #3757 --- .../src/main/java/com/genymobile/scrcpy/AudioEncoder.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java b/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java index 8bc25e8e..d06898d6 100644 --- a/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java @@ -203,6 +203,12 @@ public final class AudioEncoder { @TargetApi(Build.VERSION_CODES.M) public void encode() throws IOException { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { + Ln.w("Audio disabled: it is not supported before Android 11"); + streamer.writeDisableStream(); + return; + } + MediaCodec mediaCodec = null; AudioRecord recorder = null;