From a15c14f2a428f0b1f9bc1fb2d3fc021bbdf205e8 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Wed, 29 Jan 2025 15:14:59 +0100 Subject: [PATCH] sdl2: include + SDL_CHECK add action include inttypes.h SDL_CHECK can now have an optional action (using ellipsis) + handle return value of SDL_LockTesxture using that (currently fails on Arch Linux with sdl2-compat 2.30.50-1 and sdl3 3.2.0-1 and YCbCr textures). --- src/video_display/sdl2.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/video_display/sdl2.c b/src/video_display/sdl2.c index fb8c8a86d..8394b27a6 100644 --- a/src/video_display/sdl2.c +++ b/src/video_display/sdl2.c @@ -53,6 +53,7 @@ #include // for assert #include // for toupper +#include // for PRIu8 #include // for sqrt #include // for pthread_mutex_unlock, pthread_mutex_lock #include // for true, bool, false @@ -149,7 +150,15 @@ static const struct { {'q', "quit"}, }; -#define SDL_CHECK(cmd) do { int ret = cmd; if (ret < 0) { log_msg(LOG_LEVEL_ERROR, MOD_NAME "Error (%s): %s\n", #cmd, SDL_GetError());} } while(0) +#define SDL_CHECK(cmd, ...) \ + do { \ + int ret = cmd; \ + if (ret < 0) { \ + log_msg(LOG_LEVEL_ERROR, MOD_NAME "Error (%s): %s\n", \ + #cmd, SDL_GetError()); \ + __VA_ARGS__; \ + } \ + } while (0) static void display_frame(struct state_sdl2 *s, struct video_frame *frame) { @@ -475,7 +484,10 @@ static bool recreate_textures(struct state_sdl2 *s, struct video_desc desc) { } struct video_frame *f = vf_alloc_desc(desc); f->callbacks.dispose_udata = (void *) texture; - SDL_CHECK(SDL_LockTexture(texture, NULL, (void **) &f->tiles[0].data, &s->texture_pitch)); + SDL_CHECK(SDL_LockTexture(texture, NULL, + (void **) &f->tiles[0].data, + &s->texture_pitch), + return false); f->tiles[0].data_len = desc.height * s->texture_pitch; f->callbacks.data_deleter = vf_sdl_texture_data_deleter; simple_linked_list_append(s->free_frame_queue, f);