summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-27 20:18:41 +0100
committerDavid Robillard <d@drobilla.net>2020-11-27 21:52:29 +0100
commit10a9f00294c3a33477dee21980f91d1417b6ef21 (patch)
tree5fa81e66ffa8f5f22753ced48315db83a5237e9f
parent2146f229086ffe26888d74fffd4bd441bfdaecbe (diff)
downloadpatchage-10a9f00294c3a33477dee21980f91d1417b6ef21.tar.gz
patchage-10a9f00294c3a33477dee21980f91d1417b6ef21.tar.bz2
patchage-10a9f00294c3a33477dee21980f91d1417b6ef21.zip
Ensure that ports always have an ID
-rw-r--r--src/AlsaDriver.cpp10
-rw-r--r--src/JackDbusDriver.cpp7
-rw-r--r--src/JackDbusDriver.hpp1
-rw-r--r--src/JackDriver.cpp1
-rw-r--r--src/PatchagePort.hpp4
-rw-r--r--src/PortID.hpp10
6 files changed, 22 insertions, 11 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp
index fdda5e7..dc07d48 100644
--- a/src/AlsaDriver.cpp
+++ b/src/AlsaDriver.cpp
@@ -322,20 +322,22 @@ AlsaDriver::create_port(PatchageModule& parent,
bool is_input,
snd_seq_addr_t addr)
{
+ const PortID id{addr, is_input};
+
auto* ret =
new PatchagePort(parent,
PortType::alsa_midi,
+ id,
name,
"",
is_input,
_app->conf()->get_port_color(PortType::alsa_midi),
_app->show_human_names());
- dynamic_cast<PatchageCanvas*>(parent.canvas())
- ->index_port(PortID(addr, is_input), ret);
+ dynamic_cast<PatchageCanvas*>(parent.canvas())->index_port(id, ret);
- _app->canvas()->index_port(PortID(addr, is_input), ret);
- _port_addrs.insert(std::make_pair(ret, PortID(addr, is_input)));
+ _app->canvas()->index_port(id, ret);
+ _port_addrs.insert(std::make_pair(ret, id));
return ret;
}
diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp
index 382ec3b..b2acc69 100644
--- a/src/JackDbusDriver.cpp
+++ b/src/JackDbusDriver.cpp
@@ -588,6 +588,7 @@ JackDriver::is_attached() const
void
JackDriver::add_port(PatchageModule* module,
PortType type,
+ PortID id,
const std::string& name,
bool is_input)
{
@@ -597,6 +598,7 @@ JackDriver::add_port(PatchageModule* module,
new PatchagePort(*module,
type,
+ id,
name,
"", // TODO: pretty name
is_input,
@@ -606,8 +608,8 @@ JackDriver::add_port(PatchageModule* module,
void
JackDriver::add_port(dbus_uint64_t /*client_id*/,
- const char* client_name,
- dbus_uint64_t /*port_id*/,
+ const char* client_name,
+ dbus_uint64_t port_id,
const char* port_name,
dbus_uint32_t port_flags,
dbus_uint32_t port_type)
@@ -640,6 +642,7 @@ JackDriver::add_port(dbus_uint64_t /*client_id*/,
add_port(module,
local_port_type,
+ PortID{static_cast<jack_port_id_t>(port_id), false},
port_name,
port_flags & JACKDBUS_PORT_FLAG_INPUT);
}
diff --git a/src/JackDbusDriver.hpp b/src/JackDbusDriver.hpp
index 00c2a83..5b443b0 100644
--- a/src/JackDbusDriver.hpp
+++ b/src/JackDbusDriver.hpp
@@ -83,6 +83,7 @@ private:
void add_port(PatchageModule* module,
PortType type,
+ PortID id,
const std::string& name,
bool is_input);
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index a75aff4..5c08144 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -253,6 +253,7 @@ JackDriver::create_port(PatchageModule& parent,
auto* ret = new PatchagePort(parent,
port_type,
+ id,
jack_port_short_name(port),
label,
(jack_port_flags(port) & JackPortIsInput),
diff --git a/src/PatchagePort.hpp b/src/PatchagePort.hpp
index b790f0d..8a96f20 100644
--- a/src/PatchagePort.hpp
+++ b/src/PatchagePort.hpp
@@ -42,6 +42,7 @@ class PatchagePort : public Ganv::Port
public:
PatchagePort(Ganv::Module& module,
PortType type,
+ PortID id,
const std::string& name,
const std::string& human_name,
bool is_input,
@@ -53,6 +54,7 @@ public:
is_input,
color)
, _type(type)
+ , _id(id)
, _name(name)
, _human_name(human_name)
, _order(order)
@@ -99,12 +101,14 @@ public:
}
PortType type() const { return _type; }
+ PortID id() const { return _id; }
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;
+ PortID _id;
std::string _name;
std::string _human_name;
boost::optional<int> _order;
diff --git a/src/PortID.hpp b/src/PortID.hpp
index c29d662..2d41f92 100644
--- a/src/PortID.hpp
+++ b/src/PortID.hpp
@@ -42,8 +42,8 @@ struct PortID
PortID() = default;
-#ifdef PATCHAGE_LIBJACK
- explicit PortID(jack_port_id_t jack_id, bool = false)
+#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
+ explicit PortID(uint32_t jack_id, bool = false)
: type(Type::jack_id)
{
id.jack_id = jack_id;
@@ -71,8 +71,8 @@ struct PortID
union
{
-#ifdef PATCHAGE_LIBJACK
- jack_port_id_t jack_id;
+#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
+ uint32_t jack_id;
#endif
#ifdef HAVE_ALSA
struct
@@ -118,7 +118,7 @@ operator<(const PortID& a, const PortID& b)
case PortID::Type::nothing:
return true;
case PortID::Type::jack_id:
-#ifdef PATCHAGE_LIBJACK
+#if defined(PATCHAGE_LIBJACK) || defined(HAVE_JACK_DBUS)
return a.id.jack_id < b.id.jack_id;
#endif
break;