diff options
author | John Anderson <ardour@semiosix.com> | 2007-09-09 17:15:09 +0000 |
---|---|---|
committer | John Anderson <ardour@semiosix.com> | 2007-09-09 17:15:09 +0000 |
commit | f1c4219fa92119ab1b909f5a9d6c0bab4cce314a (patch) | |
tree | 12280b08207019e13fd92ad2d8e88657c6b09e50 /libs/surfaces | |
parent | bf27a5c45ccf8a697534fe95a09184e3e48f5e17 (diff) |
don't write automation bytes unless something has actually changed in the automated gain/pan control
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2440 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/surfaces')
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.cc | 26 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol_poll.cc | 15 | ||||
-rw-r--r-- | libs/surfaces/mackie/route_signal.h | 13 |
3 files changed, 47 insertions, 7 deletions
diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 11561d61ed..46986bbc1e 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -663,6 +663,12 @@ void MackieControlProtocol::initialize_surface() void MackieControlProtocol::close() { + // stop polling, and wait for it... + // must be before other shutdown otherwise polling loop + // calls methods on objects that are deleted + _polling = false; + pthread_join( thread, 0 ); + // TODO disconnect port active/inactive signals // Or at least put a lock here @@ -720,10 +726,6 @@ void MackieControlProtocol::close() _surface = 0; } - // stop polling, and wait for it... - _polling = false; - pthread_join( thread, 0 ); - // shut down MackiePorts for( MackiePorts::iterator it = _ports.begin(); it != _ports.end(); ++it ) { @@ -959,7 +961,13 @@ void MackieControlProtocol::notify_gain_changed( RouteSignal * route_signal ) Fader & fader = route_signal->strip().gain(); if ( !fader.in_use() ) { - route_signal->port().write( builder.build_fader( fader, route_signal->route().gain_control().get_value() ) ); + float gain_value = route_signal->route().gain_control().get_value(); + // check that something has actually changed + if ( gain_value != route_signal->last_gain_written() ) + { + route_signal->port().write( builder.build_fader( fader, gain_value ) ); + route_signal->last_gain_written( gain_value ); + } } } catch( exception & e ) @@ -1008,7 +1016,13 @@ void MackieControlProtocol::notify_panner_changed( RouteSignal * route_signal ) { float pos; route_signal->route().panner()[0]->get_effective_position( pos ); - route_signal->port().write( builder.build_led_ring( pot, ControlState( on, pos ), MackieMidiBuilder::midi_pot_mode_dot ) ); + + // check that something has actually changed + if ( pos != route_signal->last_pan_written() ) + { + route_signal->port().write( builder.build_led_ring( pot, ControlState( on, pos ), MackieMidiBuilder::midi_pot_mode_dot ) ); + route_signal->last_pan_written( pos ); + } } else { diff --git a/libs/surfaces/mackie/mackie_control_protocol_poll.cc b/libs/surfaces/mackie/mackie_control_protocol_poll.cc index 0efca85bd8..81342dc9b5 100644 --- a/libs/surfaces/mackie/mackie_control_protocol_poll.cc +++ b/libs/surfaces/mackie/mackie_control_protocol_poll.cc @@ -81,11 +81,17 @@ void * MackieControlProtocol::monitor_work() void MackieControlProtocol::update_ports() { +#ifdef DEBUG + cout << "MackieControlProtocol::update_ports" << endl; +#endif if ( _ports_changed ) { Glib::Mutex::Lock ul( update_mutex ); // yes, this is a double-test locking paradigm, or whatever it's called // because we don't *always* need to acquire the lock for the first test +#ifdef DEBUG + cout << "MackieControlProtocol::update_ports lock acquired" << endl; +#endif if ( _ports_changed ) { // create new pollfd structures @@ -105,8 +111,14 @@ void MackieControlProtocol::update_ports() } _ports_changed = false; } +#ifdef DEBUG + cout << "MackieControlProtocol::update_ports signal" << endl; +#endif update_cond.signal(); } +#ifdef DEBUG + cout << "MackieControlProtocol::update_ports finish" << endl; +#endif } void MackieControlProtocol::read_ports() @@ -207,4 +219,7 @@ void MackieControlProtocol::handle_port_init( Mackie::SurfacePort * sport ) #endif _ports_changed = true; update_ports(); +#ifdef DEBUG + cout << "MackieControlProtocol::handle_port_init finish" << endl; +#endif } diff --git a/libs/surfaces/mackie/route_signal.h b/libs/surfaces/mackie/route_signal.h index 4a706b9d8d..7f8a9f6875 100644 --- a/libs/surfaces/mackie/route_signal.h +++ b/libs/surfaces/mackie/route_signal.h @@ -44,7 +44,7 @@ class RouteSignal { public: RouteSignal( ARDOUR::Route & route, MackieControlProtocol & mcp, Strip & strip, MackiePort & port ) - : _route( route ), _mcp( mcp ), _strip( strip ), _port( port ) + : _route( route ), _mcp( mcp ), _strip( strip ), _port( port ), _last_gain_written(0.0), _last_pan_written(0.0) { connect(); } @@ -64,6 +64,12 @@ public: Strip & strip() { return _strip; } MackiePort & port() { return _port; } + float last_gain_written() const { return _last_gain_written; } + void last_gain_written( float other ) { _last_gain_written = other; } + + float last_pan_written() const { return _last_pan_written; } + void last_pan_written( float other ) { _last_pan_written = other; } + private: ARDOUR::Route & _route; MackieControlProtocol & _mcp; @@ -72,6 +78,11 @@ private: typedef std::vector<sigc::connection> Connections; Connections _connections; + + // Last written values for the gain and pan, to avoid overloading + // the midi connection to the surface + float _last_gain_written; + float _last_pan_written; }; } |