From a2c57de204f9d82315153ab9384eab651f5ebe9b Mon Sep 17 00:00:00 2001 From: Ac_K Date: Thu, 20 May 2021 01:10:46 +0200 Subject: [PATCH] Move code to FFmpegContext --- Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs | 33 ++++++++++++++++++++ Ryujinx/Program.cs | 25 --------------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs b/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs index c402c574b..31f37ca00 100644 --- a/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs +++ b/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs @@ -1,6 +1,8 @@ using FFmpeg.AutoGen; using Ryujinx.Common.Logging; using System; +using System.Diagnostics; +using System.IO; using System.Runtime.InteropServices; namespace Ryujinx.Graphics.Nvdec.H264 @@ -14,6 +16,8 @@ namespace Ryujinx.Graphics.Nvdec.H264 public FFmpegContext() { + SetRootPath(); + _logFunc = Log; // Redirect log output @@ -28,6 +32,35 @@ namespace Ryujinx.Graphics.Nvdec.H264 _packet = ffmpeg.av_packet_alloc(); } + private void SetRootPath() + { + if (OperatingSystem.IsLinux()) + { + // Configure FFmpeg search path + Process lddProcess = Process.Start(new ProcessStartInfo + { + FileName = "/bin/sh", + Arguments = "-c \"ldd $(which ffmpeg 2>/dev/null) | grep libavfilter\" 2>/dev/null", + UseShellExecute = false, + RedirectStandardOutput = true + }); + + string lddOutput = lddProcess.StandardOutput.ReadToEnd(); + + lddProcess.WaitForExit(); + lddProcess.Close(); + + if (lddOutput.Contains(" => ")) + { + ffmpeg.RootPath = Path.GetDirectoryName(lddOutput.Split(" => ")[1]); + } + else + { + Logger.Error?.PrintMsg(LogClass.FFmpeg, "FFmpeg wasn't found. Make sure that you have it installed and up to date."); + } + } + } + private void Log(void* p0, int level, string format, byte* vl) { if (level > ffmpeg.av_log_get_level()) diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs index 4e080cf21..fbdea7de6 100644 --- a/Ryujinx/Program.cs +++ b/Ryujinx/Program.cs @@ -1,5 +1,4 @@ using ARMeilleure.Translation.PTC; -using FFmpeg.AutoGen; using Gtk; using Ryujinx.Common.Configuration; using Ryujinx.Common.GraphicsDriver; @@ -12,7 +11,6 @@ using Ryujinx.Ui; using Ryujinx.Ui.Widgets; using SixLabors.ImageSharp.Formats.Jpeg; using System; -using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.InteropServices; @@ -79,29 +77,6 @@ namespace Ryujinx if (OperatingSystem.IsLinux()) { XInitThreads(); - - // Configure FFmpeg search path - Process lddProcess = Process.Start(new ProcessStartInfo - { - FileName = "/bin/sh", - Arguments = "-c \"ldd $(which ffmpeg) | grep libavfilter\"", - UseShellExecute = false, - RedirectStandardOutput = true - }); - - string lddOutput = lddProcess.StandardOutput.ReadToEnd(); - - lddProcess.WaitForExit(); - lddProcess.Close(); - - if (lddOutput.Contains(" => ")) - { - ffmpeg.RootPath = Path.GetDirectoryName(lddOutput.Split(" => ")[1]); - } - else - { - Logger.Error?.PrintMsg(LogClass.FFmpeg, "FFmpeg wasn't found. Make sure that you have it installed and up to date."); - } } string systemPath = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);