mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-23 00:26:42 +00:00
Fix library loading on Windows when not using a JAR
This commit is contained in:
@@ -100,11 +100,7 @@ public class Limelight implements NvConnectionListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
LibraryHelper.prepareNativeLibraries();
|
||||||
LibraryHelper.prepareNativeLibraries();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// This is expected to fail when not in a JAR
|
|
||||||
}
|
|
||||||
|
|
||||||
createFrame();
|
createFrame();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ public class LibraryHelper {
|
|||||||
private static final boolean needsDependencyExtraction;
|
private static final boolean needsDependencyExtraction;
|
||||||
private static final String libraryExtractionFolder;
|
private static final String libraryExtractionFolder;
|
||||||
|
|
||||||
|
private static boolean librariesExtracted = false;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
needsDependencyExtraction = System.getProperty("os.name", "").contains("Windows");
|
needsDependencyExtraction = System.getProperty("os.name", "").contains("Windows");
|
||||||
libraryExtractionFolder = System.getProperty("java.io.tmpdir", ".");
|
libraryExtractionFolder = System.getProperty("java.io.tmpdir", ".");
|
||||||
@@ -35,7 +37,7 @@ public class LibraryHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void loadNativeLibrary(String libraryName) {
|
public static void loadNativeLibrary(String libraryName) {
|
||||||
if (needsDependencyExtraction && avcDependencies.contains(libraryName)) {
|
if (librariesExtracted && avcDependencies.contains(libraryName)) {
|
||||||
System.load(libraryExtractionFolder + File.separatorChar + System.mapLibraryName(libraryName));
|
System.load(libraryExtractionFolder + File.separatorChar + System.mapLibraryName(libraryName));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -43,14 +45,21 @@ public class LibraryHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void prepareNativeLibraries() throws IOException {
|
public static void prepareNativeLibraries() {
|
||||||
if (!needsDependencyExtraction) {
|
if (!needsDependencyExtraction) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String dependency : avcDependencies) {
|
try {
|
||||||
extractNativeLibrary(dependency);
|
for (String dependency : avcDependencies) {
|
||||||
|
extractNativeLibrary(dependency);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// This is expected if this code is not running from a JAR
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
librariesExtracted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void extractNativeLibrary(String libraryName) throws IOException {
|
private static void extractNativeLibrary(String libraryName) throws IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user