summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-02-22 04:33:15 +0000
committerDavid Robillard <d@drobilla.net>2015-02-22 04:33:15 +0000
commitb8e8ee68c7507bcabb0fb7a5476b83f503be0ca3 (patch)
tree92c4cda22324fa49d0209ecdf93c3e643dbe4276 /src
parentd0b8f2a3a5dc1bde35e72f6dffd65b6da861fc6e (diff)
downloadpatchage-b8e8ee68c7507bcabb0fb7a5476b83f503be0ca3.tar.gz
patchage-b8e8ee68c7507bcabb0fb7a5476b83f503be0ca3.tar.bz2
patchage-b8e8ee68c7507bcabb0fb7a5476b83f503be0ca3.zip
Support Jack port order metadata.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@5598 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/JackDriver.cpp64
-rw-r--r--src/Patchage.cpp7
-rw-r--r--src/PatchagePort.hpp30
-rw-r--r--src/jackey.h11
4 files changed, 68 insertions, 44 deletions
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index 09e5738..f8526d5 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -177,6 +177,23 @@ JackDriver::create_port_view(Patchage* patchage,
return port;
}
+static std::string
+get_property(jack_uuid_t subject, const char* key)
+{
+ std::string result;
+
+#ifdef HAVE_JACK_METADATA
+ char* value = NULL;
+ char* datatype = NULL;
+ if (!jack_get_property(subject, key, &value, &datatype)) {
+ result = value;
+ }
+ jack_free(datatype);
+ jack_free(value);
+#endif
+ return result;
+}
+
PatchagePort*
JackDriver::create_port(PatchageModule& parent, jack_port_t* port, PortID id)
{
@@ -184,59 +201,44 @@ JackDriver::create_port(PatchageModule& parent, jack_port_t* port, PortID id)
return NULL;
}
- const char* const type_str = jack_port_type(port);
- char* pretty_name = NULL;
- PortType port_type;
-
-#ifdef HAVE_JACK_METADATA
- char* datatype = NULL;
- const jack_uuid_t uuid = jack_port_uuid(port);
- jack_get_property(uuid, JACK_METADATA_PRETTY_NAME, &pretty_name, &datatype);
-#endif
+ const char* const type_str = jack_port_type(port);
+ const jack_uuid_t uuid = jack_port_uuid(port);
+ const std::string label = get_property(uuid, JACK_METADATA_PRETTY_NAME);
+ const std::string order_str = get_property(uuid, JACKEY_ORDER);
+ boost::optional<int> order;
+ if (!order_str.empty()) {
+ order = atoi(order_str.c_str());
+ }
+ PortType port_type;
if (!strcmp(type_str, JACK_DEFAULT_AUDIO_TYPE)) {
- char* signal_type = NULL;
-#ifdef HAVE_JACK_METADATA
- jack_get_property(uuid, JACKEY_SIGNAL_TYPE, &signal_type, &datatype);
- jack_free(datatype);
-#endif
- if (signal_type && !strcmp(signal_type, "CV")) {
+ port_type = JACK_AUDIO;
+ if (get_property(uuid, JACKEY_SIGNAL_TYPE) == "CV") {
port_type = JACK_CV;
- jack_free(signal_type);
- } else {
- port_type = JACK_AUDIO;
}
} else if (!strcmp(type_str, JACK_DEFAULT_MIDI_TYPE)) {
- char* event_types = NULL;
-#ifdef HAVE_JACK_METADATA
- jack_get_property(uuid, JACKEY_EVENT_TYPES, &event_types, &datatype);
- jack_free(datatype);
-#endif
- if (event_types && !strcmp(event_types, "OSC")) {
+ port_type = JACK_MIDI;
+ if (get_property(uuid, JACKEY_EVENT_TYPES) == "OSC") {
port_type = JACK_OSC;
- jack_free(event_types);
- } else {
- port_type = JACK_MIDI;
}
} else {
_app->warning_msg((format("Jack: Port `%1%' has unknown type `%2%'.")
% jack_port_name(port) % type_str).str());
- jack_free(pretty_name);
return NULL;
}
PatchagePort* ret(
new PatchagePort(parent, port_type, jack_port_short_name(port),
- pretty_name ? pretty_name : "",
+ label,
(jack_port_flags(port) & JackPortIsInput),
_app->conf()->get_port_color(port_type),
- _app->show_human_names()));
+ _app->show_human_names(),
+ order));
if (id.type != PortID::NULL_PORT_ID) {
dynamic_cast<PatchageCanvas*>(parent.canvas())->index_port(id, ret);
}
- jack_free(pretty_name);
return ret;
}
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index e24cf04..f8f58e3 100644
--- a/src/Patchage.cpp
+++ b/src/Patchage.cpp
@@ -91,6 +91,13 @@ port_order(const GanvPort* a, const GanvPort* b, void* data)
const PatchagePort* pa = dynamic_cast<const PatchagePort*>(Glib::wrap(a));
const PatchagePort* pb = dynamic_cast<const PatchagePort*>(Glib::wrap(b));
if (pa && pb) {
+ if (pa->order() && pb->order()) {
+ return *pa->order() - *pb->order();
+ } else if (pa->order()) {
+ return -1;
+ } else if (pb->order()) {
+ return 1;
+ }
return pa->name().compare(pb->name());
}
return 0;
diff --git a/src/PatchagePort.hpp b/src/PatchagePort.hpp
index 8bc06fb..d5d6cb3 100644
--- a/src/PatchagePort.hpp
+++ b/src/PatchagePort.hpp
@@ -38,13 +38,14 @@
class PatchagePort : public Ganv::Port
{
public:
- PatchagePort(Ganv::Module& module,
- PortType type,
- const std::string& name,
- const std::string& human_name,
- bool is_input,
- uint32_t color,
- bool show_human_name)
+ PatchagePort(Ganv::Module& module,
+ PortType type,
+ const std::string& name,
+ const std::string& human_name,
+ bool is_input,
+ uint32_t color,
+ bool show_human_name,
+ boost::optional<int> order=boost::optional<int>())
: Port(module,
(show_human_name && !human_name.empty()) ? human_name : name,
is_input,
@@ -52,6 +53,7 @@ public:
, _type(type)
, _name(name)
, _human_name(human_name)
+ , _order(order)
{
signal_event().connect(
sigc::mem_fun(this, &PatchagePort::on_event));
@@ -87,14 +89,16 @@ public:
return true;
}
- PortType type() const { return _type; }
- const std::string& name() const { return _name; }
- const std::string& human_name() const { return _human_name; }
+ PortType type() const { return _type; }
+ const std::string& name() const { return _name; }
+ const std::string& human_name() const { return _human_name; }
+ const boost::optional<int>& order() const { return _order; }
private:
- PortType _type;
- std::string _name;
- std::string _human_name;
+ PortType _type;
+ std::string _name;
+ std::string _human_name;
+ boost::optional<int> _order;
};
#endif // PATCHAGE_PATCHAGEPORT_HPP
diff --git a/src/jackey.h b/src/jackey.h
index 6695f3d..02a7735 100644
--- a/src/jackey.h
+++ b/src/jackey.h
@@ -59,3 +59,14 @@
channels can be found at http://lv2plug.in/ns/ext/port-groups
*/
#define JACKEY_DESIGNATION "http://lv2plug.in/ns/lv2core#designation"
+
+/**
+ Order for a port.
+
+ This is used to specify the best order to show ports in user interfaces.
+ The value MUST be an integer. There are no other requirements, so there may
+ be gaps in the orders for several ports. Applications should compare the
+ orders of ports to determine their relative order, but must not assign any
+ other relevance to order values.
+*/
+#define JACKEY_ORDER "http://jackaudio.org/metadata/order"