|
53 | 53 |
|
54 | 54 | #include <assert.h> // for assert
|
55 | 55 | #include <ctype.h> // for toupper
|
| 56 | +#include <inttypes.h> // for PRIu8 |
56 | 57 | #include <math.h> // for sqrt
|
57 | 58 | #include <pthread.h> // for pthread_mutex_unlock, pthread_mutex_lock
|
58 | 59 | #include <stdbool.h> // for true, bool, false
|
@@ -149,7 +150,15 @@ static const struct {
|
149 | 150 | {'q', "quit"},
|
150 | 151 | };
|
151 | 152 |
|
152 |
| -#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) |
| 153 | +#define SDL_CHECK(cmd, ...) \ |
| 154 | + do { \ |
| 155 | + int ret = cmd; \ |
| 156 | + if (ret < 0) { \ |
| 157 | + log_msg(LOG_LEVEL_ERROR, MOD_NAME "Error (%s): %s\n", \ |
| 158 | + #cmd, SDL_GetError()); \ |
| 159 | + __VA_ARGS__; \ |
| 160 | + } \ |
| 161 | + } while (0) |
153 | 162 |
|
154 | 163 | static void display_frame(struct state_sdl2 *s, struct video_frame *frame)
|
155 | 164 | {
|
@@ -475,7 +484,10 @@ static bool recreate_textures(struct state_sdl2 *s, struct video_desc desc) {
|
475 | 484 | }
|
476 | 485 | struct video_frame *f = vf_alloc_desc(desc);
|
477 | 486 | f->callbacks.dispose_udata = (void *) texture;
|
478 |
| - SDL_CHECK(SDL_LockTexture(texture, NULL, (void **) &f->tiles[0].data, &s->texture_pitch)); |
| 487 | + SDL_CHECK(SDL_LockTexture(texture, NULL, |
| 488 | + (void **) &f->tiles[0].data, |
| 489 | + &s->texture_pitch), |
| 490 | + return false); |
479 | 491 | f->tiles[0].data_len = desc.height * s->texture_pitch;
|
480 | 492 | f->callbacks.data_deleter = vf_sdl_texture_data_deleter;
|
481 | 493 | simple_linked_list_append(s->free_frame_queue, f);
|
|
0 commit comments