Skip to content

Commit 6beecfc

Browse files
committed
fix #1071 sdl2 consumer broken on macOS
regression in cb0ff75
1 parent 74e4939 commit 6beecfc

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/modules/sdl2/consumer_sdl2.c

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* consumer_sdl.c -- A Simple DirectMedia Layer consumer
3-
* Copyright (C) 2017-2024 Meltytech, LLC
3+
* Copyright (C) 2017-2025 Meltytech, LLC
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public
@@ -216,6 +216,10 @@ int consumer_start(mlt_consumer parent)
216216
}
217217

218218
// Initialize SDL video if needed.
219+
#ifdef __APPLE__
220+
if (setup_sdl_video(self))
221+
return 1;
222+
#else
219223
if (!SDL_WasInit(SDL_INIT_VIDEO)) {
220224
pthread_mutex_lock(&mlt_sdl_mutex);
221225
int ret = SDL_Init(SDL_INIT_VIDEO);
@@ -227,6 +231,7 @@ int consumer_start(mlt_consumer parent)
227231
return 1;
228232
}
229233
}
234+
#endif
230235

231236
pthread_create(&self->thread, NULL, consumer_thread, self);
232237
}
@@ -481,6 +486,20 @@ static int setup_sdl_video(consumer_sdl self)
481486
if (video_off || preview_off)
482487
return error;
483488

489+
#ifdef __APPLE__
490+
if (!SDL_WasInit(SDL_INIT_VIDEO)) {
491+
pthread_mutex_lock(&mlt_sdl_mutex);
492+
int ret = SDL_Init(SDL_INIT_VIDEO);
493+
pthread_mutex_unlock(&mlt_sdl_mutex);
494+
if (ret < 0) {
495+
mlt_log_error(MLT_CONSUMER_SERVICE(&self->parent),
496+
"Failed to initialize SDL: %s\n",
497+
SDL_GetError());
498+
return -1;
499+
}
500+
}
501+
#endif
502+
484503
#ifdef MLT_IMAGE_FORMAT
485504
int image_format = mlt_properties_get_int(self->properties, "mlt_image_format");
486505

0 commit comments

Comments
 (0)