MCP: stop using signals to handle parsed control events; add debugging
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 8 Apr 2012 14:51:14 +0000 (14:51 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 8 Apr 2012 14:51:14 +0000 (14:51 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11826 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/surfaces/mackie/dummy_port.h
libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/mackie_control_protocol.h
libs/surfaces/mackie/mackie_port.cc
libs/surfaces/mackie/mackie_port.h
libs/surfaces/mackie/surface_port.h

index 4ed0a3043b43f8a87108af9afb1b9e359275d7c5..056e30fa0d46117be880708553aced5f0f0870cf 100644 (file)
@@ -53,6 +53,7 @@ public:
 
        virtual const MidiByteArray & sysex_hdr() const;
        virtual int strips() const;
+
 };     
 
 }
index f5d7c9b8f07f94397800be63a55c0180103dd2a7..8ad9db142e3e22358b2785edcb26414d5d717745 100644 (file)
@@ -657,12 +657,6 @@ MackieControlProtocol::initialize_surface()
        }
 
        _surface->init();
-
-       // Connect events. Must be after route table otherwise there will be trouble
-
-       for (MackiePorts::iterator it = _ports.begin(); it != _ports.end(); ++it) {
-               (*it)->control_event.connect_same_thread (port_connections, boost::bind (&MackieControlProtocol::handle_control_event, this, _1, _2, _3));
-       }
 }
 
 void 
@@ -767,15 +761,26 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr
 {
        // find the route for the control, if there is one
        boost::shared_ptr<Route> route;
+
        if (control.group().is_strip()) {
                if (control.group().is_master()) {
+                       DEBUG_TRACE (DEBUG::MackieControl, "master strip control event\n");
                        route = master_route();
                } else {
                        uint32_t index = control.ordinal() - 1 + (port.number() * port.strips());
-                       if (index < route_table.size())
+                       DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip control event, index = %1, rt size = %2\n",
+                                                                          index, route_table.size()));
+                       if (index < route_table.size()) {
                                route = route_table[index];
-                       else
+                               if (route) {
+                                       DEBUG_TRACE (DEBUG::MackieControl, string_compose ("modifying %1\n", route->name()));
+                               } else {
+                                       DEBUG_TRACE (DEBUG::MackieControl, "no route found!\n");
+                               }
+                       } else {
                                cerr << "Warning: index is " << index << " which is not in the route table, size: " << route_table.size() << endl;
+                               DEBUG_TRACE (DEBUG::MackieControl, "illegal route index found!\n");
+                       }
                }
        }
 
@@ -789,6 +794,8 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr
                        // at which point the fader should just reset itself
                        if (route != 0)
                        {
+                               DEBUG_TRACE (DEBUG::MackieControl, string_compose ("fader to %1\n", state.pos));
+
                                route->gain_control()->set_value (slider_position_to_gain (state.pos));
 
                                if (ARDOUR::Config->get_mackie_emulation() == "bcf") {
@@ -806,6 +813,7 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr
                case Control::type_button:
                        if (control.group().is_strip()) {
                                // strips
+                               DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip button %1\n", control.id()));
                                if (route != 0) {
                                        handle_strip_button (port, control, state.button_state, route);
                                } else {
@@ -815,11 +823,13 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr
                                }
                        } else if (control.group().is_master()) {
                                // master fader touch
+                               DEBUG_TRACE (DEBUG::MackieControl, string_compose ("master strip button %1\n", control.id()));
                                if (route != 0) {
                                        handle_strip_button (port, control, state.button_state, route);
                                }
                        } else {
                                // handle all non-strip buttons
+                               DEBUG_TRACE (DEBUG::MackieControl, string_compose ("global button %1\n", control.id()));
                                surface().handle_button (*this, state.button_state, dynamic_cast<Button&> (control));
                        }
                        break;
@@ -827,6 +837,7 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr
                // pot (jog wheel, external control)
                case Control::type_pot:
                        if (control.group().is_strip()) {
+                               DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip pot %1\n", control.id()));
                                if (route) {
                                         boost::shared_ptr<Panner> panner = route->panner_shell()->panner();
                                        // pan for mono input routes, or stereo linked panners
@@ -843,12 +854,12 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr
                                        // it's a pot for an umnapped route, so turn all the lights off
                                        port.write (builder.build_led_ring (dynamic_cast<Pot &> (control), off));
                                }
-                       }
-                       else
-                       {
+                       } else {
                                if (control.is_jog()) {
+                                       DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Jog wheel moved %1\n", state.ticks));
                                        _jog_wheel.jog_event (port, control, state);
                                } else {
+                                       DEBUG_TRACE (DEBUG::MackieControl, string_compose ("External controller moved %1\n", state.ticks));
                                        cout << "external controller" << state.ticks * state.sign << endl;
                                }
                        }
index 69b9d6a4aa6f45e4ea0eb490910fece7df7a6b62..b42dbae258bab1721eec83c35ef7ace764820ebd 100644 (file)
@@ -101,26 +101,18 @@ class MackieControlProtocol
        void tear_down_gui ();
        
        // control events
-       void handle_control_event(Mackie::SurfacePort & port, Mackie::Control & control, const Mackie::ControlState & state);
+       void handle_control_event (Mackie::SurfacePort & port, Mackie::Control & control, const Mackie::ControlState & state);
 
        // strip/route related stuff
   public:      
-       /// Signal handler for Route::solo
-       void notify_solo_changed(Mackie::RouteSignal *);
-       /// Signal handler for Route::mute
-       void notify_mute_changed(Mackie::RouteSignal *);
-       /// Signal handler for Route::record_enable_changed
-       void notify_record_enable_changed(Mackie::RouteSignal *);
-       /// Signal handler for Route::gain_changed (from IO)
-       void notify_gain_changed(Mackie::RouteSignal *, bool force_update = true);
-       /// Signal handler for Route::name_change
-       void notify_property_changed(const PBD::PropertyChange&, Mackie::RouteSignal *);
-       /// Signal handler from Panner::Change
-       void notify_panner_changed(Mackie::RouteSignal *, bool force_update = true);
-       /// Signal handler for new routes added
-       void notify_route_added(ARDOUR::RouteList &);
-       /// Signal handler for Route::active_changed
-       void notify_active_changed(Mackie::RouteSignal *);
+       void notify_solo_changed (Mackie::RouteSignal *);
+       void notify_mute_changed (Mackie::RouteSignal *);
+       void notify_record_enable_changed (Mackie::RouteSignal *);
+       void notify_gain_changed (Mackie::RouteSignal *, bool force_update = true);
+       void notify_property_changed (const PBD::PropertyChange&, Mackie::RouteSignal *);
+       void notify_panner_changed (Mackie::RouteSignal *, bool force_update = true);
+       void notify_route_added (ARDOUR::RouteList &);
+       void notify_active_changed (Mackie::RouteSignal *);
  
        void notify_remote_id_changed();
 
@@ -128,8 +120,6 @@ class MackieControlProtocol
        /// remote id changed.
        void refresh_current_bank();
 
-       // global buttons (ie button not part of strips)
-
   public:
        // button-related signals
        void notify_record_state_changed();
index d751437cb879811d14941218825b8c9f46afb121..772b668a757dec26471aef72ccd54379c878f7ed 100644 (file)
@@ -338,7 +338,7 @@ MackiePort::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb,
                // in_use is set by the MackieControlProtocol::handle_strip_button
                
                // relies on implicit ControlState constructor
-               control_event (*this, *control, float (midi_pos) / float(0x3ff));
+               _mcp.handle_control_event (*this, *control, float (midi_pos) / float(0x3ff));
        }
 }
 
@@ -385,7 +385,6 @@ MackiePort::handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes*
                        control->set_in_use (true);
                        add_in_use_timeout (*control, control);
                        
-                       // emit the control event
                        control_event (*this, *control, state);
                }
                break;
@@ -395,3 +394,8 @@ MackiePort::handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes*
        }
 }
 
+void
+MackiePort::control_event (SurfacePort& sp, Control& c, const ControlState& cs)
+{
+       _mcp.handle_control_event (sp, c, cs);
+}
index dbd5553a632b7711fc960f410768e4f9116cf18f..086043a1f5552f5c7354d18045a4073a143680bd 100644 (file)
@@ -104,6 +104,8 @@ protected:
        */
        void probe_emulation( const MidiByteArray & bytes );
 
+       void control_event (SurfacePort &, Control &, const ControlState &);
+
 private:
        MackieControlProtocol & _mcp;
        port_type_t _port_type;
index 91ca21c0b00f7a612598dc75419cac2e9b67d648..350ee561f6b753c1c901cb25aa7b850f1f4263e1 100644 (file)
@@ -65,9 +65,6 @@ public:
        MIDI::Port & output_port() { return *_output_port; }
        const MIDI::Port & output_port() const { return *_output_port; }
        
-       // all control notofications are sent from here
-       PBD::Signal3<void,SurfacePort &, Control &, const ControlState &> control_event;
-       
        // emitted just before the port goes into initialisation
        // where it tries to establish that its device is connected
        PBD::Signal0<void> init_event;
@@ -92,6 +89,8 @@ public:
 protected:
        /// Only for use by DummyPort
        SurfacePort();
+
+       virtual void control_event (SurfacePort &, Control &, const ControlState &) {}
        
 private:
        bool control_in_use_timeout (Control *, Control *);