Add Android version check in raw audio recorder
Do not attempt to capture audio below Android 11, this may cause a segfault on the device. PR #3889 <https://github.com/Genymobile/scrcpy/pull/3889> Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
parent
669e9a8d1e
commit
fdf465851c
1 changed files with 7 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
package com.genymobile.scrcpy;
|
package com.genymobile.scrcpy;
|
||||||
|
|
||||||
import android.media.MediaCodec;
|
import android.media.MediaCodec;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
@ -19,6 +20,12 @@ public final class AudioRawRecorder implements AsyncProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void record() throws IOException, AudioCaptureForegroundException {
|
private void record() throws IOException, AudioCaptureForegroundException {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||||
|
Ln.w("Audio disabled: it is not supported before Android 11");
|
||||||
|
streamer.writeDisableStream(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final ByteBuffer buffer = ByteBuffer.allocateDirect(READ_SIZE);
|
final ByteBuffer buffer = ByteBuffer.allocateDirect(READ_SIZE);
|
||||||
final MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
|
final MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue