diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-06-10 00:17:45 +0200 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2012-06-11 23:57:01 +0200 |
commit | 359abb18cfe3a5e6db44031c5110322343b16756 (patch) | |
tree | 7e3a8ce665fc918532ad27d02958c1e526ef1752 /libavutil/error.h | |
parent | 5683de00e99e4be87419a97d521887f94acc937a (diff) | |
download | ffmpeg-359abb18cfe3a5e6db44031c5110322343b16756.tar.gz |
lavu/error: add av_make_error_string() and av_err2str() convenience utilities
These functions are modeled after the corresponding utilities in
libavutil/timestamp.h.
Diffstat (limited to 'libavutil/error.h')
-rw-r--r-- | libavutil/error.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libavutil/error.h b/libavutil/error.h index 316734f112..ea0725a39c 100644 --- a/libavutil/error.h +++ b/libavutil/error.h @@ -68,6 +68,8 @@ #define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ') #define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library +#define AV_ERROR_MAX_STRING_SIZE 64 + /** * Put a description of the AVERROR code errnum in errbuf. * In case of failure the global variable errno is set to indicate the @@ -83,6 +85,29 @@ int av_strerror(int errnum, char *errbuf, size_t errbuf_size); /** + * Fill the provided buffer with a string containing an error string + * corresponding to the AVERROR code errnum. + * + * @param errbuf a buffer + * @param errbuf_size size in bytes of errbuf + * @param errnum error code to describe + * @return the buffer in input, filled with the error description + * @see av_strerror() + */ +static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int errnum) +{ + av_strerror(errnum, errbuf, errbuf_size); + return errbuf; +} + +/** + * Convenience macro, the return value should be used only directly in + * function arguments but never stand-alone. + */ +#define av_err2str(errnum) \ + av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum) + +/** * @} */ |