From c4ac6f813fef50c3f4624849ddd9f59e680bdc18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Thu, 18 Mar 2021 17:23:15 -0400 Subject: [PATCH] When trying to open pulse, play a millisecond of silence This allows the playback thread to open the device and errors to be checked. Otherwise, the first sound won't play. --- src/xpdev/xpbeep.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/xpdev/xpbeep.c b/src/xpdev/xpbeep.c index 7d01392337..574fc9ac2b 100644 --- a/src/xpdev/xpbeep.c +++ b/src/xpdev/xpbeep.c @@ -416,7 +416,17 @@ DLLCALL xptone_open_locked(void) if(pu_api != NULL) { handle_type=SOUND_DEVICE_PULSEAUDIO; handle_rc++; - return(TRUE); + pthread_mutex_unlock(&handle_mutex); + xptone(0, 1, WAVE_SHAPE_SQUARE, FALSE); + pthread_mutex_lock(&handle_mutex); + if (pulseaudio_device_open_failed) { +fprintf(stderr, "Pulse broke\n"); + handle_type = SOUND_DEVICE_CLOSED; + } + else { +fprintf(stderr, "Using pulse\n"); + return(TRUE); + } } } #endif @@ -632,6 +642,7 @@ DLLCALL xptone_open_locked(void) return(TRUE); } #endif + return(FALSE); } -- GitLab