From f675d26a5d15ade72e41a5ba899ba80aed3c396d Mon Sep 17 00:00:00 2001 From: Ac_K Date: Thu, 20 May 2021 01:42:21 +0200 Subject: [PATCH] lazy initialization --- Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs b/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs index 17de1a03a..606eeade3 100644 --- a/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs +++ b/Ryujinx.Graphics.Nvdec.H264/FFmpegContext.cs @@ -4,11 +4,14 @@ using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; +using System.Threading; namespace Ryujinx.Graphics.Nvdec.H264 { unsafe class FFmpegContext : IDisposable { + private static int _isInitialized; + private readonly av_log_set_callback_callback _logFunc; private readonly AVCodec* _codec; private AVPacket* _packet; @@ -32,7 +35,10 @@ namespace Ryujinx.Graphics.Nvdec.H264 static FFmpegContext() { - SetRootPath(); + if (Interlocked.Exchange(ref _isInitialized, 1) == 0) + { + SetRootPath(); + } } private static void SetRootPath()