OSC: Create new surface struct for ALL incoming messages
authorLen Ovens <len@ovenwerks.net>
Fri, 12 May 2017 03:46:16 +0000 (20:46 -0700)
committerLen Ovens <len@ovenwerks.net>
Fri, 12 May 2017 14:29:29 +0000 (07:29 -0700)
libs/surfaces/osc/osc.cc
libs/surfaces/osc/osc.h

index 9d422eea6f7d74d947f2649965d49e3eedd8781f..9f079e602fd92a81215a1faad56be0ca7ebed671 100644 (file)
@@ -874,6 +874,7 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
 
        } else
        if (!strncmp (path, "/access_action/", 15)) {
+               check_surface (msg);
                if (!(argc && !argv[0]->i)) {
                        std::string action_path = path;
 
@@ -883,6 +884,7 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
                ret = 0;
        } else
        if (strcmp (path, "/strip/listen") == 0) {
+               check_surface (msg);
 
                cerr << "set up listener\n";
 
@@ -914,6 +916,7 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
 
        } else
        if (strcmp (path, "/strip/ignore") == 0) {
+               check_surface (msg);
 
                for (int n = 0; n < argc; ++n) {
 
@@ -1004,6 +1007,9 @@ OSC::catchall (const char *path, const char* types, lo_arg **argv, int argc, lo_
                int ssid = atoi (&path[17]);
                ret = sel_eq_shape (ssid, argv[0]->f, msg);
        }
+       if (ret) {
+               check_surface (msg);
+       }
 
        if ((ret && _debugmode != Off)) {
                debugmsg (_("Unhandled OSC message"), path, types, argv, argc);
@@ -1393,6 +1399,16 @@ OSC::set_surface_gainmode (uint32_t gm, lo_message msg)
        return 0;
 }
 
+int
+OSC::check_surface (lo_message msg)
+{
+       if (!session) {
+               return -1;
+       }
+       get_surface(get_address (msg));
+       return 0;
+}
+
 OSC::OSCSurface *
 OSC::get_surface (lo_address addr)
 {
@@ -1707,6 +1723,7 @@ OSC::transport_frame (lo_message msg)
        if (!session) {
                return;
        }
+       check_surface (msg);
        framepos_t pos = session->transport_frame ();
 
        lo_message reply = lo_message_new ();
@@ -1723,6 +1740,7 @@ OSC::transport_speed (lo_message msg)
        if (!session) {
                return;
        }
+       check_surface (msg);
        double ts = session->transport_speed ();
 
        lo_message reply = lo_message_new ();
@@ -1739,6 +1757,7 @@ OSC::record_enabled (lo_message msg)
        if (!session) {
                return;
        }
+       check_surface (msg);
        int re = (int)session->get_record_enabled ();
 
        lo_message reply = lo_message_new ();
@@ -1753,6 +1772,7 @@ int
 OSC::scrub (float delta, lo_message msg)
 {
        if (!session) return -1;
+       check_surface (msg);
 
        scrub_place = session->transport_frame ();
 
@@ -1963,6 +1983,7 @@ int
 OSC::master_set_pan_stereo_position (float position, lo_message msg)
 {
        if (!session) return -1;
+       OSCSurface *sur = get_surface(get_address (msg));
 
        float endposition = .5;
        boost::shared_ptr<Stripable> s = session->master_out();
@@ -1973,7 +1994,6 @@ OSC::master_set_pan_stereo_position (float position, lo_message msg)
                        endposition = s->pan_azimuth_control()->internal_to_interface (s->pan_azimuth_control()->get_value ());
                }
        }
-       OSCSurface *sur = get_surface(get_address (msg));
 
        if (sur->feedback[4]) {
                lo_message reply = lo_message_new ();
index eeadcf2c6c80fc4e39501d5e25d793371b7239a4..902e0e73d6646313bb52cb41bbb0110bfd83b872 100644 (file)
@@ -217,6 +217,7 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        std::string get_unix_server_url ();
        lo_address get_address (lo_message msg);
        OSCSurface * get_surface (lo_address addr);
+       int check_surface (lo_message msg);
        uint32_t get_sid (boost::shared_ptr<ARDOUR::Stripable> strip, lo_address addr);
        boost::shared_ptr<ARDOUR::Stripable> get_strip (uint32_t ssid, lo_address addr);
        void global_feedback (std::bitset<32> feedback, lo_address addr, uint32_t gainmode);
@@ -285,8 +286,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
                return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
        } \
-       int cb_ ## name (const char *path, const char *types, lo_arg ** argv, int argc, void *) { \
+       int cb_ ## name (const char *path, const char *types, lo_arg ** argv, int argc, void *data) { \
                OSC_DEBUG; \
+               check_surface (data); \
                if (argc > 0 && !strcmp (types, "f") && argv[0]->f != 1.0) { return 0; } \
                name (); \
                return 0; \
@@ -352,8 +354,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
                return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
        } \
-       int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *) { \
+       int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
                OSC_DEBUG; \
+               check_surface (data); \
                if (argc > 0) { \
                        name (optional argv[0]->type); \
                } \
@@ -427,8 +430,9 @@ class OSC : public ARDOUR::ControlProtocol, public AbstractUI<OSCUIRequest>
        static int _ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data, void *user_data) { \
                return static_cast<OSC*>(user_data)->cb_ ## name (path, types, argv, argc, data); \
        } \
-       int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *) { \
+       int cb_ ## name (const char *path, const char *types, lo_arg **argv, int argc, void *data) { \
                OSC_DEBUG; \
+               check_surface (data); \
                if (argc > 1) { \
                        name (argv[0]->arg1type, argv[1]->arg2type); \
                } \