fix segfault when stopping JACK2 server

This commit is contained in:
kennypm 2022-02-24 02:46:45 -05:00
parent a1d046b2e7
commit 318a6e0969
2 changed files with 10 additions and 3 deletions

View File

@ -5,7 +5,7 @@ project(
meson_version: '>= 0.49.0', meson_version: '>= 0.49.0',
default_options : [ default_options : [
'cpp_std=c++17', 'cpp_std=c++17',
'buildtype=release', 'buildtype=debug',
'default_library=static' 'default_library=static'
], ],
) )

View File

@ -24,7 +24,8 @@ std::string waybar::modules::JACK::JACKState() {
proc_t** proctab = readproctab(PROC_FILLSTAT); proc_t** proctab = readproctab(PROC_FILLSTAT);
for(int i=0; proctab[i]; i++) { for(int i=0; proctab[i]; i++) {
procname = proctab[i]->cmd; procname = proctab[i]->cmd;
if(!procname.compare("jackd") || !procname.compare("pipewire")) if(!procname.compare("jackd") || !procname.compare("jackdbus") ||
!procname.compare("pipewire"))
foundJACK = true; foundJACK = true;
freeproc(proctab[i]); freeproc(proctab[i]);
} }
@ -116,8 +117,14 @@ int waybar::modules::JACK::xrun() {
return 0; return 0;
} }
/*
** problem: pipewire leaves old client threads hanging around after server
** is killed. was handling this sloppily by calling pthread_cancel() on the
** JACK thread but since JACK2 cleans up after itself properly, this call
** led to segfault when using JACK2. probably best course of action is to
** submit a bug report to pipewire.
*/
void waybar::modules::JACK::shutdown() { void waybar::modules::JACK::shutdown() {
pthread_cancel(jack_thread_);
client_ = NULL; client_ = NULL;
state_ = "disconnected"; state_ = "disconnected";
xruns_ = 0; xruns_ = 0;