Skip to content

Commit 3935661

Browse files
committed
Add support to native Windows ARM64 with fallback to Win64
Wrap Windows ARM64 detection in #if !NET40 && !NETSTANDARD1_1 to fix CI running on NET40
1 parent 8d68fdd commit 3935661

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

src/LibVLCSharp/Shared/Core/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ internal static class Constants
3030

3131
internal static class ArchitectureNames
3232
{
33+
internal const string WinArm64 = "win-arm64";
3334
internal const string Win64 = "win-x64";
3435
internal const string Win86 = "win-x86";
3536
internal const string MacOS64 = "osx-x64";

src/LibVLCSharp/Shared/Core/Core.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ static internal bool LibVLCLoaded
7777
{
7878
arch = Path.Combine(ArchitectureNames.MacOS64, Constants.Lib);
7979
}
80+
81+
#if !NET40 && !NETSTANDARD1_1
82+
else if (PlatformHelper.IsWindows)
83+
{
84+
arch = RuntimeInformation.ProcessArchitecture switch
85+
{
86+
Architecture.X64 => ArchitectureNames.Win64,
87+
Architecture.X86 => ArchitectureNames.Win86,
88+
Architecture.Arm64 => ArchitectureNames.WinArm64,
89+
_ => arch = PlatformHelper.IsX64BitProcess ? ArchitectureNames.Win64 : ArchitectureNames.Win86
90+
};
91+
}
92+
#endif
93+
8094
else
8195
{
8296
arch = PlatformHelper.IsX64BitProcess ? ArchitectureNames.Win64 : ArchitectureNames.Win86;
@@ -117,6 +131,27 @@ static internal bool LibVLCLoaded
117131

118132
paths.Add((string.Empty, libvlcPath3));
119133

134+
// Add Win64 folders as fallback for WinArm64 to keep compatibility
135+
if (arch == ArchitectureNames.WinArm64)
136+
{
137+
var fallbackLibvlcDirPath1 = Path.Combine(Path.GetDirectoryName(libvlcAssemblyLocation)!,
138+
Constants.LibrariesRepositoryFolderName, ArchitectureNames.Win64);
139+
140+
var fallbackLibvlccorePath1 = LibVLCCorePath(fallbackLibvlcDirPath1);
141+
var fallbackLibvlcPath1 = LibVLCPath(fallbackLibvlcDirPath1);
142+
paths.Add((fallbackLibvlccorePath1, fallbackLibvlcPath1));
143+
144+
if (!string.IsNullOrEmpty(assemblyLocation))
145+
{
146+
var fallbackLibvlcDirPath2 = Path.Combine(Path.GetDirectoryName(assemblyLocation)!,
147+
Constants.LibrariesRepositoryFolderName, ArchitectureNames.Win64);
148+
149+
var fallbackLibvlccorePath2 = LibVLCCorePath(fallbackLibvlcDirPath2);
150+
var fallbackLibvlcPath2 = LibVLCPath(fallbackLibvlcDirPath2);
151+
paths.Add((fallbackLibvlccorePath2, fallbackLibvlcPath2));
152+
}
153+
}
154+
120155
if (PlatformHelper.IsMac)
121156
{
122157
var libvlcPath4 = Path.Combine(Path.Combine(Path.GetDirectoryName(libvlcAssemblyLocation)!,

0 commit comments

Comments
 (0)