From 46f27770ecaf5226e88ae1cb19d2c6e07251cda7 Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Tue, 11 Aug 2009 14:38:05 +0300 Subject: [PATCH] remove gui/jack_proxy module --- gui/Patchage.cpp | 37 +++-- gui/Patchage.hpp | 2 - gui/dbus_helpers.h | 4 +- gui/jack_proxy.cpp | 428 ----------------------------------------------------- gui/jack_proxy.hpp | 122 --------------- wscript | 3 +- 6 files changed, 23 insertions(+), 573 deletions(-) delete mode 100644 gui/jack_proxy.cpp delete mode 100644 gui/jack_proxy.hpp diff --git a/gui/Patchage.cpp b/gui/Patchage.cpp index b0fc2e3c..4129b5f9 100644 --- a/gui/Patchage.cpp +++ b/gui/Patchage.cpp @@ -36,7 +36,6 @@ #include #include -#include "jack_proxy.hpp" #include "Patchage.hpp" #include "lash_proxy.hpp" #include "project_list.hpp" @@ -195,19 +194,15 @@ Patchage::Patchage(int argc, char** argv) _lash = new lash_proxy(_session); - _jack = new jack_proxy(this); - - _menu_jack_start->signal_activate().connect( - sigc::mem_fun(_jack, &jack_proxy::start_server)); - _menu_jack_stop->signal_activate().connect( - sigc::mem_fun(_jack, &jack_proxy::stop_server)); + //_menu_jack_start->signal_activate().connect(sigc::mem_fun(_jack, &jack_proxy::start_server)); + //_menu_jack_stop->signal_activate().connect(sigc::mem_fun(_jack, &jack_proxy::stop_server)); _menu_a2j_start->signal_activate().connect( sigc::mem_fun(_a2j, &a2j_proxy::start_bridge)); _menu_a2j_stop->signal_activate().connect( sigc::mem_fun(_a2j, &a2j_proxy::stop_bridge)); - jack_status_changed(_jack->is_started()); + //jack_status_changed(_jack->is_started()); connect_widgets(); update_state(); @@ -221,7 +216,6 @@ Patchage::Patchage(int argc, char** argv) Patchage::~Patchage() { - delete _jack; delete _lash; delete _project_list; delete _session; @@ -233,7 +227,6 @@ Patchage::~Patchage() patchage_dbus_uninit(); } - bool Patchage::idle_callback() { @@ -242,10 +235,10 @@ Patchage::idle_callback() return true; } - void Patchage::update_toolbar() { +#if 0 bool started; started = _jack->is_started(); @@ -256,12 +249,13 @@ Patchage::update_toolbar() { _buffer_size_combo->set_active((int)log2f(_jack->buffer_size()) - 5); } +#endif } - void Patchage::update_load() { +#if 0 if (!_jack->is_started()) { _main_xrun_progress->set_text("JACK stopped"); @@ -282,6 +276,7 @@ Patchage::update_load() _max_dsp_load = load; _main_xrun_progress->set_fraction(load); } +#endif } @@ -310,9 +305,11 @@ Patchage::refresh() void Patchage::clear_load() { +#if 0 _main_xrun_progress->set_fraction(0.0); _jack->reset_xruns(); _max_dsp_load = 0.0; +#endif } @@ -364,11 +361,8 @@ Patchage::update_state() void Patchage::connect_widgets() { - _jack->signal_started.connect( - sigc::bind(sigc::mem_fun(this, &Patchage::jack_status_changed), true)); - - _jack->signal_stopped.connect( - sigc::bind(sigc::mem_fun(this, &Patchage::jack_status_changed), false)); + //_jack->signal_started.connect(sigc::bind(sigc::mem_fun(this, &Patchage::jack_status_changed), true)); + //_jack->signal_stopped.connect(sigc::bind(sigc::mem_fun(this, &Patchage::jack_status_changed), false)); } void @@ -439,11 +433,15 @@ Patchage::on_scroll(GdkEventScroll* ev) void Patchage::buffer_size_changed() { +#if 0 const int selected = _buffer_size_combo->get_active_row_number(); - if (selected == -1) { + if (selected == -1) + { update_toolbar(); - } else { + } + else + { uint32_t buffer_size = 1 << (selected+5); // this check is temporal workaround for jack bug @@ -457,6 +455,7 @@ Patchage::buffer_size_changed() } } } +#endif } void diff --git a/gui/Patchage.hpp b/gui/Patchage.hpp index 7cff4a82..0b7df522 100644 --- a/gui/Patchage.hpp +++ b/gui/Patchage.hpp @@ -34,7 +34,6 @@ class PatchageCanvas; class a2j_proxy; -class jack_proxy; class lash_proxy; class project_list; class session; @@ -99,7 +98,6 @@ protected: #endif a2j_proxy * _a2j; - jack_proxy * _jack; session * _session; lash_proxy * _lash; project_list * _project_list; diff --git a/gui/dbus_helpers.h b/gui/dbus_helpers.h index 91b51530..001acf72 100644 --- a/gui/dbus_helpers.h +++ b/gui/dbus_helpers.h @@ -2,7 +2,7 @@ /* * LADI Session Handler (ladish) * - * Copyright (C) 2008 Nedko Arnaudov + * Copyright (C) 2008, 2009 Nedko Arnaudov * ************************************************************************** * This file contains interface to D-Bus helpers @@ -27,6 +27,8 @@ #ifndef DBUS_HELPERS_H__4078F17D_E387_4F96_8CAB_FF0BFF83A295__INCLUDED #define DBUS_HELPERS_H__4078F17D_E387_4F96_8CAB_FF0BFF83A295__INCLUDED +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/gui/jack_proxy.cpp b/gui/jack_proxy.cpp deleted file mode 100644 index baa862b8..00000000 --- a/gui/jack_proxy.cpp +++ /dev/null @@ -1,428 +0,0 @@ -/* -*- Mode: C ; c-basic-offset: 2 -*- */ -/* - * LADI Session Handler (ladish) - * - * Copyright (C) 2008, 2009 Nedko Arnaudov - * - ************************************************************************** - * This file contains code that interface with JACK through D-Bus - ************************************************************************** - * - * LADI Session Handler is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * LADI Session Handler is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LADI Session Handler. If not, see - * or write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "common.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "Patchage.hpp" -#include "jack_proxy.hpp" -#include "dbus_helpers.h" - -#define JACKDBUS_SERVICE "org.jackaudio.service" -#define JACKDBUS_OBJECT "/org/jackaudio/Controller" -#define JACKDBUS_IFACE_CONTROL "org.jackaudio.JackControl" - -#define JACKDBUS_PORT_FLAG_INPUT 0x00000001 -#define JACKDBUS_PORT_FLAG_OUTPUT 0x00000002 -#define JACKDBUS_PORT_FLAG_PHYSICAL 0x00000004 -#define JACKDBUS_PORT_FLAG_CAN_MONITOR 0x00000008 -#define JACKDBUS_PORT_FLAG_TERMINAL 0x00000010 - -#define JACKDBUS_PORT_TYPE_AUDIO 0 -#define JACKDBUS_PORT_TYPE_MIDI 1 - -jack_proxy::jack_proxy(Patchage* app) - : _app(app) - , _server_responding(false) - , _server_started(false) - , _graph_version(0) - , _max_dsp_load(0.0) -{ - patchage_dbus_add_match("type='signal',interface='" DBUS_INTERFACE_DBUS "',member=NameOwnerChanged,arg0='" JACKDBUS_SERVICE "'"); - patchage_dbus_add_filter(dbus_message_hook, this); - - update_attached(); - - if (!_server_responding) { - return; - } -} - - -jack_proxy::~jack_proxy() -{ -} - -void -jack_proxy::update_attached() -{ - bool was_started = _server_started; - _server_started = is_started(); - - if (!_server_responding) { - if (was_started) { - signal_stopped.emit(); - } - return; - } - - if (_server_started && !was_started) { - signal_started.emit(); - return; - } - - if (!_server_started && was_started) { - signal_stopped.emit(); - return; - } -} - - -void -jack_proxy::on_jack_appeared() -{ - info_msg("JACK appeared."); - update_attached(); -} - - -void -jack_proxy::on_jack_disappeared() -{ - info_msg("JACK disappeared."); - - // we are not calling update_attached() here, because it will activate jackdbus - - _server_responding = false; - - if (_server_started) { - signal_stopped.emit(); - } - - _server_started = false; -} - - -DBusHandlerResult -jack_proxy::dbus_message_hook( - DBusConnection* connection, - DBusMessage* message, - void* jack_driver) -{ - const char *object_name; - const char *old_owner; - const char *new_owner; - - assert(jack_driver); - jack_proxy* me = reinterpret_cast(jack_driver); - - //me->info_msg("dbus_message_hook() called."); - - // Handle signals we have subscribed for in attach() - - if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) { - if (!dbus_message_get_args( message, &g_dbus_error, - DBUS_TYPE_STRING, &object_name, - DBUS_TYPE_STRING, &old_owner, - DBUS_TYPE_STRING, &new_owner, - DBUS_TYPE_INVALID)) { - me->error_msg(str(boost::format("dbus_message_get_args() failed to extract " - "NameOwnerChanged signal arguments (%s)") % g_dbus_error.message)); - dbus_error_free(&g_dbus_error); - return DBUS_HANDLER_RESULT_HANDLED; - } - - if ((std::string)object_name != JACKDBUS_SERVICE) - { - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - - if (old_owner[0] == '\0') { - me->on_jack_appeared(); - } else if (new_owner[0] == '\0') { - me->on_jack_disappeared(); - } - - return DBUS_HANDLER_RESULT_HANDLED; - } - - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; -} - -bool -jack_proxy::call( - bool response_expected, - const char* iface, - const char* method, - DBusMessage** reply_ptr_ptr, - int in_type, ...) -{ - va_list ap; - - va_start(ap, in_type); - - _server_responding = patchage_dbus_call_valist( - response_expected, - JACKDBUS_SERVICE, - JACKDBUS_OBJECT, - iface, - method, - reply_ptr_ptr, - in_type, - ap); - - va_end(ap); - - return _server_responding; -} - -bool -jack_proxy::is_started() -{ - DBusMessage* reply_ptr; - dbus_bool_t started; - - if (!call(false, JACKDBUS_IFACE_CONTROL, "IsStarted", &reply_ptr, DBUS_TYPE_INVALID)) { - return false; - } - - if (!dbus_message_get_args(reply_ptr, &g_dbus_error, - DBUS_TYPE_BOOLEAN, &started, - DBUS_TYPE_INVALID)) { - dbus_message_unref(reply_ptr); - dbus_error_free(&g_dbus_error); - error_msg("decoding reply of IsStarted failed."); - return false; - } - - dbus_message_unref(reply_ptr); - - return started; -} - - -void -jack_proxy::start_server() -{ - DBusMessage* reply_ptr; - - if (!call(false, JACKDBUS_IFACE_CONTROL, "StartServer", &reply_ptr, DBUS_TYPE_INVALID)) { - return; - } - - dbus_message_unref(reply_ptr); - - update_attached(); -} - - -void -jack_proxy::stop_server() -{ - DBusMessage* reply_ptr; - - if (!call(false, JACKDBUS_IFACE_CONTROL, "StopServer", &reply_ptr, DBUS_TYPE_INVALID)) { - return; - } - - dbus_message_unref(reply_ptr); - - if (!_server_started) { - _server_started = false; - signal_stopped.emit(); - } -} - -uint32_t -jack_proxy::buffer_size() -{ - DBusMessage* reply_ptr; - dbus_uint32_t buffer_size; - - if (_server_responding && !_server_started) { - goto fail; - } - - if (!call(true, JACKDBUS_IFACE_CONTROL, "GetBufferSize", &reply_ptr, DBUS_TYPE_INVALID)) { - goto fail; - } - - if (!dbus_message_get_args(reply_ptr, &g_dbus_error, DBUS_TYPE_UINT32, &buffer_size, DBUS_TYPE_INVALID)) { - dbus_message_unref(reply_ptr); - dbus_error_free(&g_dbus_error); - error_msg("decoding reply of GetBufferSize failed."); - goto fail; - } - - dbus_message_unref(reply_ptr); - - return buffer_size; - -fail: - return 4096; // something fake, patchage needs it to match combobox value -} - - -bool -jack_proxy::set_buffer_size(uint32_t size) -{ - DBusMessage* reply_ptr; - dbus_uint32_t buffer_size; - - buffer_size = size; - - if (!call(true, JACKDBUS_IFACE_CONTROL, "SetBufferSize", &reply_ptr, DBUS_TYPE_UINT32, &buffer_size, DBUS_TYPE_INVALID)) { - return false; - } - - dbus_message_unref(reply_ptr); - - return true; -} - - -float -jack_proxy::sample_rate() -{ - DBusMessage* reply_ptr; - double sample_rate; - - if (!call(true, JACKDBUS_IFACE_CONTROL, "GetSampleRate", &reply_ptr, DBUS_TYPE_INVALID)) { - return false; - } - - if (!dbus_message_get_args(reply_ptr, &g_dbus_error, DBUS_TYPE_DOUBLE, &sample_rate, DBUS_TYPE_INVALID)) { - dbus_message_unref(reply_ptr); - dbus_error_free(&g_dbus_error); - error_msg("decoding reply of GetSampleRate failed."); - return false; - } - - dbus_message_unref(reply_ptr); - - return sample_rate; -} - - -bool -jack_proxy::is_realtime() -{ - DBusMessage* reply_ptr; - dbus_bool_t realtime; - - if (!call(true, JACKDBUS_IFACE_CONTROL, "IsRealtime", &reply_ptr, DBUS_TYPE_INVALID)) { - return false; - } - - if (!dbus_message_get_args(reply_ptr, &g_dbus_error, DBUS_TYPE_BOOLEAN, &realtime, DBUS_TYPE_INVALID)) { - dbus_message_unref(reply_ptr); - dbus_error_free(&g_dbus_error); - error_msg("decoding reply of IsRealtime failed."); - return false; - } - - dbus_message_unref(reply_ptr); - - return realtime; -} - - -size_t -jack_proxy::xruns() -{ - DBusMessage* reply_ptr; - dbus_uint32_t xruns; - - if (_server_responding && !_server_started) { - return 0; - } - - if (!call(true, JACKDBUS_IFACE_CONTROL, "GetXruns", &reply_ptr, DBUS_TYPE_INVALID)) { - return 0; - } - - if (!dbus_message_get_args(reply_ptr, &g_dbus_error, DBUS_TYPE_UINT32, &xruns, DBUS_TYPE_INVALID)) { - dbus_message_unref(reply_ptr); - dbus_error_free(&g_dbus_error); - error_msg("decoding reply of GetXruns failed."); - return 0; - } - - dbus_message_unref(reply_ptr); - - return xruns; -} - - -void -jack_proxy::reset_xruns() -{ - DBusMessage* reply_ptr; - - if (!call(true, JACKDBUS_IFACE_CONTROL, "ResetXruns", &reply_ptr, DBUS_TYPE_INVALID)) { - return; - } - - dbus_message_unref(reply_ptr); -} - - -float -jack_proxy::get_dsp_load() -{ - DBusMessage* reply_ptr; - double load; - - if (_server_responding && !_server_started) { - return 0.0; - } - - if (!call(true, JACKDBUS_IFACE_CONTROL, "GetLoad", &reply_ptr, DBUS_TYPE_INVALID)) { - return 0.0; - } - - if (!dbus_message_get_args(reply_ptr, &g_dbus_error, DBUS_TYPE_DOUBLE, &load, DBUS_TYPE_INVALID)) { - dbus_message_unref(reply_ptr); - dbus_error_free(&g_dbus_error); - error_msg("decoding reply of GetLoad failed."); - return 0.0; - } - - dbus_message_unref(reply_ptr); - - return load; -} - -void -jack_proxy::error_msg(const std::string& msg) const -{ - _app->error_msg((std::string)"[JACKDBUS] " + msg); -} - -void -jack_proxy::info_msg(const std::string& msg) const -{ - _app->info_msg((std::string)"[JACKDBUS] " + msg); -} diff --git a/gui/jack_proxy.hpp b/gui/jack_proxy.hpp deleted file mode 100644 index 3ca46693..00000000 --- a/gui/jack_proxy.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- Mode: C ; c-basic-offset: 2 -*- */ -/* - * LADI Session Handler (ladish) - * - * Copyright (C) 2008, 2009 Nedko Arnaudov - * - ************************************************************************** - * This file contains interface to code that interfaces JACK through D-Bus - ************************************************************************** - * - * LADI Session Handler is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * LADI Session Handler is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with LADI Session Handler. If not, see - * or write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef PATCHAGE_JACKDBUSDRIVER_HPP -#define PATCHAGE_JACKDBUSDRIVER_HPP - -#include -#include -#include - -#include "Patchage.hpp" - -class jack_proxy -{ -public: - jack_proxy(Patchage* app); - ~jack_proxy(); - - bool is_started(); - bool is_realtime(); - - bool - connect( - const char * client1_name, - const char * port1_name, - const char * client2_name, - const char * port2_name); - - bool - disconnect( - const char * client1_name, - const char * port1_name, - const char * client2_name, - const char * port2_name); - - void reset_xruns(); - - uint32_t buffer_size(); - bool set_buffer_size(uint32_t size); - - float sample_rate(); - - size_t xruns(); - - float get_dsp_load(); - - float get_max_dsp_load(); - void reset_max_dsp_load(); - - void - start_server(); - - void - stop_server(); - - sigc::signal0 signal_started; - sigc::signal0 signal_stopped; - -private: - void error_msg(const std::string& msg) const; - void info_msg(const std::string& msg) const; - - bool - call( - bool response_expected, - const char* iface, - const char* method, - DBusMessage ** reply_ptr_ptr, - int in_type, - ...); - - void - update_attached(); - - static - DBusHandlerResult - dbus_message_hook( - DBusConnection *connection, - DBusMessage *message, - void *me); - - void - on_jack_appeared(); - - void - on_jack_disappeared(); - -private: - Patchage* _app; - - bool _server_responding; - bool _server_started; - - dbus_uint64_t _graph_version; - - float _max_dsp_load; -}; - -#endif // PATCHAGE_JACKDBUSDRIVER_HPP diff --git a/wscript b/wscript index 9562a0f4..d205a657 100644 --- a/wscript +++ b/wscript @@ -261,7 +261,6 @@ def build(bld): 'Patchage.cpp', #'PatchageCanvas.cpp', #'StateManager.cpp', - 'jack_proxy.cpp', 'lash_client.cpp', 'lash_proxy.cpp', 'load_projects_dialog.cpp', @@ -283,6 +282,8 @@ def build(bld): ]: gladish.source.append(os.path.join("dbus", source)) + gladish.source.append('jack_proxy.c') + # Glade UI definitions (XML) bld.install_files(bld.env['DATA_DIR'], 'gui/gui.glade') -- 2.11.4.GIT