mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-18 14:04:20 +01:00
Apply workarounds only on error
To avoid NullPointerException on some devices, workarounds have been implemented. But these workaround produce (harmless) internal errors causing exceptions to be printed in the console. To avoid this problem, apply the workarounds only if it fails without them. Fixes #994 <https://github.com/Genymobile/scrcpy/issues/994> Refs #365 <https://github.com/Genymobile/scrcpy/issues/365> Refs #940 <https://github.com/Genymobile/scrcpy/issues/940>
This commit is contained in:
@@ -47,8 +47,20 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||
|
||||
public void streamScreen(Device device, FileDescriptor fd) throws IOException {
|
||||
Workarounds.prepareMainLooper();
|
||||
Workarounds.fillAppInfo();
|
||||
|
||||
try {
|
||||
internalStreamScreen(device, fd);
|
||||
} catch (NullPointerException e) {
|
||||
// Retry with workarounds enabled:
|
||||
// <https://github.com/Genymobile/scrcpy/issues/365>
|
||||
// <https://github.com/Genymobile/scrcpy/issues/940>
|
||||
Ln.d("Applying workarounds to avoid NullPointerException");
|
||||
Workarounds.fillAppInfo();
|
||||
internalStreamScreen(device, fd);
|
||||
}
|
||||
}
|
||||
|
||||
private void internalStreamScreen(Device device, FileDescriptor fd) throws IOException {
|
||||
MediaFormat format = createFormat(bitRate, maxFps, DEFAULT_I_FRAME_INTERVAL);
|
||||
device.setRotationListener(this);
|
||||
boolean alive;
|
||||
|
||||
Reference in New Issue
Block a user