diff options
| author | Ac_K <Acoustik666@gmail.com> | 2022-01-03 12:38:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-03 12:38:21 +0100 |
| commit | 16c649934fde134d7e8fc9539cf562dd129fbaac (patch) | |
| tree | c18540f5097debbc59f6b5b2f0d46e9a5dd15fff | |
| parent | e98abf182043630fd8fae1a20a3ddfe5fe56a313 (diff) | |
ffmpeg: Add extra checks and error messages (#2951)
* ffmpeg: Add extra checks and error messages
This PR adds some checks and logging error messages related to the ffmpeg context creation, that will prevent users to open issues because they don't have the correct packages installed.
Close #2762
* Update FFmpegContext.cs
| -rw-r--r-- | Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs b/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs index 1e3b88bb..e0ef05a5 100644 --- a/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs +++ b/Ryujinx.Graphics.Nvdec.FFmpeg/FFmpegContext.cs @@ -18,11 +18,35 @@ namespace Ryujinx.Graphics.Nvdec.FFmpeg public FFmpegContext(AVCodecID codecId) { _codec = ffmpeg.avcodec_find_decoder(codecId); + if (_codec == null) + { + Logger.Error?.PrintMsg(LogClass.FFmpeg, $"Codec wasn't found. Make sure you have the {codecId} codec present in your FFmpeg installation."); + + return; + } + _context = ffmpeg.avcodec_alloc_context3(_codec); + if (_context == null) + { + Logger.Error?.PrintMsg(LogClass.FFmpeg, "Codec context couldn't be allocated."); - ffmpeg.avcodec_open2(_context, _codec, null); + return; + } + + if (ffmpeg.avcodec_open2(_context, _codec, null) != 0) + { + Logger.Error?.PrintMsg(LogClass.FFmpeg, "Codec couldn't be opened."); + + return; + } _packet = ffmpeg.av_packet_alloc(); + if (_packet == null) + { + Logger.Error?.PrintMsg(LogClass.FFmpeg, "Packet couldn't be allocated."); + + return; + } _decodeFrame = Marshal.GetDelegateForFunctionPointer<AVCodec_decode>(_codec->decode.Pointer); } |
