add basic support for HUI heartbeat, only used for HUI devices
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 3 Oct 2015 16:03:07 +0000 (12:03 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 3 Oct 2015 17:13:58 +0000 (13:13 -0400)
libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/mackie_control_protocol.h
libs/surfaces/mackie/surface.cc
libs/surfaces/mackie/surface.h

index 1b665287546e27fa496c9a85442b5efdf4f8df31..f4ad499313b02e15a17016673f7a44b4f26cbe30 100644 (file)
@@ -428,6 +428,13 @@ MackieControlProtocol::set_active (bool yn)
                redisplay_connection = redisplay_timeout->connect (sigc::mem_fun (*this, &MackieControlProtocol::redisplay));
                redisplay_timeout->attach (main_loop()->get_context());
 
+               if (_device_info.device_type() == DeviceInfo::HUI) {
+                       Glib::RefPtr<Glib::TimeoutSource> hui_timeout = Glib::TimeoutSource::create (1000); // milliseconds
+                       hui_connection = hui_timeout->connect (sigc::mem_fun (*this, &MackieControlProtocol::hui_heartbeat));
+                       hui_timeout->attach (main_loop()->get_context());
+               }
+               
+               
        } else {
 
                BaseUI::quit ();
@@ -442,6 +449,18 @@ MackieControlProtocol::set_active (bool yn)
        return 0;
 }
 
+bool
+MackieControlProtocol::hui_heartbeat ()
+{
+       Glib::Threads::Mutex::Lock lm (surfaces_lock);
+
+       for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
+               (*s)->hui_heartbeat ();
+       }
+
+       return true;
+}
+       
 bool
 MackieControlProtocol::periodic ()
 {
index 2008d9c88795ee6a54e1450b913fe7a428545ce0..1908070a9e95d658d641d534b0b1d682090cf8df 100644 (file)
@@ -282,6 +282,7 @@ class MackieControlProtocol
        Mackie::DeviceProfile    _device_profile;
        sigc::connection          periodic_connection;
        sigc::connection          redisplay_connection;
+       sigc::connection          hui_connection;
        uint32_t                 _current_initial_bank;
        PBD::ScopedConnectionList audio_engine_connections;
        PBD::ScopedConnectionList session_connections;
@@ -324,6 +325,7 @@ class MackieControlProtocol
        int create_surfaces ();
        bool periodic();
        bool redisplay();
+       bool hui_heartbeat ();
        void build_gui ();
        bool midi_input_handler (Glib::IOCondition ioc, MIDI::Port* port);
        void clear_ports ();
index 3770a335e7473624c511b1658d2b72bfc781f17c..a4b1feccad54a90c0f7b9ee9f415918286dd4d04 100644 (file)
@@ -440,8 +440,12 @@ Surface::handle_midi_note_on_message (MIDI::Parser &, MIDI::EventTwoBytes* ev)
        
        if (_mcp.device_info().no_handshake()) {
                turn_it_on ();
-       }
+       } 
 
+       if (_mcp.device_info().device_type() == DeviceInfo::HUI && ev->note_number == 0 && ev->velocity == 127) {
+               turn_it_on ();
+       }
+       
        /* fader touch sense is given by "buttons" 0xe..0xe7 and 0xe8 for the
         * master. 
         */
@@ -1087,3 +1091,14 @@ Surface::set_touch_sensitivity (int sensitivity)
                }
        }
 }
+
+void
+Surface::hui_heartbeat ()
+{
+       if (!_port) {
+               return;
+       }
+
+       MidiByteArray msg (3, MIDI::on, 0x0, 0x0);
+       _port->write (msg);
+}
index dc3b51566e9667c121c147b899c56e00041bec05..a3d874a89a749c2946567a48edcf7bf5368edf92 100644 (file)
@@ -87,7 +87,8 @@ public:
 
        void periodic (uint64_t now_usecs);
        void redisplay ();
-
+       void hui_heartbeat ();
+       
        void handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t, uint32_t channel_id);
        void handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes*);
        void handle_midi_note_on_message (MIDI::Parser&, MIDI::EventTwoBytes*);