mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-24 09:06:45 +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 String host;
|
||||||
private StreamFrame streamFrame;
|
private StreamFrame streamFrame;
|
||||||
private NvConnection conn;
|
private NvConnection conn;
|
||||||
private boolean connectionFailed;
|
private boolean connectionTerminating;
|
||||||
private static JFrame limeFrame;
|
private static JFrame limeFrame;
|
||||||
|
|
||||||
public Limelight(String host) {
|
public Limelight(String host) {
|
||||||
@@ -88,7 +88,7 @@ public class Limelight implements NvConnectionListener {
|
|||||||
StreamConfiguration streamConfig = createConfiguration(prefs.getResolution());
|
StreamConfiguration streamConfig = createConfiguration(prefs.getResolution());
|
||||||
|
|
||||||
conn = new NvConnection(host, this, streamConfig);
|
conn = new NvConnection(host, this, streamConfig);
|
||||||
streamFrame.build(conn, streamConfig, prefs.getFullscreen());
|
streamFrame.build(this, conn, streamConfig, prefs.getFullscreen());
|
||||||
conn.start(PlatformBinding.getDeviceName(), streamFrame,
|
conn.start(PlatformBinding.getDeviceName(), streamFrame,
|
||||||
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
||||||
PlatformBinding.getAudioRenderer(),
|
PlatformBinding.getAudioRenderer(),
|
||||||
@@ -158,6 +158,11 @@ public class Limelight implements NvConnectionListener {
|
|||||||
createFrame();
|
createFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
connectionTerminating = true;
|
||||||
|
conn.stop();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stageStarting(Stage stage) {
|
public void stageStarting(Stage stage) {
|
||||||
System.out.println("Starting "+stage.getName());
|
System.out.println("Starting "+stage.getName());
|
||||||
@@ -183,9 +188,11 @@ public class Limelight implements NvConnectionListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionTerminated(Exception e) {
|
public void connectionTerminated(Exception e) {
|
||||||
e.printStackTrace();
|
if (!(e instanceof InterruptedException)) {
|
||||||
if (!connectionFailed) {
|
e.printStackTrace();
|
||||||
connectionFailed = true;
|
}
|
||||||
|
if (!connectionTerminating) {
|
||||||
|
connectionTerminating = true;
|
||||||
|
|
||||||
// Kill the connection to the target
|
// Kill the connection to the target
|
||||||
conn.stop();
|
conn.stop();
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import javax.swing.JOptionPane;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
|
|
||||||
|
import com.limelight.Limelight;
|
||||||
import com.limelight.input.KeyboardHandler;
|
import com.limelight.input.KeyboardHandler;
|
||||||
import com.limelight.input.MouseHandler;
|
import com.limelight.input.MouseHandler;
|
||||||
import com.limelight.nvstream.NvConnection;
|
import com.limelight.nvstream.NvConnection;
|
||||||
@@ -41,7 +42,7 @@ public class StreamFrame extends JFrame {
|
|||||||
private JProgressBar spinner;
|
private JProgressBar spinner;
|
||||||
private JLabel spinnerLabel;
|
private JLabel spinnerLabel;
|
||||||
private Cursor noCursor;
|
private Cursor noCursor;
|
||||||
private NvConnection conn;
|
private Limelight limelight;
|
||||||
|
|
||||||
public void freeMouse() {
|
public void freeMouse() {
|
||||||
mouse.free();
|
mouse.free();
|
||||||
@@ -53,8 +54,8 @@ public class StreamFrame extends JFrame {
|
|||||||
hideCursor();
|
hideCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(NvConnection conn, StreamConfiguration streamConfig, boolean fullscreen) {
|
public void build(Limelight limelight, NvConnection conn, StreamConfiguration streamConfig, boolean fullscreen) {
|
||||||
this.conn = conn;
|
this.limelight = limelight;
|
||||||
|
|
||||||
keyboard = new KeyboardHandler(conn, this);
|
keyboard = new KeyboardHandler(conn, this);
|
||||||
mouse = new MouseHandler(conn, this);
|
mouse = new MouseHandler(conn, this);
|
||||||
@@ -224,7 +225,7 @@ public class StreamFrame extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
limelight.stop();
|
||||||
dispose();
|
dispose();
|
||||||
conn.stop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user