Moving SDL video mutex lock to avoid deadlock between buffering and drawing threads

This commit is contained in:
Seth Polsley 2019-02-25 18:43:34 -06:00 committed by Seth
parent f67fe9671b
commit d9ba646899

View File

@ -1094,12 +1094,10 @@ void driver_base::update_palette(void)
if ((int)VIDEO_MODE_DEPTH <= VIDEO_DEPTH_8BIT) { if ((int)VIDEO_MODE_DEPTH <= VIDEO_DEPTH_8BIT) {
SDL_SetSurfacePalette(s, sdl_palette); SDL_SetSurfacePalette(s, sdl_palette);
SDL_LockMutex(sdl_update_video_mutex);
sdl_update_video_rect.x = 0; sdl_update_video_rect.x = 0;
sdl_update_video_rect.y = 0; sdl_update_video_rect.y = 0;
sdl_update_video_rect.w = VIDEO_MODE_X; sdl_update_video_rect.w = VIDEO_MODE_X;
sdl_update_video_rect.h = VIDEO_MODE_Y; sdl_update_video_rect.h = VIDEO_MODE_Y;
SDL_UnlockMutex(sdl_update_video_mutex);
} }
} }
@ -2514,6 +2512,7 @@ static inline void possibly_ungrab_mouse()
static inline void handle_palette_changes(void) static inline void handle_palette_changes(void)
{ {
SDL_LockMutex(sdl_update_video_mutex);
LOCK_PALETTE; LOCK_PALETTE;
if (sdl_palette_changed) { if (sdl_palette_changed) {
@ -2522,6 +2521,7 @@ static inline void handle_palette_changes(void)
} }
UNLOCK_PALETTE; UNLOCK_PALETTE;
SDL_UnlockMutex(sdl_update_video_mutex);
} }
static void video_refresh_window_static(void); static void video_refresh_window_static(void);