OSC: issue 7116 fix send enable not working
authorLen Ovens <len@ovenwerks.net>
Fri, 18 Nov 2016 15:53:40 +0000 (07:53 -0800)
committerLen Ovens <len@ovenwerks.net>
Fri, 18 Nov 2016 15:53:40 +0000 (07:53 -0800)
libs/surfaces/osc/osc.cc
libs/surfaces/osc/osc_select_observer.cc
libs/surfaces/osc/osc_select_observer.h

index 4a0e8657d0776f703f10a7fa5d2517f71e807c07..4d4e20aae61a6e3ed72ef17fee5c153aa1919df4 100644 (file)
@@ -2597,6 +2597,18 @@ OSC::route_set_send_enable (int ssid, int sid, float val, lo_message msg)
                }
 
                if (s->send_level_controllable (sid)) {
+                       boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
+                       if (!r) {
+                               return 0;
+                       }
+                       boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(sid));
+                       if (snd) {
+                               if (val) {
+                                       snd->activate();
+                               } else {
+                                       snd->deactivate();
+                               }
+                       }
                        return 0;
                }
 
@@ -2624,7 +2636,20 @@ OSC::sel_sendenable (int id, float val, lo_message msg)
                        return 0;
                }
                if (s->send_level_controllable (id)) {
-                       return sel_send_fail ("send_enable", id + 1, 1, get_address (msg));
+                       boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (s);
+                       if (!r) {
+                               // should never get here
+                               return sel_send_fail ("send_enable", id + 1, 0, get_address (msg));
+                       }
+                       boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(id));
+                       if (snd) {
+                               if (val) {
+                                       snd->activate();
+                               } else {
+                                       snd->deactivate();
+                               }
+                       }
+                       return 0;
                }
        }
        return sel_send_fail ("send_enable", id + 1, 0, get_address (msg));
index 657b46ff93eec0c4295e9b628e4622108ad3daaf..7bd274643270dadd4e79815e1965ac65474343b7 100644 (file)
@@ -29,6 +29,8 @@
 #include "ardour/solo_isolate_control.h"
 #include "ardour/solo_safe_control.h"
 #include "ardour/route.h"
+#include "ardour/send.h"
+#include "ardour/processor.h"
 
 #include "osc.h"
 #include "osc_select_observer.h"
@@ -251,8 +253,17 @@ OSCSelectObserver::send_init()
                        enable_message_with_id ("/select/send_enable", nsends + 1, _strip->send_enable_controllable(nsends));
                        sends = true;
                } else if (sends) {
-                       // not used by Ardour, just mixbus so in Ardour always true
-                       clear_strip_with_id ("/select/send_enable", nsends + 1, 1);
+                       boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_strip);
+                       if (!r) {
+                               // should never get here
+                               clear_strip_with_id ("/select/send_enable", nsends + 1, 0);
+                       }
+                       boost::shared_ptr<Send> snd = boost::dynamic_pointer_cast<Send> (r->nth_send(nsends));
+                       if (snd) {
+                               boost::shared_ptr<Processor> proc = boost::dynamic_pointer_cast<Processor> (snd);
+                               proc->ActiveChanged.connect (strip_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::send_enable, this, X_("/select/send_enable"), nsends + 1, proc), OSC::instance());
+                               clear_strip_with_id ("/select/send_enable", nsends + 1, proc->enabled());
+                       }
                }
                // this should get signalled by the route the send goes to, (TODO)
                if (!gainmode && sends) { // if the gain control is there, this is too
@@ -542,6 +553,15 @@ OSCSelectObserver::send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable>
        lo_message_free (msg);
 }
 
+void
+OSCSelectObserver::send_enable (string path, uint32_t id, boost::shared_ptr<Processor> proc)
+{
+       // with no delay value is wrong
+       usleep(10);
+
+       clear_strip_with_id ("/select/send_enable", id, proc->enabled());
+}
+
 void
 OSCSelectObserver::text_with_id (string path, uint32_t id, string name)
 {
index d3abc20c808c880b35058465bf7797476fa99846..b004f938d9cad7826932303d32b76049b07ba627 100644 (file)
@@ -29,6 +29,7 @@
 #include "pbd/controllable.h"
 #include "pbd/stateful.h"
 #include "ardour/types.h"
+#include "ardour/processor.h"
 
 class OSCSelectObserver
 {
@@ -75,6 +76,7 @@ class OSCSelectObserver
        void send_end (void);
        void send_restart (int);
        void send_gain (uint32_t id, boost::shared_ptr<PBD::Controllable> controllable);
+       void send_enable (std::string path, uint32_t id, boost::shared_ptr<ARDOUR::Processor> proc);
        void eq_init (void);
        void eq_end (void);
        void eq_restart (int);