summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/surfaces/osc/osc.cc21
-rw-r--r--libs/surfaces/osc/osc.h43
-rw-r--r--libs/surfaces/osc/osc_gui.cc145
-rw-r--r--libs/surfaces/osc/wscript5
4 files changed, 200 insertions, 14 deletions
diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc
index 8ce7969307..90f9afa917 100644
--- a/libs/surfaces/osc/osc.cc
+++ b/libs/surfaces/osc/osc.cc
@@ -83,6 +83,8 @@ OSC::OSC (Session& s, uint32_t port)
, _osc_unix_server (0)
, _namespace_root ("/ardour")
, _send_route_changes (true)
+ , _debugmode (Off)
+ , gui (0)
{
_instance = this;
@@ -329,9 +331,6 @@ OSC::register_callbacks()
serv = srvs[i];
- /* this is a special catchall handler */
-
- lo_server_add_method (serv, 0, 0, _catchall, this);
#define REGISTER_CALLBACK(serv,path,types, function) lo_server_add_method (serv, path, types, OSC::_ ## function, this)
@@ -413,6 +412,10 @@ OSC::register_callbacks()
//lo_server_add_method(serv, "/register_auto_update", "siss", OSC::global_register_auto_update_handler, this);
//lo_server_add_method(serv, "/unregister_auto_update", "sss", OSC::_global_unregister_auto_update_handler, this);
+ /* this is a special catchall handler,
+ * register at the end so this is only called if no
+ * other handler matches (used for debug) */
+ lo_server_add_method (serv, 0, 0, _catchall, this);
}
}
@@ -675,6 +678,10 @@ OSC::catchall (const char *path, const char* /*types*/, lo_arg **argv, int argc,
ret = 0;
}
+ if ((ret && _debugmode == Unhandled) || _debugmode == All) {
+ PBD::info << "Unhandled OSC message: " << path << endmsg;
+ }
+
return ret;
}
@@ -1163,7 +1170,9 @@ OSC::route_plugin_parameter_print (int rid, int piid, int par)
XMLNode&
OSC::get_state ()
{
- return ControlProtocol::get_state();
+ XMLNode& node (ControlProtocol::get_state());
+ node.add_property("debugmode", (int) _debugmode); // TODO: enum2str
+ return node;
}
int
@@ -1172,6 +1181,10 @@ OSC::set_state (const XMLNode& node, int version)
if (ControlProtocol::set_state (node, version)) {
return -1;
}
+ XMLProperty const * p = node.property (X_("debugmode"));
+ if (p) {
+ _debugmode = OSCDebugMode (std::stoi(p->value ()));
+ }
return 0;
}
diff --git a/libs/surfaces/osc/osc.h b/libs/surfaces/osc/osc.h
index c19a8d0bb4..9c96d5f593 100644
--- a/libs/surfaces/osc/osc.h
+++ b/libs/surfaces/osc/osc.h
@@ -69,6 +69,10 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
XMLNode& get_state ();
int set_state (const XMLNode&, int version);
+ bool has_editor () const { return true; }
+ void* get_gui () const;
+ void tear_down_gui ();
+
int set_active (bool yn);
bool get_active () const;
int set_feedback (bool yn);
@@ -81,6 +85,16 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
static void* request_factory (uint32_t);
+ enum OSCDebugMode {
+ Off,
+ Unhandled,
+ All
+ };
+
+ std::string get_server_url ();
+ void set_debug_mode (OSCDebugMode m) { _debugmode = m; }
+ OSCDebugMode get_debug_mode () { return _debugmode; }
+
protected:
void thread_init ();
void do_request (OSCUIRequest*);
@@ -100,6 +114,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
std::string _osc_url_file;
std::string _namespace_root;
bool _send_route_changes;
+ OSCDebugMode _debugmode;
void register_callbacks ();
@@ -111,7 +126,6 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
// end "Application Hook" handles
- std::string get_server_url ();
std::string get_unix_server_url ();
void send_current_value (const char* path, lo_arg** argv, int argc, lo_message msg);
@@ -127,11 +141,17 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
void transport_speed (lo_message msg);
void record_enabled (lo_message msg);
+#define OSC_DEBUG \
+ if (_debugmode == All) { \
+ PBD::info << "OSC: " << path << " " << types << endmsg; \
+ }
+
#define PATH_CALLBACK_MSG(name) \
static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
} \
- int cb_ ## name (const char *, const char *, lo_arg **, int, void *data) { \
+ int cb_ ## name (const char *path, const char *types, lo_arg **, int, void *data) { \
+ OSC_DEBUG; \
name (data); \
return 0; \
}
@@ -145,7 +165,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
} \
- int cb_ ## name (const char *, const char *types, lo_arg ** argv, int argc, void *) { \
+ int cb_ ## name (const char *path, const char *types, lo_arg ** argv, int argc, void *) { \
+ OSC_DEBUG; \
if (argc > 0 && !strcmp (types, "f") && argv[0]->f != 1.0) { return 0; } \
name (); \
return 0; \
@@ -173,7 +194,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
} \
- int cb_ ## name (const char *, const char *, lo_arg **argv, int argc, void *) { \
+ int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *) { \
+ OSC_DEBUG; \
if (argc > 0) { \
name (optional argv[0]->type); \
} \
@@ -187,7 +209,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
} \
- int cb_ ## name (const char *, const char *, lo_arg **argv, int argc, void *) { \
+ int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *) { \
+ OSC_DEBUG; \
if (argc > 1) { \
name (argv[0]->arg1type, argv[1]->arg2type); \
} \
@@ -198,7 +221,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
} \
- int cb_ ## name (const char *, const char *, lo_arg **argv, int argc, void *) { \
+ int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *) { \
+ OSC_DEBUG; \
if (argc > 1) { \
name (argv[0]->arg1type, argv[1]->arg2type,argv[2]->arg3type); \
} \
@@ -209,7 +233,8 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
} \
- int cb_ ## name (const char *, const char *, lo_arg **argv, int argc, void *) { \
+ int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *) { \
+ OSC_DEBUG; \
if (argc > 1) { \
name (argv[0]->arg1type, argv[1]->arg2type,argv[2]->arg3type,argv[3]->arg4type); \
} \
@@ -254,12 +279,14 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
void update_clock ();
-
typedef std::list<OSCRouteObserver*> RouteObservers;
RouteObservers route_observers;
static OSC* _instance;
+
+ mutable void *gui;
+ void build_gui ();
};
} // namespace
diff --git a/libs/surfaces/osc/osc_gui.cc b/libs/surfaces/osc/osc_gui.cc
new file mode 100644
index 0000000000..7879b75f19
--- /dev/null
+++ b/libs/surfaces/osc/osc_gui.cc
@@ -0,0 +1,145 @@
+/*
+ Copyright (C) 2016 Robin Gareus <robin@gareus.org
+ Copyright (C) 2009-2012 Paul Davis
+
+ This program 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.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <iostream>
+#include <list>
+#include <string>
+
+#include <gtkmm/box.h>
+#include <gtkmm/table.h>
+#include <gtkmm/label.h>
+#include <gtkmm/comboboxtext.h>
+
+#include "gtkmm2ext/gtk_ui.h"
+#include "gtkmm2ext/gui_thread.h"
+#include "gtkmm2ext/utils.h"
+
+#include "osc.h"
+
+#include "i18n.h"
+
+namespace ArdourSurface {
+
+class OSC_GUI : public Gtk::VBox
+{
+ public:
+ OSC_GUI (OSC&);
+ ~OSC_GUI ();
+
+private:
+ Gtk::ComboBoxText debug_combo;
+ void debug_changed ();
+
+ OSC& cp;
+};
+
+
+void*
+OSC::get_gui () const
+{
+ if (!gui) {
+ const_cast<OSC*>(this)->build_gui ();
+ }
+ static_cast<Gtk::VBox*>(gui)->show_all();
+ return gui;
+}
+
+void
+OSC::tear_down_gui ()
+{
+ if (gui) {
+ Gtk::Widget *w = static_cast<Gtk::VBox*>(gui)->get_parent();
+ if (w) {
+ w->hide();
+ delete w;
+ }
+ }
+ delete (OSC_GUI*) gui;
+ gui = 0;
+}
+
+void
+OSC::build_gui ()
+{
+ gui = (void*) new OSC_GUI (*this);
+}
+
+} // end namespace
+
+///////////////////////////////////////////////////////////////////////////////
+
+using namespace PBD;
+using namespace Gtk;
+using namespace Gtkmm2ext;
+using namespace ArdourSurface;
+
+OSC_GUI::OSC_GUI (OSC& p)
+ : cp (p)
+{
+ int n = 0; // table row
+ Table* table = manage (new Table);
+ Label* label;
+
+ label = manage (new Gtk::Label(_("Connection:")));
+ table->attach (*label, 0, 1, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
+ label = manage (new Gtk::Label(cp.get_server_url()));
+ table->attach (*label, 1, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
+ ++n;
+
+ label = manage (new Gtk::Label(_("Debug:")));
+ table->attach (*label, 0, 1, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
+ table->attach (debug_combo, 1, 2, n, n+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
+
+ std::vector<std::string> debug_options;
+ debug_options.push_back (_("Off"));
+ debug_options.push_back (_("Log invalid messages"));
+ debug_options.push_back (_("Log all messages"));
+
+ set_popdown_strings (debug_combo, debug_options);
+ debug_combo.set_active ((int)cp.get_debug_mode());
+
+ table->show_all ();
+ pack_start (*table, false, false);
+
+ debug_combo.signal_changed().connect (sigc::mem_fun (*this, &OSC_GUI::debug_changed));
+}
+
+OSC_GUI::~OSC_GUI ()
+{
+}
+
+void
+OSC_GUI::debug_changed ()
+{
+ std::string str = debug_combo.get_active_text ();
+ if (str == _("Off")) {
+ cp.set_debug_mode (OSC::Off);
+ }
+ else if (str == _("Log invalid messages")) {
+ cp.set_debug_mode (OSC::Unhandled);
+ }
+ else if (str == _("Log all messages")) {
+ cp.set_debug_mode (OSC::All);
+ }
+ else {
+ std::cerr << "Invalid OSC Debug Mode\n";
+ assert (0);
+ }
+}
diff --git a/libs/surfaces/osc/wscript b/libs/surfaces/osc/wscript
index d6e8ff2f7c..48f24f6d4f 100644
--- a/libs/surfaces/osc/wscript
+++ b/libs/surfaces/osc/wscript
@@ -19,6 +19,7 @@ def build(bld):
osc_controllable.cc
osc_route_observer.cc
interface.cc
+ osc_gui.cc
'''
obj.export_includes = ['.']
obj.defines = [ 'PACKAGE="ardour_osc"' ]
@@ -26,8 +27,8 @@ def build(bld):
obj.includes = ['.', './osc']
obj.name = 'libardour_osc'
obj.target = 'ardour_osc'
- obj.uselib = ' LO '
- obj.use = 'libardour libardour_cp libpbd'
+ obj.uselib = 'LO GTKMM GTK GDK'
+ obj.use = 'libardour libardour_cp libgtkmm2ext libpbd'
obj.install_path = os.path.join(bld.env['LIBDIR'], 'surfaces')
def shutdown():