From e0cf3f80610120236bc593d225b7606efc67594c Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Mon, 29 Sep 2025 18:32:28 -0500 Subject: [PATCH] test/libmpv_encode: use libmpv_common.h De-duplicates some code. --- test/libmpv_encode.c | 39 +++------------------------------------ test/meson.build | 3 ++- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/test/libmpv_encode.c b/test/libmpv_encode.c index c97da66747..e28f06fb8b 100644 --- a/test/libmpv_encode.c +++ b/test/libmpv_encode.c @@ -30,27 +30,12 @@ #include -// Stolen from osdep/compiler.h -#ifdef __GNUC__ -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format(printf, a1, a2))) -#define MP_NORETURN __attribute__((noreturn)) -#else -#define PRINTF_ATTRIBUTE(a1, a2) -#define MP_NORETURN -#endif +#include "libmpv_common.h" -// Broken crap with __USE_MINGW_ANSI_STDIO -#if defined(__MINGW32__) && defined(__GNUC__) && !defined(__clang__) -#undef PRINTF_ATTRIBUTE -#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (gnu_printf, a1, a2))) -#endif - -// Global handle -static mpv_handle *ctx; // Temporary output file static const char *out_path; -static void exit_cleanup(void) +static void cleanup(void) { if (ctx) mpv_destroy(ctx); @@ -58,24 +43,6 @@ static void exit_cleanup(void) unlink(out_path); } -MP_NORETURN PRINTF_ATTRIBUTE(1, 2) -static void fail(const char *fmt, ...) -{ - if (fmt) { - va_list va; - va_start(va, fmt); - vfprintf(stderr, fmt, va); - va_end(va); - } - exit(1); -} - -static void check_api_error(int status) -{ - if (status < 0) - fail("libmpv error: %s\n", mpv_error_string(status)); -} - static void wait_done(void) { while (1) { @@ -111,7 +78,7 @@ int main(int argc, char *argv[]) if (!ctx) return 1; - atexit(exit_cleanup); + atexit(cleanup); static char path[] = "./testout.XXXXXX"; diff --git a/test/meson.build b/test/meson.build index 528df9f403..b67074166b 100644 --- a/test/meson.build +++ b/test/meson.build @@ -139,7 +139,8 @@ if get_option('libmpv') endif endif - exe = executable('libmpv-encode', 'libmpv_encode.c', dependencies: libmpv_dep) + exe = executable('libmpv-encode', 'libmpv_encode.c', + include_directories: incdir, dependencies: libmpv_dep) test('libmpv-encode', exe, suite: 'libmpv') mpvlib = libmpv