Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commits (3)
  • Deucе's avatar
    Fix race condition when handle is opened by playing a sample. · d5e78851
    Deucе authored
    Caused a SyncTERM hang if it played a FG beep.
    d5e78851
  • Deucе's avatar
    Fix AltGr with SDL2 · 1495774a
    Deucе authored
    This is pretty insane since SDL2 completely ignores the keysym value
    of the X11 keyboard event, so here's what we do...
    
    1) When there's a keypress that includes right-alt, store the sym/mod
    2) When we get text input, if it's the same as we would get if ALT
       wasn't pressed for the last keydown, parse through the mapping
       (ie: handle ALT keys)
    3) If it's different, use that (gets AltGr modified value)
    
    I get that AltGr is hard in a cross-platform way, but just pretending
    it doesn't exist at all for key input is a very weird choice.
    1495774a
  • Deucе's avatar
    Better comment conformance in key parsing · d8920e06
    Deucе authored
    There's a comment saying we set key=0 when we consume it... do so
    in a couple cases where it wasn't done.
    
    Range check the key before sending to the remote.
    
    This should not actually do anything different, but in the future
    if things are changed at least the comments won't be misleading.
    d8920e06
......@@ -795,6 +795,8 @@ void sdl_video_event_thread(void *data)
SDL_Event ev;
int old_w, old_h;
int block_text = 0;
static SDL_Keycode last_sym = SDLK_UNKNOWN;
static Uint16 last_mod = 0;
pthread_mutex_lock(&vstatlock);
old_w = cvstat.winwidth;
......@@ -816,6 +818,8 @@ void sdl_video_event_thread(void *data)
else {
switch (ev.type) {
case SDL_KEYDOWN: /* Keypress */
last_mod = ev.key.keysym.mod;
last_sym = ev.key.keysym.sym;
if ((ev.key.keysym.mod & (KMOD_CTRL|KMOD_ALT|KMOD_GUI)) && !(ev.key.keysym.mod & KMOD_MODE)) {
block_text = 1;
if ((ev.key.keysym.mod & KMOD_ALT) &&
......@@ -878,6 +882,10 @@ void sdl_video_event_thread(void *data)
break;
}
}
if (ev.key.keysym.mod & KMOD_RALT) { // Possible AltGr, let textinput sort it out...
block_text = 0;
break;
}
if ((ev.key.keysym.mod & KMOD_SHIFT) && (ev.key.keysym.sym == '\t'))
block_text = 1;
if (block_text || ev.key.keysym.sym < 0 || ev.key.keysym.sym > 127) {
......@@ -897,10 +905,17 @@ void sdl_video_event_thread(void *data)
}
break;
case SDL_TEXTINPUT:
if (!block_text)
sdl_add_keys((uint8_t *)ev.text.text);
if (!block_text) {
unsigned int charcode = sdl_get_char_code(last_sym, last_mod & ~(KMOD_ALT));
// If the key is exactly what we would expect, use sdl_get_char_code()
if (*(uint8_t *)ev.text.text == charcode)
sdl_add_key(sdl_get_char_code(last_sym, last_mod));
else
sdl_add_keys((uint8_t *)ev.text.text);
}
break;
case SDL_KEYUP:
last_mod = ev.key.keysym.mod;
if (!(ev.key.keysym.mod & (KMOD_CTRL|KMOD_ALT|KMOD_GUI)))
block_text = 0;
break;
......
......@@ -2770,6 +2770,7 @@ BOOL doterm(struct bbslist *bbs)
break;
case CIO_KEY_SHIFT_IC: /* Shift-Insert - Paste */
do_paste();
key = 0;
break;
case 0x3000: /* ALT-B - Scrollback */
setup_mouse_events(NULL);
......@@ -2814,6 +2815,7 @@ BOOL doterm(struct bbslist *bbs)
}
showmouse();
_setcursortype(_NORMALCURSOR);
key = 0;
}
break;
case 0x2100: /* ALT-F */
......@@ -3331,7 +3333,7 @@ BOOL doterm(struct bbslist *bbs)
key='\b';
/* FALLTHROUGH to default */
default:
if(key<256) {
if(key<256 && key >= 0) {
ch[0]=key;
conn_send(ch,1,0);
}
......
......@@ -212,6 +212,7 @@ struct alsa_api_struct *alsa_api=NULL;
#ifdef XPDEV_THREAD_SAFE
static void init_sample(void);
static BOOL xp_play_sample_locked(const unsigned char *sample, size_t size, BOOL background);
#endif
/********************************************************************************/
......@@ -418,10 +419,12 @@ DLLCALL xptone_open_locked(void)
handle_rc++;
#ifdef XPDEV_THREAD_SAFE
pthread_mutex_unlock(&handle_mutex);
#endif
pthread_mutex_lock(&sample_mutex);
if (samples_posted == 0)
xp_play_sample_locked((unsigned char *)"\x80", 1, FALSE);
pthread_mutex_unlock(&sample_mutex);
#else
xptone(0, 1, WAVE_SHAPE_SQUARE);
#ifdef XPDEV_THREAD_SAFE
pthread_mutex_lock(&handle_mutex);
#endif
if (pulseaudio_device_open_failed) {
handle_type = SOUND_DEVICE_CLOSED;
......@@ -995,20 +998,20 @@ void DLLCALL xp_play_sample_thread(void *data)
waited=FALSE;
posted_last=FALSE;
pthread_mutex_lock(&handle_mutex);
if(pthread_mutex_lock(&sample_mutex)!=0) {
pthread_mutex_unlock(&handle_mutex);
goto error_return;
}
if(handle_type==SOUND_DEVICE_CLOSED) {
must_close=TRUE;
if(!xptone_open_locked()) {
sem_post(&sample_complete_sem);
pthread_mutex_unlock(&sample_mutex);
pthread_mutex_unlock(&handle_mutex);
continue;
}
}
if(pthread_mutex_lock(&sample_mutex)!=0) {
pthread_mutex_unlock(&handle_mutex);
goto error_return;
}
this_sample_size=sample_size;
FREE_AND_NULL(sample);
sample=(unsigned char *)malloc(sample_size);
......@@ -1067,15 +1070,8 @@ init_sample(void)
sem_init(&sample_complete_sem, 0, 0);
}
/*
* This MUST not return false after sample goes into the sample buffer in the background.
* If it does, the caller won't be able to free() it.
*/
BOOL DLLCALL xp_play_sample(const unsigned char *sample, size_t size, BOOL background)
static BOOL xp_play_sample_locked(const unsigned char *sample, size_t size, BOOL background)
{
pthread_once(&sample_initialized_pto, init_sample);
pthread_mutex_lock(&sample_mutex);
if(!sample_thread_running) {
_beginthread(xp_play_sample_thread, 0,NULL);
sem_wait(&sample_complete_sem);
......@@ -1099,8 +1095,22 @@ BOOL DLLCALL xp_play_sample(const unsigned char *sample, size_t size, BOOL backg
samples_posted--;
}
}
return TRUE;
}
/*
* This MUST not return false after sample goes into the sample buffer in the background.
* If it does, the caller won't be able to free() it.
*/
BOOL DLLCALL xp_play_sample(const unsigned char *sample, size_t size, BOOL background)
{
BOOL ret;
pthread_once(&sample_initialized_pto, init_sample);
pthread_mutex_lock(&sample_mutex);
ret = xp_play_sample_locked(sample, size, background);
pthread_mutex_unlock(&sample_mutex);
return(TRUE);
return(ret);
}
#else
BOOL DLLCALL xp_play_sample(const unsigned char *sample, size_t sample_size, BOOL background)
......