test/libmpv_encode: use libmpv_common.h

De-duplicates some code.
This commit is contained in:
Dudemanguy committed 2025-10-02 15:15:48 +00:00
1 parent 6179a24741
commit e0cf3f8061
2 files changed
+5 -37

No files matched your search

+3 -36
View File
@@ -30,27 +30,12 @@
#include <mpv/client.h>
// 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";
+2 -1
View File
@@ -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