Browse Source

fix nvidia capabilities on windows (#2530)

pull/2531/head
Jason Dove 7 months ago committed by GitHub
parent
commit
da4687ac0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 60
      ErsatzTV/Services/RunOnce/PlatformSettingsService.cs

60
ErsatzTV/Services/RunOnce/PlatformSettingsService.cs

@ -15,38 +15,44 @@ public class PlatformSettingsService(IServiceScopeFactory serviceScopeFactory) : @@ -15,38 +15,44 @@ public class PlatformSettingsService(IServiceScopeFactory serviceScopeFactory) :
using IServiceScope scope = serviceScopeFactory.CreateScope();
IRuntimeInfo runtimeInfo = scope.ServiceProvider.GetRequiredService<IRuntimeInfo>();
if (runtimeInfo != null && runtimeInfo.IsOSPlatform(OSPlatform.Linux))
if (runtimeInfo != null)
{
try
if (runtimeInfo.IsOSPlatform(OSPlatform.Linux) || runtimeInfo.IsOSPlatform(OSPlatform.Windows))
{
NvEncSharpRedirector.Init();
try
{
NvEncSharpRedirector.Init();
}
catch (FileNotFoundException)
{
// do nothing
}
}
catch (FileNotFoundException)
{
// do nothing
}
if (Directory.Exists("/dev/dri"))
{
ILocalFileSystem localFileSystem = scope.ServiceProvider.GetRequiredService<ILocalFileSystem>();
IMemoryCache memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
var devices = localFileSystem.ListFiles("/dev/dri")
.Filter(s => s.StartsWith("/dev/dri/render", StringComparison.OrdinalIgnoreCase)
|| s.StartsWith("/dev/dri/card", StringComparison.OrdinalIgnoreCase))
.ToList();
memoryCache.Set("ffmpeg.render_devices", devices);
}
IHardwareCapabilitiesFactory hardwareCapabilitiesFactory =
scope.ServiceProvider.GetRequiredService<IHardwareCapabilitiesFactory>();
if (hardwareCapabilitiesFactory != null)
if (runtimeInfo.IsOSPlatform(OSPlatform.Linux))
{
IMemoryCache memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
List<string> displays = await hardwareCapabilitiesFactory.GetVaapiDisplays();
memoryCache.Set("ffmpeg.vaapi_displays", displays);
if (Directory.Exists("/dev/dri"))
{
ILocalFileSystem localFileSystem = scope.ServiceProvider.GetRequiredService<ILocalFileSystem>();
IMemoryCache memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
var devices = localFileSystem.ListFiles("/dev/dri")
.Filter(s => s.StartsWith("/dev/dri/render", StringComparison.OrdinalIgnoreCase)
|| s.StartsWith("/dev/dri/card", StringComparison.OrdinalIgnoreCase))
.ToList();
memoryCache.Set("ffmpeg.render_devices", devices);
}
IHardwareCapabilitiesFactory hardwareCapabilitiesFactory =
scope.ServiceProvider.GetRequiredService<IHardwareCapabilitiesFactory>();
if (hardwareCapabilitiesFactory != null)
{
IMemoryCache memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
List<string> displays = await hardwareCapabilitiesFactory.GetVaapiDisplays();
memoryCache.Set("ffmpeg.vaapi_displays", displays);
}
}
}
}

Loading…
Cancel
Save