mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-22 16:16:39 +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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ public class LibraryHelper {
|
|||||||
private static final HashSet<String> avcDependencies = new HashSet<String>();
|
private static final HashSet<String> avcDependencies = new HashSet<String>();
|
||||||
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");
|
||||||
@@ -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