Fixed all the issues caused by merging

This commit is contained in:
Diego Waxemberg
2013-12-29 13:40:59 -05:00
parent 6b06df4b82
commit f043a505ea
4 changed files with 12 additions and 72 deletions

View File

@@ -1,7 +1,5 @@
package com.limelight;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
@@ -42,60 +40,6 @@ public class Limelight implements NvConnectionListener {
this.host = host;
}
/*
* Extracts native library into current directory. This is required in order for the library to
* be found when trying to load it.
*/
private static void extractNativeLibrary(String libraryName, String targetDirectory) throws IOException {
InputStream resource = new Object().getClass().getResourceAsStream("/binlib/"+libraryName);
if (resource == null) {
throw new FileNotFoundException("Unable to find native library in JAR: "+libraryName);
}
File destination = new File(targetDirectory+File.separatorChar+libraryName);
// this will only delete it if it exists, and then create a new file
destination.delete();
destination.createNewFile();
//this is the janky java 6 way to copy a file
FileOutputStream fos = null;
try {
fos = new FileOutputStream(destination);
int read;
byte[] readBuffer = new byte[16384];
while ((read = resource.read(readBuffer)) != -1) {
fos.write(readBuffer, 0, read);
}
} finally {
if (fos != null) {
fos.close();
}
}
}
/*
* Checks the OS and decides which libraries need to be extracted.
*/
private static void prepareNativeLibraries() throws IOException {
if (!System.getProperty("os.name").contains("Windows")) {
// Nothing to do for platforms other than Windows
return;
}
// We need to extract nv_avc_dec's runtime dependencies manually
// because the current JRE extracts them with different file names
// so they don't load properly.
String nativeLibDir = ".";
extractNativeLibrary("avfilter-3.dll", nativeLibDir);
extractNativeLibrary("avformat-55.dll", nativeLibDir);
extractNativeLibrary("avutil-52.dll", nativeLibDir);
extractNativeLibrary("postproc-52.dll", nativeLibDir);
extractNativeLibrary("pthreadVC2.dll", nativeLibDir);
extractNativeLibrary("swresample-0.dll", nativeLibDir);
extractNativeLibrary("swscale-2.dll", nativeLibDir);
extractNativeLibrary("avcodec-55.dll", nativeLibDir);
}
/*
* Creates a connection to the host and starts up the stream.
*/
@@ -106,7 +50,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(),

View File

@@ -79,14 +79,6 @@ public class JavaxAudioRenderer implements AudioRenderer {
}
}
/**
* The callback for the audio stream being initialized and starting to receive.
* @param channelCount the number of channels in the audio
* @param sampleRate the sample rate for the audio.
*/
@Override
public void streamInitialized(int channelCount, int sampleRate) {
private void createSoundLine(int bufferSize) {
AudioFormat audioFormat = new AudioFormat(sampleRate, 16, channelCount, true, true);
@@ -117,6 +109,11 @@ public class JavaxAudioRenderer implements AudioRenderer {
}
}
/**
* The callback for the audio stream being initialized and starting to receive.
* @param channelCount the number of channels in the audio
* @param sampleRate the sample rate for the audio.
*/
@Override
public void streamInitialized(int channelCount, int sampleRate) {
this.channelCount = channelCount;

View File

@@ -80,6 +80,9 @@ public class GamepadConfigFrame extends JFrame {
for (int i = 0; i < components.length; i++) {
Mapping mapping = config.get(components[i]);
if (mapping == null) {
mapping = config.new Mapping(components[i], false, false);
}
Box componentBox = createComponentBox(mapping);
mainPanel.add(componentBox);

View File

@@ -50,8 +50,6 @@ public class StreamFrame extends JFrame {
private Cursor noCursor;
private Limelight limelight;
private NvConnection conn;
/**
* Frees the mouse ie. makes it visible and allowed to move outside the frame.
*/
@@ -68,17 +66,15 @@ public class StreamFrame extends JFrame {
hideCursor();
}
public void build(Limelight limelight, NvConnection conn, StreamConfiguration streamConfig, boolean fullscreen) {
this.limelight = limelight;
/**
* Builds the components of this frame with the specified configurations.
* @param conn the connection this frame belongs to
* @param streamConfig the configurations for this frame
* @param fullscreen if the frame should be made fullscreen
*/
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);