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:
parent
d4eeb1c84d
commit
62c0c1321f
1 changed files with 13 additions and 1 deletions
|
@ -47,8 +47,20 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||||
|
|
||||||
public void streamScreen(Device device, FileDescriptor fd) throws IOException {
|
public void streamScreen(Device device, FileDescriptor fd) throws IOException {
|
||||||
Workarounds.prepareMainLooper();
|
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);
|
MediaFormat format = createFormat(bitRate, maxFps, DEFAULT_I_FRAME_INTERVAL);
|
||||||
device.setRotationListener(this);
|
device.setRotationListener(this);
|
||||||
boolean alive;
|
boolean alive;
|
||||||
|
|
Loading…
Reference in a new issue