Compared to ad-hoc if(printed) ... code this allows the user to disable it by adjusting the log level
Unified · Split
| @@ -15,6 +15,9 @@ libavutil: 2017-10-21 · 14 unmodified lines | |||
| 15 | 15 | ||
| 16 | API changes, most recent first: | 16 | API changes, most recent first: |
| 17 | 17 | ||
| 18 | 2020-02-12 - xxxxxxxxxx - lavu 56.40.100 - log.h | ||
| 19 | Add av_log_once(). | ||
| 20 | |||
| 18 | 2020-02-04 - xxxxxxxxxx - lavu 56.39.100 - hwcontext.h | 21 | 2020-02-04 - xxxxxxxxxx - lavu 56.39.100 - hwcontext.h |
| 19 | Add AV_PIX_FMT_VULKAN | 22 | Add AV_PIX_FMT_VULKAN |
| 20 | Add AV_HWDEVICE_TYPE_VULKAN and implementation. | 23 | Add AV_HWDEVICE_TYPE_VULKAN and implementation. |
| @@ -412,6 +412,15 @@ void av_log(void* avcl, int level, const char *fmt, ...) · 411 unmodified lines | |||
| 412 | va_end(vl); | 412 | va_end(vl); |
| 413 | } | 413 | } |
| 414 | 414 | ||
| 415 | void av_log_once(void* avcl, int initial_level, int subsequent_level, int *state, const char *fmt, ...) | ||
| 416 | { | ||
| 417 | va_list vl; | ||
| 418 | va_start(vl, fmt); | ||
| 419 | av_vlog(avcl, *state ? subsequent_level : initial_level, fmt, vl); | ||
| 420 | va_end(vl); | ||
| 421 | *state = 1; | ||
| 422 | } | ||
| 423 | |||
| 415 | void av_vlog(void* avcl, int level, const char *fmt, va_list vl) | 424 | void av_vlog(void* avcl, int level, const char *fmt, va_list vl) |
| 416 | { | 425 | { |
| 417 | AVClass* avc = avcl ? *(AVClass **) avcl : NULL; | 426 | AVClass* avc = avcl ? *(AVClass **) avcl : NULL; |
| @@ -233,6 +233,27 @@ typedef struct AVClass { · 232 unmodified lines | |||
| 233 | */ | 233 | */ |
| 234 | void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); | 234 | void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); |
| 235 | 235 | ||
| 236 | /** | ||
| 237 | * Send the specified message to the log once with the initial_level and then with | ||
| 238 | * the subsequent_level. By default, all logging messages are sent to | ||
| 239 | * stderr. This behavior can be altered by setting a different logging callback | ||
| 240 | * function. | ||
| 241 | * @see av_log | ||
| 242 | * | ||
| 243 | * @param avcl A pointer to an arbitrary struct of which the first field is a | ||
| 244 | * pointer to an AVClass struct or NULL if general log. | ||
| 245 | * @param initial_level importance level of the message expressed using a @ref | ||
| 246 | * lavu_log_constants "Logging Constant" for the first occurance. | ||
| 247 | * @param subsequent_level importance level of the message expressed using a @ref | ||
| 248 | * lavu_log_constants "Logging Constant" after the first occurance. | ||
| 249 | * @param fmt The format string (printf-compatible) that specifies how | ||
| 250 | * subsequent arguments are converted to output. | ||
| 251 | * @param state a variable to keep trak of if a message has already been printed | ||
| 252 | * this must be initialized to 0 before the first use. The same state | ||
| 253 | * must not be accessed by 2 Threads simultaneously. | ||
| 254 | */ | ||
| 255 | void av_log_once(void* avcl, int initial_level, int subsequent_level, int *state, const char *fmt, ...) av_printf_format(5, 6); | ||
| 256 | |||
| 236 | 257 | ||
| 237 | /** | 258 | /** |
| 238 | * Send the specified message to the log if the level is less than or equal | 259 | * Send the specified message to the log if the level is less than or equal |
| @@ -79,7 +79,7 @@ · 78 unmodified lines | |||
| 79 | */ | 79 | */ |
| 80 | 80 | ||
| 81 | #define LIBAVUTIL_VERSION_MAJOR 56 | 81 | #define LIBAVUTIL_VERSION_MAJOR 56 |
| 82 | #define LIBAVUTIL_VERSION_MINOR 39 | 82 | #define LIBAVUTIL_VERSION_MINOR 40 |
| 83 | #define LIBAVUTIL_VERSION_MICRO 100 | 83 | #define LIBAVUTIL_VERSION_MICRO 100 |
| 84 | 84 | ||
| 85 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ | 85 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |