libav: log more error codes as string

This commit is contained in:
Megamouse 2022-04-20 23:44:22 +02:00
parent f1a37da94c
commit d8bbec9594
4 changed files with 65 additions and 21 deletions

View file

@ -6,6 +6,7 @@
#include "Emu/Cell/lv2/sys_ppu_thread.h"
#include "Emu/Cell/lv2/sys_process.h"
#include "sysPrxForUser.h"
#include "util/media_utils.h"
#ifdef _MSC_VER
#pragma warning(push, 0)
@ -172,15 +173,29 @@ struct vdec_context final
}
AVDictionary* opts{};
av_dict_set(&opts, "refcounted_frames", "1", 0);
int err = av_dict_set(&opts, "refcounted_frames", "1", 0);
if (err < 0)
{
avcodec_free_context(&ctx);
fmt::throw_exception("av_dict_set(refcounted_frames, 1) failed (err=0x%x='%s')", err, utils::av_error_to_string(err));
}
std::lock_guard lock(g_mutex_avcodec_open2);
int err = avcodec_open2(ctx, codec, &opts);
err = avcodec_open2(ctx, codec, &opts);
if (err || opts)
{
avcodec_free_context(&ctx);
fmt::throw_exception("avcodec_open2() failed (err=0x%x, opts=%d)", err, opts ? 1 : 0);
std::string dict_content;
if (opts)
{
AVDictionaryEntry* tag = nullptr;
while ((tag = av_dict_get(opts, "", tag, AV_DICT_IGNORE_SUFFIX)))
{
fmt::append(dict_content, "['%s': '%s']", tag->key, tag->value);
}
}
fmt::throw_exception("avcodec_open2() failed (err=0x%x='%s', opts=%s)", err, utils::av_error_to_string(err), dict_content);
}
}