From f7ec31d95dff299bfb8b1f251dc0ccb96905261a Mon Sep 17 00:00:00 2001 From: Len Ovens Date: Tue, 16 Jan 2018 15:16:12 -0800 Subject: OSC: allow each surface to set portmode for that IP. --- libs/surfaces/osc/osc.cc | 29 ++++++++++++++++++++++++++--- libs/surfaces/osc/osc.h | 8 ++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) (limited to 'libs') 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 std::map link_sets; // list of linksets + struct PortAdd { + public: + std::string host; + std::string port; + }; + + std::vector _ports; + // GUI calls std::string get_server_url (); void set_debug_mode (OSCDebugMode m) { _debugmode = m; } -- cgit v1.2.3