From faff26f98e67387e36b15a7bf655446e8ba3c1ce Mon Sep 17 00:00:00 2001 From: Giso Grimm Date: Fri, 20 Sep 2024 08:44:17 +0200 Subject: [PATCH] check for jack on startup, start qjackctl if not running (optional) --- gui/src/tascar_mainwindow.cc | 14 +++++++++++++- gui/src/tascar_mainwindow.h | 24 +++++++++++++----------- libtascar/include/jackclient.h | 4 +++- libtascar/src/jackclient.cc | 13 +++++++++++++ 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/gui/src/tascar_mainwindow.cc b/gui/src/tascar_mainwindow.cc index ea238d46..1f58fef9 100644 --- a/gui/src/tascar_mainwindow.cc +++ b/gui/src/tascar_mainwindow.cc @@ -24,6 +24,7 @@ #include "logo.xpm" #include "pdfexport.h" #include "tascar.res.c" +#include "tascar_os.h" #include #undef WEBKIT2GTK30 @@ -273,6 +274,14 @@ tascar_window_t::tascar_window_t(BaseObjectType* cobject, catch(const Gtk::CssProviderError& e) { TASCAR::add_warning("css error: " + e.what()); } + // optionally test for running jack server and start qjackctl: + bool checkforjack = TASCAR::config("tascar.gui.checkforjack", 1); + if(checkforjack) { + bool jack_is_running = test_for_jack_server(); + if(!jack_is_running) { + jackpid = TASCAR::system("qjackctl", false); + } + } } bool tascar_window_t::on_timeout() @@ -420,6 +429,9 @@ tascar_window_t::~tascar_window_t() pthread_mutex_trylock(&mtx_draw); pthread_mutex_unlock(&mtx_draw); pthread_mutex_destroy(&mtx_draw); + if(jackpid > 0) { + terminate_process(jackpid); + } } bool tascar_window_t::draw_scene(const Cairo::RefPtr& cr) @@ -732,7 +744,7 @@ void tascar_window_t::reset_gui() Glib::filename_display_basename(tascar_filename) + "]"); } else { set_title("tascar"); - //resize(200, 60); + // resize(200, 60); } update_object_list(); if(session && (session->scenes.size() > selected_scene)) { diff --git a/gui/src/tascar_mainwindow.h b/gui/src/tascar_mainwindow.h index f4a7f846..9ce0b4d4 100644 --- a/gui/src/tascar_mainwindow.h +++ b/gui/src/tascar_mainwindow.h @@ -20,30 +20,31 @@ #ifndef TASCAR_MAINWINDOW_H #define TASCAR_MAINWINDOW_H +#include "gui_elements.h" +#include "scene_manager.h" +#include "viewport.h" #include #include #include -#include "scene_manager.h" -#include "viewport.h" -#include "gui_elements.h" #include #include -#if defined (WEBKIT2GTK30) || defined(WEBKIT2GTK40) +#if defined(WEBKIT2GTK30) || defined(WEBKIT2GTK40) #include #endif void error_message(const std::string& msg); -class tascar_window_t : public scene_manager_t, public Gtk::Window -{ +class tascar_window_t : public scene_manager_t, public Gtk::Window { public: - tascar_window_t(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + tascar_window_t(BaseObjectType* cobject, + const Glib::RefPtr& refGlade); virtual ~tascar_window_t(); void load(const std::string& fname); + protected: Glib::RefPtr m_refBuilder; - //Signal handlers: + // Signal handlers: void on_menu_file_new(); void on_menu_file_open(); void on_menu_file_open_example(); @@ -95,7 +96,7 @@ class tascar_window_t : public scene_manager_t, public Gtk::Window void on_show_warnings_clicked(); - void set_scale(double s){draw.view.set_scale( s );}; + void set_scale(double s) { draw.view.set_scale(s); }; bool on_map_scroll(GdkEventScroll* e); bool on_map_clicked(GdkEventButton* e); @@ -159,14 +160,15 @@ class tascar_window_t : public scene_manager_t, public Gtk::Window bool sessionloaded; bool sessionquit; -#if defined (WEBKIT2GTK30) || defined(WEBKIT2GTK40) - WebKitWebView *news_view; +#if defined(WEBKIT2GTK30) || defined(WEBKIT2GTK40) + WebKitWebView* news_view; Gtk::Box* news_box; Gtk::Widget* news_viewpp; #endif uint32_t splash_timeout; size_t numlastwarnings = 0; + pid_t jackpid = 0; }; #endif diff --git a/libtascar/include/jackclient.h b/libtascar/include/jackclient.h index 56be2360..63e00c6c 100644 --- a/libtascar/include/jackclient.h +++ b/libtascar/include/jackclient.h @@ -30,10 +30,10 @@ #include #include +#include #include #include #include -#include class jackc_portless_t { public: @@ -180,6 +180,8 @@ class jackc_transport_t : public jackc_t { double stop_at_time; }; +bool test_for_jack_server(); + #endif /* diff --git a/libtascar/src/jackclient.cc b/libtascar/src/jackclient.cc index 1aa7961e..6bcf0116 100644 --- a/libtascar/src/jackclient.cc +++ b/libtascar/src/jackclient.cc @@ -657,6 +657,19 @@ int jackc_db_t::process(jack_nframes_t, const std::vector& inBuffer, return rv; } +bool test_for_jack_server() +{ + bool isrunning = true; + try { + jackc_portless_t jc("test_for_jack_server"); + jc.activate(); + } + catch(...) { + isrunning = false; + } + return isrunning; +} + /* * Local Variables: * mode: c++