|
23 | 23 | #ifndef MPV_CLIENT_API_H_ |
24 | 24 | #define MPV_CLIENT_API_H_ |
25 | 25 |
|
| 26 | +#include <stdarg.h> |
26 | 27 | #include <stddef.h> |
27 | 28 | #include <stdint.h> |
28 | 29 |
|
|
43 | 44 | #define MPV_DECLTYPE __typeof__ |
44 | 45 | #endif |
45 | 46 |
|
| 47 | +// Stolen from osdep/compiler.h |
| 48 | +#if defined(__GNUC__) || defined(__clang__) |
| 49 | +#define MPV_PRINTF_ATTRIBUTE(a1, a2) __attribute__((format(printf, a1, a2))) |
| 50 | +#else |
| 51 | +#define MPV_PRINTF_ATTRIBUTE(a1, a2) |
| 52 | +#endif |
| 53 | + |
| 54 | +// Broken crap with __USE_MINGW_ANSI_STDIO |
| 55 | +#if defined(__MINGW32__) && defined(__GNUC__) && !defined(__clang__) |
| 56 | +#undef MPV_PRINTF_ATTRIBUTE |
| 57 | +#define MPV_PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (gnu_printf, a1, a2))) |
| 58 | +#endif |
| 59 | + |
46 | 60 | #ifdef __cplusplus |
47 | 61 | extern "C" { |
48 | 62 | #endif |
@@ -248,7 +262,7 @@ extern "C" { |
248 | 262 | * relational operators (<, >, <=, >=). |
249 | 263 | */ |
250 | 264 | #define MPV_MAKE_VERSION(major, minor) (((major) << 16) | (minor) | 0UL) |
251 | | -#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(2, 5) |
| 265 | +#define MPV_CLIENT_API_VERSION MPV_MAKE_VERSION(2, 6) |
252 | 266 |
|
253 | 267 | /** |
254 | 268 | * The API user is allowed to "#define MPV_ENABLE_DEPRECATED 0" before |
@@ -1682,6 +1696,41 @@ MPV_EXPORT int mpv_request_event(mpv_handle *ctx, mpv_event_id event, int enable |
1682 | 1696 | */ |
1683 | 1697 | MPV_EXPORT int mpv_request_log_messages(mpv_handle *ctx, const char *min_level); |
1684 | 1698 |
|
| 1699 | +/** |
| 1700 | + * Write a log message using the log instance of the mpv_handle. |
| 1701 | + * |
| 1702 | + * Safe to be called from mpv render API threads. |
| 1703 | + * |
| 1704 | + * @param lev See enum mpv_log_level. |
| 1705 | + * @param format printf-style format string |
| 1706 | + */ |
| 1707 | +MPV_EXPORT void mpv_msg(mpv_handle *ctx, mpv_log_level lev, const char *format, ...) |
| 1708 | + MPV_PRINTF_ATTRIBUTE(3, 4); |
| 1709 | + |
| 1710 | +/** |
| 1711 | + * Same as mpv_msg but takes a va_list. |
| 1712 | + */ |
| 1713 | +MPV_EXPORT void mpv_msg_va(mpv_handle *ctx, mpv_log_level lev, const char *format, va_list va) |
| 1714 | + MPV_PRINTF_ATTRIBUTE(3, 0); |
| 1715 | + |
| 1716 | +/** |
| 1717 | + * @defgroup msg_macros Convenience macros for mpv_msg |
| 1718 | + * |
| 1719 | + * @{ |
| 1720 | + */ |
| 1721 | + |
| 1722 | +#define mpv_msg_fatal(ctx, ...) mpv_msg(ctx, MPV_LOG_LEVEL_FATAL, __VA_ARGS__) |
| 1723 | +#define mpv_msg_err(ctx, ...) mpv_msg(ctx, MPV_LOG_LEVEL_ERROR, __VA_ARGS__) |
| 1724 | +#define mpv_msg_warn(ctx, ...) mpv_msg(ctx, MPV_LOG_LEVEL_WARN, __VA_ARGS__) |
| 1725 | +#define mpv_msg_info(ctx, ...) mpv_msg(ctx, MPV_LOG_LEVEL_INFO, __VA_ARGS__) |
| 1726 | +#define mpv_msg_verbose(ctx, ...) mpv_msg(ctx, MPV_LOG_LEVEL_V, __VA_ARGS__) |
| 1727 | +#define mpv_msg_dbg(ctx, ...) mpv_msg(ctx, MPV_LOG_LEVEL_DEBUG, __VA_ARGS__) |
| 1728 | +#define mpv_msg_trace(ctx, ...) mpv_msg(ctx, MPV_LOG_LEVEL_TRACE, __VA_ARGS__) |
| 1729 | + |
| 1730 | +/** |
| 1731 | + * @} |
| 1732 | + */ |
| 1733 | + |
1685 | 1734 | /** |
1686 | 1735 | * Wait for the next event, or until the timeout expires, or if another thread |
1687 | 1736 | * makes a call to mpv_wakeup(). Passing 0 as timeout will never wait, and |
@@ -2008,6 +2057,10 @@ MPV_DEFINE_SYM_PTR(mpv_request_event) |
2008 | 2057 | #define mpv_request_event pfn_mpv_request_event |
2009 | 2058 | MPV_DEFINE_SYM_PTR(mpv_request_log_messages) |
2010 | 2059 | #define mpv_request_log_messages pfn_mpv_request_log_messages |
| 2060 | +MPV_DEFINE_SYM_PTR(mpv_msg) |
| 2061 | +#define mpv_msg pfn_mpv_msg |
| 2062 | +MPV_DEFINE_SYM_PTR(mpv_msg_va) |
| 2063 | +#define mpv_msg_va pfn_mpv_msg_va |
2011 | 2064 | MPV_DEFINE_SYM_PTR(mpv_wait_event) |
2012 | 2065 | #define mpv_wait_event pfn_mpv_wait_event |
2013 | 2066 | MPV_DEFINE_SYM_PTR(mpv_wakeup) |
|
0 commit comments