From 668522d772ee1e940ad7f1799299d359ae3df58c Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 14 Jan 2023 19:54:51 -0800 Subject: jack: ensure sound_data_read is always signaled The other side needs to be waked up should it be blocked in the cond var, and we're not going to send anything. Otherwise it won't notice !running and exit its side. This should take care of the --use-jack hangs on shutdown --- src/rmd_jack.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/rmd_jack.c b/src/rmd_jack.c index a4227fc..4168a35 100644 --- a/src/rmd_jack.c +++ b/src/rmd_jack.c @@ -50,8 +50,14 @@ static int rmdJackCapture(jack_nframes_t nframes, void *jdata_t) { JackData *jdata = (JackData *)jdata_t; - if (!jdata->pdata->running || jdata->pdata->paused || !jdata->capture_started) + if (!jdata->pdata->running || jdata->pdata->paused || !jdata->capture_started) { + /* still produce a signal on sound_data_read just to ensure the other side + * wakes up and realizes running/paused etc. + */ + pthread_cond_signal(jdata->sound_data_read); + return 0; + } for (int i = 0; i < jdata->nports; i++) jdata->portbuf[i] = jack_port_get_buffer(jdata->ports[i], nframes); @@ -122,7 +128,10 @@ static void rmdJackShutdown(void *jdata_t) { JackData *jdata = (JackData *)jdata_t; + pthread_mutex_unlock(jdata->sound_buffer_mutex); jdata->pdata->running = FALSE; + pthread_cond_signal(jdata->sound_data_read); + pthread_mutex_lock(jdata->sound_buffer_mutex); fprintf (stderr, "JACK shutdown\n"); } -- cgit v1.2.3