mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-05 07:26:07 +00:00
Don't print stack traces for InterruptExceptions. Call the NvConnectionListener class to terminate the stream without causing the unexpected termination error dialog.
This commit is contained in:
@@ -27,7 +27,7 @@ public class Limelight implements NvConnectionListener {
|
||||
private String host;
|
||||
private StreamFrame streamFrame;
|
||||
private NvConnection conn;
|
||||
private boolean connectionFailed;
|
||||
private boolean connectionTerminating;
|
||||
private static JFrame limeFrame;
|
||||
|
||||
public Limelight(String host) {
|
||||
@@ -88,7 +88,7 @@ public class Limelight implements NvConnectionListener {
|
||||
StreamConfiguration streamConfig = createConfiguration(prefs.getResolution());
|
||||
|
||||
conn = new NvConnection(host, this, streamConfig);
|
||||
streamFrame.build(conn, streamConfig, prefs.getFullscreen());
|
||||
streamFrame.build(this, conn, streamConfig, prefs.getFullscreen());
|
||||
conn.start(PlatformBinding.getDeviceName(), streamFrame,
|
||||
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
||||
PlatformBinding.getAudioRenderer(),
|
||||
@@ -157,6 +157,11 @@ public class Limelight implements NvConnectionListener {
|
||||
|
||||
createFrame();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
connectionTerminating = true;
|
||||
conn.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stageStarting(Stage stage) {
|
||||
@@ -183,9 +188,11 @@ public class Limelight implements NvConnectionListener {
|
||||
|
||||
@Override
|
||||
public void connectionTerminated(Exception e) {
|
||||
e.printStackTrace();
|
||||
if (!connectionFailed) {
|
||||
connectionFailed = true;
|
||||
if (!(e instanceof InterruptedException)) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!connectionTerminating) {
|
||||
connectionTerminating = true;
|
||||
|
||||
// Kill the connection to the target
|
||||
conn.stop();
|
||||
|
||||
@@ -24,6 +24,7 @@ import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
|
||||
import com.limelight.Limelight;
|
||||
import com.limelight.input.KeyboardHandler;
|
||||
import com.limelight.input.MouseHandler;
|
||||
import com.limelight.nvstream.NvConnection;
|
||||
@@ -41,7 +42,7 @@ public class StreamFrame extends JFrame {
|
||||
private JProgressBar spinner;
|
||||
private JLabel spinnerLabel;
|
||||
private Cursor noCursor;
|
||||
private NvConnection conn;
|
||||
private Limelight limelight;
|
||||
|
||||
public void freeMouse() {
|
||||
mouse.free();
|
||||
@@ -53,8 +54,8 @@ public class StreamFrame extends JFrame {
|
||||
hideCursor();
|
||||
}
|
||||
|
||||
public void build(NvConnection conn, StreamConfiguration streamConfig, boolean fullscreen) {
|
||||
this.conn = conn;
|
||||
public void build(Limelight limelight, NvConnection conn, StreamConfiguration streamConfig, boolean fullscreen) {
|
||||
this.limelight = limelight;
|
||||
|
||||
keyboard = new KeyboardHandler(conn, this);
|
||||
mouse = new MouseHandler(conn, this);
|
||||
@@ -224,7 +225,7 @@ public class StreamFrame extends JFrame {
|
||||
}
|
||||
|
||||
public void close() {
|
||||
limelight.stop();
|
||||
dispose();
|
||||
conn.stop();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user