diff options
author | Len Ovens <len@ovenwerks.net> | 2018-01-16 15:16:12 -0800 |
---|---|---|
committer | Len Ovens <len@ovenwerks.net> | 2018-01-24 08:17:45 -0800 |
commit | f7ec31d95dff299bfb8b1f251dc0ccb96905261a (patch) | |
tree | 30836cbff785e0ff83c3cbeb85dbc69eb2ddd484 /libs | |
parent | d785883836c77c7549ed9cd4b1243b54118d2a84 (diff) |
OSC: allow each surface to set portmode for that IP.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/surfaces/osc/osc.cc | 29 | ||||
-rw-r--r-- | libs/surfaces/osc/osc.h | 8 |
2 files changed, 34 insertions, 3 deletions
diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index a026e0283a..a15c2ea544 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -1400,12 +1400,34 @@ OSC::cancel_all_solos () lo_address OSC::get_address (lo_message msg) { + lo_address addr = lo_message_get_source (msg); + string host = lo_address_get_hostname (addr); + string port = lo_address_get_port (addr); + int protocol = lo_address_get_protocol (addr); + for (uint32_t i = 0; i < _ports.size (); i++) { + std::cout << string_compose ("_ports at %1 of %2\n", i + 1, _ports.size ()); + if (_ports[i].host == host) { + std::cout << "found host " << host << "\n"; + if (_ports[i].port != "auto") { + port = _ports[i].port; + return lo_address_new_with_proto (protocol, host.c_str(), port.c_str()); + } else { + return lo_message_get_source (msg); + } + } + } + std::cout << "host not found\n"; + + // if we get here we need to add a new entry for this surface + PortAdd new_port; + new_port.host = host; if (address_only) { - lo_address addr = lo_message_get_source (msg); - string host = lo_address_get_hostname (addr); - int protocol = lo_address_get_protocol (addr); + new_port.port = remote_port; + _ports.push_back (new_port); return lo_address_new_with_proto (protocol, host.c_str(), remote_port.c_str()); } else { + new_port.port = "auto"; + _ports.push_back (new_port); return lo_message_get_source (msg); } } @@ -1440,6 +1462,7 @@ OSC::clear_devices () } _surface.clear(); link_sets.clear (); + _ports.clear (); PresentationInfo::Change.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&OSC::recalcbanks, this), this); diff --git a/libs/surfaces/osc/osc.h b/libs/surfaces/osc/osc.h index c9dd723f2c..00d8d76353 100644 --- a/libs/surfaces/osc/osc.h +++ b/libs/surfaces/osc/osc.h @@ -206,6 +206,14 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest> std::map<uint32_t, LinkSet> link_sets; // list of linksets + struct PortAdd { + public: + std::string host; + std::string port; + }; + + std::vector<PortAdd> _ports; + // GUI calls std::string get_server_url (); void set_debug_mode (OSCDebugMode m) { _debugmode = m; } |