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

More fixups...

Some Coverity issues, some deadlocks, some crashes...
Just misc stuff.
parent a76da51b
No related branches found
No related tags found
No related merge requests found
Pipeline #7775 failed
......@@ -814,15 +814,16 @@ bitmap_draw_vmem(int sx, int sy, int ex, int ey, struct vmem_cell *fill)
size_t xoffset = (sx-1) * vstat.charwidth;
size_t yoffset = (sy-1) * vstat.charheight;
bs.expand = vstat.flags & VIDMODES_FLAG_EXPAND;
bs.font_data_width = vstat.charwidth - (bs.expand ? 1 : 0);
pthread_mutex_lock(&screenlock);
assert(xoffset + vstat.charwidth <= screena.screenwidth);
assert(xoffset + vstat.charwidth <= screenb.screenwidth);
assert(yoffset + vstat.charheight <= screena.screenheight);
assert(yoffset + vstat.charheight <= screenb.screenheight);
bs.maxpix = screena.screenwidth * screena.screenheight;
bs.expand = vstat.flags & VIDMODES_FLAG_EXPAND;
bs.font_data_width = vstat.charwidth - (bs.expand ? 1 : 0);
pthread_mutex_lock(&screenlock);
bs.pixeloffset = pixel_offset(&screena, xoffset, yoffset);
bs.cheat_colour = fill[0].bg;
size_t rsz = screena.screenwidth - vstat.charwidth * vwidth;
......@@ -971,6 +972,13 @@ static void blinker_thread(void *data)
lfc = force_cursor;
force_cursor = 0;
blink = vstat.blink;
pthread_mutex_lock(&screenlock);
if (screena.rect == NULL) {
pthread_mutex_unlock(&screenlock);
do_rwlock_unlock(&vstatlock);
continue;
}
pthread_mutex_unlock(&screenlock);
do_rwlock_unlock(&vstatlock);
if (check_redraw()) {
......
......@@ -756,8 +756,8 @@ static void sdl_add_key(unsigned int keyval, struct video_stats *vs)
if(keyval <= 0xffff) {
pthread_mutex_lock(&sdl_keylock);
if(sdl_keynext+1==sdl_key) {
beep();
pthread_mutex_unlock(&sdl_keylock);
beep();
return;
}
if((sdl_keynext+2==sdl_key) && keyval > 0xff) {
......@@ -990,7 +990,7 @@ void sdl_video_event_thread(void *data)
}
else {
if (bios_key >= 26 ||
(bios_key == 429496729 && ((ev.key.keysym.sym > SDLK_KP_5) || (ev.key.keysym.sym == SDLK_KP_0)))) {
(bios_key == 25 && ((ev.key.keysym.sym > SDLK_KP_5) || (ev.key.keysym.sym == SDLK_KP_0)))) {
terminate_bios = true;
}
}
......@@ -1146,8 +1146,10 @@ void sdl_video_event_thread(void *data)
case SDL_WINDOWEVENT_SIZE_CHANGED:
// SDL2: User resized window
case SDL_WINDOWEVENT_RESIZED:
pthread_mutex_lock(&win_mutex);
fullscreen = !!(sdl.GetWindowFlags(win) & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP));
sdl.SetWindowResizable(win, fullscreen ? SDL_FALSE : SDL_TRUE);
pthread_mutex_unlock(&win_mutex);
cio_api.mode=fullscreen?CIOLIB_MODE_SDL_FULLSCREEN:CIOLIB_MODE_SDL;
pthread_mutex_lock(&sdl_mode_mutex);
if (sdl_mode) {
......@@ -1326,17 +1328,17 @@ void sdl_video_event_thread(void *data)
case SDL_USEREVENT_INIT:
if(!sdl_init_good) {
if(sdl.WasInit(SDL_INIT_VIDEO)==SDL_INIT_VIDEO) {
pthread_mutex_lock(&win_mutex);
_beginthread(sdl_mouse_thread, 0, NULL);
sdl_init_good=1;
pthread_mutex_unlock(&win_mutex);
}
}
sdl_ufunc_retval=0;
sem_post(&sdl_ufunc_ret);
break;
case SDL_USEREVENT_GETWINPOS:
pthread_mutex_lock(&win_mutex);
sdl.GetWindowPosition(win, ev.user.data1, ev.user.data2);
pthread_mutex_unlock(&win_mutex);
sem_post(&sdl_ufunc_ret);
break;
case SDL_USEREVENT_MOUSEPOINTER:
......@@ -1380,8 +1382,6 @@ void sdl_video_event_thread(void *data)
break;
}
}
sdl.QuitSubSystem(SDL_INIT_VIDEO);
return;
}
static int
......
......@@ -218,6 +218,11 @@ ifndef WITHOUT_ALSA_SOUND
ifeq ($(shell if [ -f /usr/include/alsa/asoundlib.h ] ; then echo YES ; fi),YES)
XPDEV-MT_CFLAGS += -DUSE_ALSA_SOUND
XPDEV-MT_LIBS += -ldl
else
ifeq ($(shell if [ -f /usr/local/include/alsa/asoundlib.h ] ; then echo YES ; fi),YES)
XPDEV-MT_CFLAGS += -DUSE_ALSA_SOUND
XPDEV-MT_LIBS += -ldl
endif
endif
endif
......
......@@ -1147,8 +1147,10 @@ int64_t xp_fast_timer64(void)
}
cid = CLOCK_MONOTONIC_RAW;
#endif
#ifdef CLOCK_MONOTONIC
if (cid == CLOCK_REALTIME)
cid = CLOCK_MONOTONIC;
#endif
if (clock_gettime(cid, &ts) == 0)
ret = ts.tv_sec;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment