diff options
Diffstat (limited to 'libs/surfaces/osc/osc.cc')
-rw-r--r-- | libs/surfaces/osc/osc.cc | 87 |
1 files changed, 83 insertions, 4 deletions
diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 357b82d4d2..d02626f4af 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -34,6 +34,7 @@ #include <pbd/file_utils.h> #include <pbd/failed_constructor.h> +#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" @@ -164,6 +166,13 @@ OSC::start () _port++; 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); #ifdef ARDOUR_OSC_UNIX_SERVER @@ -172,7 +181,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); @@ -182,6 +191,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 @@ -221,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<IOSource> 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<IOSource> 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<IOSource> 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); @@ -356,8 +371,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); @@ -892,6 +907,70 @@ 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<Route> r = session->route_by_remote_id (rid); + + if (!r) { + return -1; + } + + /* revert to zero-based counting */ + + if (sid > 0) { + --sid; + } + + boost::shared_ptr<Processor> p = r->nth_send (sid); + + if (p) { + boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p); + boost::shared_ptr<Amp> a = s->amp(); + + if (a) { + a->set_gain (val, this); + } + } + return 0; +} + +int +OSC::route_set_send_gain_dB (int rid, int sid, float val) +{ + if (!session) { + return -1; + } + + boost::shared_ptr<Route> r = session->route_by_remote_id (rid); + + if (!r) { + return -1; + } + + /* revert to zero-based counting */ + + if (sid > 0) { + --sid; + } + + boost::shared_ptr<Processor> p = r->nth_send (sid); + + if (p) { + boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p); + boost::shared_ptr<Amp> a = s->amp(); + + if (a) { + a->set_gain (dB_to_coefficient (val), this); + } + } + return 0; +} + +int OSC::route_plugin_parameter (int rid, int piid, int par, float val) { if (!session) { |