Fix meizu deadlock

Some devices (Meizu) assume that the video encoding thread has a
Looper. By moving video encoding to a separate thread, commit
feab87053a broke this assumption.

Call Looper.prepare() from this thread to fix the problem.

Fixes #4143 <https://github.com/Genymobile/scrcpy/issues/4143>
This commit is contained in:
Romain Vimont 2023-07-13 21:43:52 +02:00
parent 01d785d9a3
commit 7e936fa879

View file

@ -8,6 +8,7 @@ import android.media.MediaCodecInfo;
import android.media.MediaFormat;
import android.os.Build;
import android.os.IBinder;
import android.os.Looper;
import android.os.SystemClock;
import android.view.Surface;
@ -285,6 +286,10 @@ public class ScreenEncoder implements Device.RotationListener, Device.FoldListen
@Override
public void start(TerminationListener listener) {
thread = new Thread(() -> {
// Some devices (Meizu) deadlock if the video encoding thread has no Looper
// <https://github.com/Genymobile/scrcpy/issues/4143>
Looper.prepare();
try {
streamScreen();
} catch (ConfigurationException e) {