diff --git a/src/Library/Sucrose.Mpv.NET/API/MpvFunctions.cs b/src/Library/Sucrose.Mpv.NET/API/MpvFunctions.cs index bc2e37f96..7bf2a1a40 100644 --- a/src/Library/Sucrose.Mpv.NET/API/MpvFunctions.cs +++ b/src/Library/Sucrose.Mpv.NET/API/MpvFunctions.cs @@ -62,6 +62,11 @@ private void LoadDll(string dllPath) { Guard.AgainstNullOrEmptyOrWhiteSpaceString(dllPath, nameof(dllPath)); + if (!File.Exists(dllPath)) + { + throw new DllNotFoundException($"Failed to load Mpv DLL. File not found: {dllPath}"); + } + dllHandle = PlatformDll.Utils.LoadLibrary(dllPath); if (dllHandle == IntPtr.Zero) diff --git a/src/Live/Sucrose.Live.MpvPlayer/Sucrose.Live.MpvPlayer.csproj b/src/Live/Sucrose.Live.MpvPlayer/Sucrose.Live.MpvPlayer.csproj index 3fb0405fa..5b766c013 100644 --- a/src/Live/Sucrose.Live.MpvPlayer/Sucrose.Live.MpvPlayer.csproj +++ b/src/Live/Sucrose.Live.MpvPlayer/Sucrose.Live.MpvPlayer.csproj @@ -105,6 +105,9 @@ + + Always + Always diff --git a/src/Live/Sucrose.Live.MpvPlayer/lib/mpv.conf b/src/Live/Sucrose.Live.MpvPlayer/lib/mpv.conf new file mode 100644 index 000000000..e4b009f7c --- /dev/null +++ b/src/Live/Sucrose.Live.MpvPlayer/lib/mpv.conf @@ -0,0 +1,25 @@ +# Video Settings +vo=gpu +hwdec=auto +hwdec-codecs=all +profile=low-latency +interpolation=no +framedrop=decoder +fullscreen=yes +scale-antiring=0 +temporal-dither=no + +# Audio Settings +audio-buffer=0.2 +audio-channels=stereo +volume-max=100 +audio-samplerate=48000 + +# General Performance Settings +cache=no +gpu-context=win +video-sync=display-desync +demuxer-seekable-cache=no +demuxer-max-bytes=64M +demuxer-max-back-bytes=16M +keep-open=no \ No newline at end of file diff --git a/src/Portal/Sucrose.Portal/Extension/ImageLoader.cs b/src/Portal/Sucrose.Portal/Extension/ImageLoader.cs index 2b25e91b5..77c90ca0c 100644 --- a/src/Portal/Sucrose.Portal/Extension/ImageLoader.cs +++ b/src/Portal/Sucrose.Portal/Extension/ImageLoader.cs @@ -129,14 +129,20 @@ public void Dispose() { Clear(); + GC.Collect(); GC.SuppressFinalize(this); + GC.SuppressFinalize(SPMI.Images); + GC.SuppressFinalize(SPMI.ImageStream); } public async ValueTask DisposeAsync() { await ClearAsync(); + GC.Collect(); GC.SuppressFinalize(this); + GC.SuppressFinalize(SPMI.Images); + GC.SuppressFinalize(SPMI.ImageStream); } } } \ No newline at end of file diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/Manage/Internal.cs b/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/Manage/Internal.cs index 62c2b530a..249350beb 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/Manage/Internal.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/Manage/Internal.cs @@ -1,4 +1,6 @@ -using MediaEngine = Sucrose.Mpv.NET.Player.MpvPlayer; +using System.IO; +using MediaEngine = Sucrose.Mpv.NET.Player.MpvPlayer; +using SSSMI = Sucrose.Shared.Space.Manage.Internal; namespace Sucrose.Shared.Engine.MpvPlayer.Manage { @@ -8,12 +10,16 @@ internal static class Internal public static MediaEngine MediaEngine; + public static readonly string LibPath = Path.Combine(SSSMI.This, "lib"); + + public static readonly string MpvConfig = Path.Combine(LibPath, "mpv.conf"); + #if X86 - public static readonly string MediaPath = @"lib\libmpv-x86.dll"; + public static readonly string MediaPath = Path.Combine(LibPath, "libmpv-x86.dll"); #elif X64 - public static readonly string MediaPath = @"lib\libmpv-x64.dll"; + public static readonly string MediaPath = Path.Combine(LibPath, "libmpv-x64.dll"); #else - public static readonly string MediaPath = @"lib\libmpv-ARM64.dll"; + public static readonly string MediaPath = Path.Combine(LibPath, "libmpv-ARM64.dll"); #endif } diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Gif.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Gif.xaml.cs index d8c2c56dc..a437b1eea 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Gif.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Gif.xaml.cs @@ -33,6 +33,8 @@ public Gif() Loop = SSEHD.GetLoop() }; + SSEMPMI.MediaEngine.LoadConfig(SSEMPMI.MpvConfig); + SSEMPMI.MediaEngine.Load(SSEMPMI.Source); SSEMI.GeneralTimer.Tick += new EventHandler(GeneralTimer_Tick); diff --git a/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Video.xaml.cs b/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Video.xaml.cs index c8fa12fcb..f68bb558b 100644 --- a/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Video.xaml.cs +++ b/src/Shared/Engine/Sucrose.Shared.Engine.MpvPlayer/View/Video.xaml.cs @@ -35,6 +35,8 @@ public Video() Volume = SSEHD.GetVolume() }; + SSEMPMI.MediaEngine.LoadConfig(SSEMPMI.MpvConfig); + SSEMPMI.MediaEngine.Load(SSEMPMI.Source); SSEMI.GeneralTimer.Tick += new EventHandler(GeneralTimer_Tick);