summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/common.c9
-rw-r--r--common/common.h3
2 files changed, 12 insertions, 0 deletions
diff --git a/common/common.c b/common/common.c
index 449c95be26..4c1f9f327a 100644
--- a/common/common.c
+++ b/common/common.c
@@ -20,6 +20,7 @@
#include <assert.h>
#include <libavutil/common.h>
+#include <libavutil/error.h>
#include "talloc.h"
#include "misc/bstr.h"
@@ -243,3 +244,11 @@ bool mp_append_escaped_string(void *talloc_ctx, bstr *dst, bstr *src)
}
return false;
}
+
+// Behaves like strerror()/strerror_r(), but is thread- and GNU-safe.
+char *mp_strerror_buf(char *buf, size_t buf_size, int errnum)
+{
+ // This handles the nasty details of calling the right function for us.
+ av_strerror(AVERROR(errnum), buf, buf_size);
+ return buf;
+}
diff --git a/common/common.h b/common/common.h
index 3e5ee1190f..e3411427a5 100644
--- a/common/common.h
+++ b/common/common.h
@@ -89,4 +89,7 @@ bool mp_append_escaped_string_noalloc(void *talloc_ctx, struct bstr *dst,
bool mp_append_escaped_string(void *talloc_ctx, struct bstr *dst,
struct bstr *src);
+char *mp_strerror_buf(char *buf, size_t buf_size, int errnum);
+#define mp_strerror(e) mp_strerror_buf((char[80]){0}, 80, e)
+
#endif /* MPLAYER_MPCOMMON_H */