File tree Expand file tree Collapse file tree 1 file changed +24
-5
lines changed
src/main/kotlin/dev/silenium/libs/ffmpeg Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -14,19 +14,38 @@ object FFmpeg {
1414 " swresample" ,
1515 " swscale" ,
1616 )
17- private var loaded = false
17+ private var loadedGPL = false
18+ private var loadedLGPL = false
1819
1920 @Synchronized
20- fun ensureLoaded (withGPL : Boolean = false) {
21- if (loaded) return
21+ fun ensureLoadedGPL (): Result <Unit > {
22+ if (loadedLGPL) return Result .failure(IllegalStateException (" GPL and LGPL libraries are mutually exclusive" ))
23+ if (loadedGPL) return Result .success(Unit )
2224
2325 libs.forEach {
2426 NativeLoader .loadLibraryFromClasspath(
2527 baseName = it,
26- platform = NativePlatform .platform(" -gpl" . takeIf { withGPL }.orEmpty() ),
28+ platform = NativePlatform .platform(" -gpl" ),
2729 )
2830 }
2931
30- loaded = true
32+ loadedGPL = true
33+ return Result .success(Unit )
34+ }
35+
36+ @Synchronized
37+ fun ensureLoadedLGPL (): Result <Unit > {
38+ if (loadedGPL) return Result .failure(IllegalStateException (" GPL and LGPL libraries are mutually exclusive" ))
39+ if (loadedLGPL) return Result .success(Unit )
40+
41+ libs.forEach {
42+ NativeLoader .loadLibraryFromClasspath(
43+ baseName = it,
44+ platform = NativePlatform .platform(),
45+ )
46+ }
47+
48+ loadedLGPL = true
49+ return Result .success(Unit )
3150 }
3251}
You can’t perform that action at this time.
0 commit comments