Skip to content

Commit

Permalink
check for jack on startup, start qjackctl if not running (optional)
Browse files Browse the repository at this point in the history
  • Loading branch information
gisogrimm committed Sep 20, 2024
1 parent eb132e2 commit faff26f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 13 deletions.
14 changes: 13 additions & 1 deletion gui/src/tascar_mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "logo.xpm"
#include "pdfexport.h"
#include "tascar.res.c"
#include "tascar_os.h"
#include <fstream>

#undef WEBKIT2GTK30
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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<Cairo::Context>& cr)
Expand Down Expand Up @@ -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)) {
Expand Down
24 changes: 13 additions & 11 deletions gui/src/tascar_mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,31 @@
#ifndef TASCAR_MAINWINDOW_H
#define TASCAR_MAINWINDOW_H

#include "gui_elements.h"
#include "scene_manager.h"
#include "viewport.h"
#include <gtkmm.h>
#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include "scene_manager.h"
#include "viewport.h"
#include "gui_elements.h"
#include <gtksourceview/gtksource.h>
#include <gtksourceviewmm.h>

#if defined (WEBKIT2GTK30) || defined(WEBKIT2GTK40)
#if defined(WEBKIT2GTK30) || defined(WEBKIT2GTK40)
#include <webkit2/webkit2.h>
#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<Gtk::Builder>& refGlade);
tascar_window_t(BaseObjectType* cobject,
const Glib::RefPtr<Gtk::Builder>& refGlade);
virtual ~tascar_window_t();
void load(const std::string& fname);

protected:
Glib::RefPtr<Gtk::Builder> m_refBuilder;
//Signal handlers:
// Signal handlers:
void on_menu_file_new();
void on_menu_file_open();
void on_menu_file_open_example();
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion libtascar/include/jackclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

#include <atomic>
#include <jack/jack.h>
#include <mutex>
#include <pthread.h>
#include <string>
#include <vector>
#include <mutex>

class jackc_portless_t {
public:
Expand Down Expand Up @@ -180,6 +180,8 @@ class jackc_transport_t : public jackc_t {
double stop_at_time;
};

bool test_for_jack_server();

#endif

/*
Expand Down
13 changes: 13 additions & 0 deletions libtascar/src/jackclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,19 @@ int jackc_db_t::process(jack_nframes_t, const std::vector<float*>& 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++
Expand Down

0 comments on commit faff26f

Please sign in to comment.