Skip to content

Commit

Permalink
fix: fix #1457 again by moving av_err2str to a common header (#1688)
Browse files Browse the repository at this point in the history
  • Loading branch information
yretenai authored Dec 7, 2024
1 parent 8ee672f commit dad5953
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 30 deletions.
17 changes: 17 additions & 0 deletions src/common/support/avdec.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

// support header file for libav

// The av_err2str macro in libavutil/error.h does not play nice with C++
#ifdef av_err2str
#undef av_err2str
#include <string>
av_always_inline std::string av_err2string(int errnum) {
char errbuf[AV_ERROR_MAX_STRING_SIZE];
return av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, errnum);
}
#define av_err2str(err) av_err2string(err).c_str()
#endif // av_err2str
2 changes: 2 additions & 0 deletions src/core/libraries/ajm/ajm_mp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ extern "C" {
#include <libswresample/swresample.h>
}

#include "common/support/avdec.h"

namespace Libraries::Ajm {

// Following tables have been reversed from AJM library
Expand Down
11 changes: 1 addition & 10 deletions src/core/libraries/avplayer/avplayer_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,7 @@ extern "C" {
#include <libswscale/swscale.h>
}

// The av_err2str macro in libavutil/error.h does not play nice with C++
#ifdef av_err2str
#undef av_err2str
#include <string>
av_always_inline std::string av_err2string(int errnum) {
char errbuf[AV_ERROR_MAX_STRING_SIZE];
return av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, errnum);
}
#define av_err2str(err) av_err2string(err).c_str()
#endif // av_err2str
#include "common/support/avdec.h"

namespace Libraries::AvPlayer {

Expand Down
11 changes: 1 addition & 10 deletions src/core/libraries/videodec/videodec2_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@
#include "common/logging/log.h"
#include "core/libraries/videodec/videodec_error.h"

// The av_err2str macro in libavutil/error.h does not play nice with C++
#ifdef av_err2str
#undef av_err2str
#include <string>
av_always_inline std::string av_err2string(int errnum) {
char errbuf[AV_ERROR_MAX_STRING_SIZE];
return av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, errnum);
}
#define av_err2str(err) av_err2string(err).c_str()
#endif // av_err2str
#include "common/support/avdec.h"

namespace Libraries::Vdec2 {

Expand Down
11 changes: 1 addition & 10 deletions src/core/libraries/videodec/videodec_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@
#include "common/logging/log.h"
#include "core/libraries/videodec/videodec_error.h"

// The av_err2str macro in libavutil/error.h does not play nice with C++
#ifdef av_err2str
#undef av_err2str
#include <string>
av_always_inline std::string av_err2string(int errnum) {
char errbuf[AV_ERROR_MAX_STRING_SIZE];
return av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, errnum);
}
#define av_err2str(err) av_err2string(err).c_str()
#endif // av_err2str
#include "common/support/avdec.h"

namespace Libraries::Videodec {

Expand Down

0 comments on commit dad5953

Please sign in to comment.