Prevent adding a 2nd MIDI input/output port
authorRobin Gareus <robin@gareus.org>
Thu, 11 Jul 2019 20:57:34 +0000 (22:57 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 11 Jul 2019 20:57:34 +0000 (22:57 +0200)
Ardour's Tracks/Routes are not capable of handing more than one
MIDI port per per route properly. Most Plugin standards don't support
this either.

However, at this point in time IO::ensure_ports_locked() is not
limited by this restriction!

It is still possible to indirectly add a 2nd MIDI data-buffer
and output-port via plugin pin-management, or simply plugins with
two MIDI output ports when using flexible I/O.

libs/ardour/ardour/io.h
libs/ardour/io.cc

index 3f4fdc5797919efcccd3e779bb5b3e51f73322fa..d9fc412e279d2d8287a2258715f6fa56323d9d6d 100644 (file)
@@ -104,6 +104,8 @@ public:
 
        boost::shared_ptr<Bundle> bundle () { return _bundle; }
 
+       bool can_add_port (DataType) const;
+
        int add_port (std::string connection, void *src, DataType type = DataType::NIL);
        int remove_port (boost::shared_ptr<Port>, void *src);
        int connect (boost::shared_ptr<Port> our_port, std::string other_port, void *src);
index c6624b2e4a8d51650e33201792fc5013ffcfc04c..52bbd59b5f636945cd1778d177bbb6c243dfe58c 100644 (file)
@@ -200,6 +200,19 @@ IO::connect (boost::shared_ptr<Port> our_port, string other_port, void* src)
        return 0;
 }
 
+bool
+IO::can_add_port (DataType type) const
+{
+       switch (type) {
+               case DataType::NIL:
+                       return false;
+               case DataType::AUDIO:
+                       return true;
+               case DataType::MIDI:
+                       return _ports.count ().n_midi() < 1;
+       }
+}
+
 int
 IO::remove_port (boost::shared_ptr<Port> port, void* src)
 {
@@ -269,6 +282,10 @@ IO::add_port (string destination, void* src, DataType type)
                type = _default_type;
        }
 
+       if (!can_add_port (type)) {
+               return -1;
+       }
+
        ChanCount before = _ports.count ();
        ChanCount after = before;
        after.set (type, after.get (type) + 1);