From 04a7c950ab232ebafc5d7ecc3f82564be3ac5550 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Fri, 9 Mar 2007 11:24:14 +0000 Subject: [PATCH] poll for automation git-svn-id: svn://localhost/ardour2/trunk@1566 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/surfaces/mackie/TODO | 3 +- .../mackie/mackie_control_protocol.cc | 28 +++++++++++++++++-- .../surfaces/mackie/mackie_control_protocol.h | 3 ++ .../mackie/mackie_control_protocol_poll.cc | 8 ++++++ libs/surfaces/mackie/route_signal.cc | 4 +-- libs/surfaces/mackie/route_signal.h | 1 + 6 files changed, 41 insertions(+), 6 deletions(-) diff --git a/libs/surfaces/mackie/TODO b/libs/surfaces/mackie/TODO index 39a75dc8e2..88b1788668 100644 --- a/libs/surfaces/mackie/TODO +++ b/libs/surfaces/mackie/TODO @@ -3,8 +3,9 @@ if the handler is not called in the "correct thread", it will use a pseudo-RT-safe-enough technique to get the correct thread to recall "handler" later on, and return. * automation feedback not working. gtk2_ardour seems to poll. +* optimise strip_from_route. Can just pass in strips. * jog with transport rolling doesn't work properly. My use of ScrollTimeline also doesn't work. -* finish button mapping +* finish button mapping. Click on/off. start/end locate. punch in/out * discuss button mapping for Ardour * concurrency for bank switching? And make sure "old" events aren't sent to "new" faders * TODOs in code diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 3f54da88a5..53466004e4 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -105,7 +105,18 @@ MackieControlProtocol::MackieControlProtocol (Session& session) MackieControlProtocol::~MackieControlProtocol() { cout << "~MackieControlProtocol::MackieControlProtocol" << endl; - close(); + try + { + close(); + } + catch ( exception & e ) + { + cout << "~MackieControlProtocol caught " << e.what() << endl; + } + catch ( ... ) + { + cout << "~MackieControlProtocol caught unknown" << endl; + } } Mackie::Surface & MackieControlProtocol::surface() @@ -983,7 +994,7 @@ void MackieControlProtocol::notify_gain_changed( ARDOUR::Route * route, MackieP Fader & fader = strip_from_route( route ).gain(); if ( !fader.touch() ) { - port->write( builder.build_fader( fader, gain_to_slider_position( route->gain() ) ) ); + port->write( builder.build_fader( fader, gain_to_slider_position( route->effective_gain() ) ) ); } } catch( exception & e ) @@ -1027,6 +1038,19 @@ void MackieControlProtocol::notify_panner_changed( ARDOUR::Route * route, Mackie } } +void MackieControlProtocol::poll_automation() +{ + for( RouteSignals::iterator it = route_signals.begin(); it != route_signals.end(); ++it ) + { + // update strip from route + ARDOUR::AutoState state = (*it)->route().gain_automation_state(); + if ( state == Touch || state == Play ) + { + (*it)->notify_all(); + } + } +} + ///////////////////////////////////// // Transport Buttons ///////////////////////////////////// diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index 9f78c83cba..4ba9443b96 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -233,6 +233,9 @@ class MackieControlProtocol void read_ports(); void add_port( MIDI::Port &, int number ); + + /// read automation data from the currently active routes and send to surface + void poll_automation(); /** used by the notify_XXX methods to find diff --git a/libs/surfaces/mackie/mackie_control_protocol_poll.cc b/libs/surfaces/mackie/mackie_control_protocol_poll.cc index 859b67c17d..8ef0431ed8 100644 --- a/libs/surfaces/mackie/mackie_control_protocol_poll.cc +++ b/libs/surfaces/mackie/mackie_control_protocol_poll.cc @@ -71,6 +71,9 @@ void * MackieControlProtocol::monitor_work() } // provide a cancellation point pthread_testcancel(); + + // poll for automation data from the routes + poll_automation(); } // these never get called @@ -86,6 +89,7 @@ void MackieControlProtocol::update_ports() // create pollfd structures if necessary if ( _ports_changed ) { + cout << "MackieControlProtocol::update_ports changed 1" << endl; 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 @@ -178,10 +182,14 @@ void MackieControlProtocol::handle_port_changed( SurfacePort * port, bool active } else { +cout << __FILE__ << ':' << __LINE__ << endl; _ports_changed = true; +cout << __FILE__ << ':' << __LINE__ << endl; // port added update_ports(); +cout << __FILE__ << ':' << __LINE__ << endl; update_surface(); +cout << __FILE__ << ':' << __LINE__ << endl; // TODO update bank size diff --git a/libs/surfaces/mackie/route_signal.cc b/libs/surfaces/mackie/route_signal.cc index a5b98dc709..8c62548714 100644 --- a/libs/surfaces/mackie/route_signal.cc +++ b/libs/surfaces/mackie/route_signal.cc @@ -76,8 +76,6 @@ void RouteSignal::disconnect() void RouteSignal::notify_all() { - void * src = &_route; - if ( _strip.has_solo() ) _mcp.notify_solo_changed( &_route, &_port ); @@ -87,7 +85,7 @@ void RouteSignal::notify_all() if ( _strip.has_gain() ) _mcp.notify_gain_changed( &_route, &_port ); - _mcp.notify_name_changed( src, &_route, &_port ); + _mcp.notify_name_changed( &_route, &_route, &_port ); if ( _strip.has_vpot() ) _mcp.notify_panner_changed( &_route, &_port ); diff --git a/libs/surfaces/mackie/route_signal.h b/libs/surfaces/mackie/route_signal.h index f8742a5875..0cc5d36898 100644 --- a/libs/surfaces/mackie/route_signal.h +++ b/libs/surfaces/mackie/route_signal.h @@ -60,6 +60,7 @@ public: const ARDOUR::Route & route() const { return _route; } Strip & strip() { return _strip; } + Port & port() { return _port; } private: ARDOUR::Route & _route;