Skip to content
Snippets Groups Projects
Commit 4af4effb authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix deadlock in SDL mode.

sdl_getscaling() does not require vstatlock.  Move it out.
parent ab061c8b
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4283 passed
...@@ -405,8 +405,8 @@ static void ...@@ -405,8 +405,8 @@ static void
update_cvstat(struct video_stats *vs) update_cvstat(struct video_stats *vs)
{ {
if (vs != NULL && vs != &vstat) { if (vs != NULL && vs != &vstat) {
pthread_mutex_lock(&vstatlock);
vstat.scaling = sdl_getscaling(); vstat.scaling = sdl_getscaling();
pthread_mutex_lock(&vstatlock);
*vs = vstat; *vs = vstat;
pthread_mutex_unlock(&vstatlock); pthread_mutex_unlock(&vstatlock);
} }
...@@ -435,15 +435,18 @@ static void internal_setwinsize(struct video_stats *vs, bool force) ...@@ -435,15 +435,18 @@ static void internal_setwinsize(struct video_stats *vs, bool force)
vs->winwidth = vstat.winwidth = w; vs->winwidth = vstat.winwidth = w;
vs->winheight = vstat.winheight = h; vs->winheight = vstat.winheight = h;
} }
if (!changed) { if (changed) {
pthread_mutex_unlock(&vstatlock);
}
else {
pthread_mutex_lock(&win_mutex); pthread_mutex_lock(&win_mutex);
sdl.GetWindowSize(win, &w, &h); sdl.GetWindowSize(win, &w, &h);
pthread_mutex_unlock(&win_mutex); pthread_mutex_unlock(&win_mutex);
if (w != vs->winwidth || h != vs->winheight) if (w != vs->winwidth || h != vs->winheight)
changed = true; changed = true;
pthread_mutex_unlock(&vstatlock);
vstat.scaling = sdl_getscaling(); vstat.scaling = sdl_getscaling();
} }
pthread_mutex_unlock(&vstatlock);
if (changed) if (changed)
setup_surfaces(vs); setup_surfaces(vs);
} }
...@@ -651,9 +654,7 @@ static void setup_surfaces(struct video_stats *vs) ...@@ -651,9 +654,7 @@ static void setup_surfaces(struct video_stats *vs)
sdl.PeepEvents(&ev, 1, SDL_ADDEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT); sdl.PeepEvents(&ev, 1, SDL_ADDEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
} }
pthread_mutex_unlock(&win_mutex); pthread_mutex_unlock(&win_mutex);
pthread_mutex_lock(&vstatlock);
vstat.scaling = sdl_getscaling(); vstat.scaling = sdl_getscaling();
pthread_mutex_unlock(&vstatlock);
} }
/* Called from event thread only */ /* Called from event thread only */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment