mirror of
https://github.com/encounter/rust-ffmpeg-zmwangx.git
synced 2026-07-10 21:18:40 -07:00
avutil::error: mark AVERROR and AVUNERROR as const
This commit is contained in:
committed by
Till Höppner
parent
87d69b1cbc
commit
8fc05cf1e8
+13
-4
@@ -1,18 +1,27 @@
|
||||
use libc::{c_char, c_int, size_t};
|
||||
|
||||
// Note: FFmpeg's AVERROR and AVUNERROR are conditionally defined based on
|
||||
// whether EDOM is positive, claiming that "Some platforms have E* and errno
|
||||
// already negated". This can be traced to a commit in 2007 where "some
|
||||
// platforms" were specifically identified as BeOS (so maybe also Haiku?):
|
||||
// https://github.com/FFmpeg/FFmpeg/commit/8fa36ae09dddb1b639b4df5d505c0dbcf4e916e4
|
||||
// constness is more valuable than BeOS support, so if someone really needs it,
|
||||
// send a patch with cfg_attr.
|
||||
|
||||
#[inline(always)]
|
||||
pub fn AVERROR(e: c_int) -> c_int {
|
||||
pub const fn AVERROR(e: c_int) -> c_int {
|
||||
-e
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn AVUNERROR(e: c_int) -> c_int {
|
||||
pub const fn AVUNERROR(e: c_int) -> c_int {
|
||||
-e
|
||||
}
|
||||
|
||||
macro_rules! FFERRTAG {
|
||||
($a:expr, $b:expr, $c:expr, $d:expr) =>
|
||||
(-MKTAG!($a, $b, $c, $d) as c_int)
|
||||
($a:expr, $b:expr, $c:expr, $d:expr) => {
|
||||
-MKTAG!($a, $b, $c, $d) as c_int
|
||||
};
|
||||
}
|
||||
|
||||
pub const AVERROR_BSF_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'B', b'S', b'F');
|
||||
|
||||
Reference in New Issue
Block a user