From addb33bc630721e623f90b6f3e920eedcdc40742 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 6 Jun 2013 11:14:31 -0400 Subject: implement OSC /ardour/route/send/gainabs and /ardour/route/send/gainDB --- libs/surfaces/osc/osc.cc | 66 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) (limited to 'libs/surfaces/osc/osc.cc') diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 357b82d4d2..ef07ca17fb 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -356,8 +356,8 @@ OSC::register_callbacks() REGISTER_CALLBACK (serv, "/ardour/routes/pan_stereo_width", "if", route_set_pan_stereo_width); REGISTER_CALLBACK (serv, "/ardour/routes/plugin/parameter", "iiif", route_plugin_parameter); REGISTER_CALLBACK (serv, "/ardour/routes/plugin/parameter/print", "iii", route_plugin_parameter_print); - - + REGISTER_CALLBACK (serv, "/ardour/routes/send/gainabs", "iif", route_set_send_gain_abs); + REGISTER_CALLBACK (serv, "/ardour/routes/send/gaindB", "iif", route_set_send_gain_dB); /* still not-really-standardized query interface */ //REGISTER_CALLBACK (serv, "/ardour/*/#current_value", "", current_value); @@ -891,6 +891,68 @@ OSC::route_set_pan_stereo_width (int rid, float pos) } +int +OSC::route_set_send_gain_abs (int rid, int sid, float val) +{ + if (!session) { + return -1; + } + + boost::shared_ptr r = session->route_by_remote_id (rid); + + if (!r) { + return -1; + } + + /* revert to zero-based counting */ + + if (sid > 0) { + --sid; + } + + boost::shared_ptr p = r->nth_send (send); + + if (p) { + boost::shared_ptr s = boost::dynamic_pointer_cast(p); + boost::shared_ptr a = s->amp(); + + if (a) { + a->set_gain (val, this); + } + } +} + +int +OSC::route_set_send_gain_dB (int rid, int sid, float val) +{ + if (!session) { + return -1; + } + + boost::shared_ptr r = session->route_by_remote_id (rid); + + if (!r) { + return -1; + } + + /* revert to zero-based counting */ + + if (sid > 0) { + --sid; + } + + boost::shared_ptr p = r->nth_send (send); + + if (p) { + boost::shared_ptr s = boost::dynamic_pointer_cast(p); + boost::shared_ptr a = s->amp(); + + if (a) { + a->set_gain (dB_to_coefficient (val), this); + } + } +} + int OSC::route_plugin_parameter (int rid, int piid, int par, float val) { -- cgit v1.2.3 From 36359a7d8f96a46574421e31d8980388320d62d0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 6 Jun 2013 11:19:23 -0400 Subject: correct previous premature commit re: OSC and send gain --- libs/surfaces/osc/osc.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libs/surfaces/osc/osc.cc') diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index ef07ca17fb..13dbd3bcf0 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -34,6 +34,7 @@ #include #include +#include "ardour/amp.h" #include "ardour/session.h" #include "ardour/route.h" #include "ardour/audio_track.h" @@ -42,6 +43,7 @@ #include "ardour/filesystem_paths.h" #include "ardour/panner.h" #include "ardour/plugin.h" +#include "ardour/send.h" #include "osc.h" #include "osc_controllable.h" @@ -910,7 +912,7 @@ OSC::route_set_send_gain_abs (int rid, int sid, float val) --sid; } - boost::shared_ptr p = r->nth_send (send); + boost::shared_ptr p = r->nth_send (sid); if (p) { boost::shared_ptr s = boost::dynamic_pointer_cast(p); @@ -941,7 +943,7 @@ OSC::route_set_send_gain_dB (int rid, int sid, float val) --sid; } - boost::shared_ptr p = r->nth_send (send); + boost::shared_ptr p = r->nth_send (sid); if (p) { boost::shared_ptr s = boost::dynamic_pointer_cast(p); -- cgit v1.2.3 From 7d8def38f41fff0f6962acc2c56d517110a73598 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 6 Jun 2013 21:00:34 +0200 Subject: fix compiler warnings --- libs/surfaces/osc/osc.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libs/surfaces/osc/osc.cc') diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 13dbd3bcf0..009587ce85 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -922,6 +922,7 @@ OSC::route_set_send_gain_abs (int rid, int sid, float val) a->set_gain (val, this); } } + return 0; } int @@ -953,6 +954,7 @@ OSC::route_set_send_gain_dB (int rid, int sid, float val) a->set_gain (dB_to_coefficient (val), this); } } + return 0; } int -- cgit v1.2.3 From 024e556cb2c3fb95721aaa83954aed373d2c7d0f Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 7 Jun 2013 16:54:47 +0200 Subject: close network sockets on fork fixes problem with external apps (ie. video-server) inheriting them. --- libs/midi++2/ipmidi_port.cc | 4 ++++ libs/surfaces/osc/osc.cc | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'libs/surfaces/osc/osc.cc') diff --git a/libs/midi++2/ipmidi_port.cc b/libs/midi++2/ipmidi_port.cc index c90a3dbe6f..543c63e343 100644 --- a/libs/midi++2/ipmidi_port.cc +++ b/libs/midi++2/ipmidi_port.cc @@ -160,6 +160,8 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname) return false; } + fcntl(sockin, F_SETFD, fcntl(sockin, F_GETFD) | FD_CLOEXEC); + struct sockaddr_in addrin; ::memset(&addrin, 0, sizeof(addrin)); addrin.sin_family = AF_INET; @@ -206,6 +208,8 @@ IPMIDIPort::open_sockets (int base_port, const string& ifname) ::perror("socket(out)"); return false; } + + fcntl(sockout, F_SETFD, fcntl(sockout, F_GETFD) | FD_CLOEXEC); // Will Hall, Oct 2007 if (!ifname.empty()) { diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 009587ce85..9e80554f0b 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -166,6 +166,9 @@ OSC::start () _port++; continue; } + + int fd = lo_server_get_socket_fd (_osc_server); + fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); #ifdef ARDOUR_OSC_UNIX_SERVER @@ -174,7 +177,7 @@ OSC::start () // attempt to create unix socket server too snprintf(tmpstr, sizeof(tmpstr), "/tmp/sooperlooper_XXXXXX"); - int fd = mkstemp(tmpstr); + fd = mkstemp(tmpstr); if (fd >= 0 ) { unlink (tmpstr); @@ -185,6 +188,8 @@ OSC::start () if (_osc_unix_server) { _osc_unix_socket_path = tmpstr; } + fd = lo_server_get_socket_fd (_osc_unix_server) + fcntl(fdx, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); } #endif -- cgit v1.2.3 From 6b19f5a444fc17372fab6c3450f86ef657dbc956 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 7 Jun 2013 18:02:04 +0200 Subject: OSC bail out if server cannot be started --- libs/surfaces/osc/osc.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libs/surfaces/osc/osc.cc') diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 9e80554f0b..4e80c4dad0 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -167,6 +167,10 @@ OSC::start () continue; } + if (!_osc_server) { + return 1; + } + int fd = lo_server_get_socket_fd (_osc_server); fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); -- cgit v1.2.3 From bdf91de8b7261ca9c23135a05a53f1a7961a9eff Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 7 Jun 2013 18:02:47 +0200 Subject: more OSC socket fcntl() close-on-exec --- libs/surfaces/osc/osc.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'libs/surfaces/osc/osc.cc') diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 4e80c4dad0..d02626f4af 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -191,9 +191,9 @@ OSC::start () if (_osc_unix_server) { _osc_unix_socket_path = tmpstr; + fd = lo_server_get_socket_fd (_osc_unix_server) + fcntl(fdx, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); } - fd = lo_server_get_socket_fd (_osc_unix_server) - fcntl(fdx, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); } #endif @@ -232,19 +232,23 @@ OSC::thread_init () pthread_set_name (X_("OSC")); if (_osc_unix_server) { + const int fd = lo_server_get_socket_fd (_osc_unix_server); Glib::RefPtr src = IOSource::create (lo_server_get_socket_fd (_osc_unix_server), IO_IN|IO_HUP|IO_ERR); src->connect (sigc::bind (sigc::mem_fun (*this, &OSC::osc_input_handler), _osc_unix_server)); src->attach (_main_loop->get_context()); local_server = src->gobj(); g_source_ref (local_server); + fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); } if (_osc_server) { - Glib::RefPtr src = IOSource::create (lo_server_get_socket_fd (_osc_server), IO_IN|IO_HUP|IO_ERR); + const int fd = lo_server_get_socket_fd (_osc_server); + Glib::RefPtr src = IOSource::create (fd, IO_IN|IO_HUP|IO_ERR); src->connect (sigc::bind (sigc::mem_fun (*this, &OSC::osc_input_handler), _osc_server)); src->attach (_main_loop->get_context()); remote_server = src->gobj(); g_source_ref (remote_server); + fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); } PBD::notify_gui_about_thread_creation (X_("gui"), pthread_self(), X_("OSC"), 2048); -- cgit v1.2.3