From ccce2b700b823be87ac91819d9611486675a42fe Mon Sep 17 00:00:00 2001 From: kennypm Date: Thu, 24 Feb 2022 02:46:45 -0500 Subject: [PATCH] fix segfault when stopping JACK2 server --- meson.build | 2 +- src/modules/jack.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 33085903..e0fb452b 100644 --- a/meson.build +++ b/meson.build @@ -5,7 +5,7 @@ project( meson_version: '>= 0.49.0', default_options : [ 'cpp_std=c++17', - 'buildtype=release', + 'buildtype=debug', 'default_library=static' ], ) diff --git a/src/modules/jack.cpp b/src/modules/jack.cpp index 45dab230..af4870ed 100644 --- a/src/modules/jack.cpp +++ b/src/modules/jack.cpp @@ -24,7 +24,8 @@ std::string waybar::modules::JACK::JACKState() { proc_t** proctab = readproctab(PROC_FILLSTAT); for(int i=0; proctab[i]; i++) { procname = proctab[i]->cmd; - if(!procname.compare("jackd") || !procname.compare("pipewire")) + if(!procname.compare("jackd") || !procname.compare("jackdbus") || + !procname.compare("pipewire")) foundJACK = true; freeproc(proctab[i]); } @@ -116,8 +117,14 @@ int waybar::modules::JACK::xrun() { 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() { - pthread_cancel(jack_thread_); client_ = NULL; state_ = "disconnected"; xruns_ = 0;