diff --git a/src/com/limelight/Limelight.java b/src/com/limelight/Limelight.java index 9b7f731..cae9efe 100644 --- a/src/com/limelight/Limelight.java +++ b/src/com/limelight/Limelight.java @@ -45,18 +45,24 @@ public class Limelight implements NvConnectionListener { */ private void startUp(StreamConfiguration streamConfig, List inputs) { conn = new NvConnection(host, this, streamConfig); - conn.start(PlatformBinding.getDeviceName(), null, - VideoDecoderRenderer.FLAG_PREFER_QUALITY, - PlatformBinding.getAudioRenderer(), - PlatformBinding.getVideoDecoderRenderer()); - + for (String input:inputs) { try { new EvdevHandler(conn, input).start(); } catch (FileNotFoundException ex) { displayError("Input", "Input (" + input + ") could not be found"); + return; + } catch (IOException ex) { + displayError("Input", "Input (" + input + ") could not be read"); + displayError("Input", "Are you running as root?"); + return; } - } + } + + conn.start(PlatformBinding.getDeviceName(), null, + VideoDecoderRenderer.FLAG_PREFER_QUALITY, + PlatformBinding.getAudioRenderer(), + PlatformBinding.getVideoDecoderRenderer()); } private void pair() { diff --git a/src/com/limelight/input/EvdevHandler.java b/src/com/limelight/input/EvdevHandler.java index 4b4a43b..013e137 100644 --- a/src/com/limelight/input/EvdevHandler.java +++ b/src/com/limelight/input/EvdevHandler.java @@ -4,6 +4,7 @@ import com.limelight.nvstream.NvConnection; import com.limelight.nvstream.input.KeyboardPacket; import com.limelight.nvstream.input.MouseButtonPacket; import java.awt.event.KeyEvent; +import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -167,9 +168,15 @@ public class EvdevHandler implements Runnable { private FileChannel deviceInput; private ByteBuffer inputBuffer; - public EvdevHandler(NvConnection conn, String device) throws FileNotFoundException { + public EvdevHandler(NvConnection conn, String device) throws FileNotFoundException, IOException { this.conn = conn; - FileInputStream in = new FileInputStream(device); + File file = new File(device); + if (!file.exists()) + throw new FileNotFoundException("File " + device + " not found"); + if (!file.canRead()) + throw new IOException("Can't read from " + device); + + FileInputStream in = new FileInputStream(file); deviceInput = in.getChannel(); inputBuffer = ByteBuffer.allocate(MAX_STRUCT_SIZE_BYTES); inputBuffer.order(ByteOrder.nativeOrder());