update surface when remote ids change

git-svn-id: svn://localhost/ardour2/trunk@1479 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
John Anderson 2007-02-20 10:42:50 +00:00
parent b69b53eef0
commit 780e9d7ecb
4 changed files with 46 additions and 8 deletions

View File

@ -1,21 +1,22 @@
* how long can UI signal callbacks take to execute? What happens if they block?
where ENSURE_CORRECT_THREAD is a macro that is modelled on ENSURE_GUI_THREAD
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
* finish button mapping
* discuss button mapping for Ardour
* concurrency for bank switching? And make sure "old" events aren't sent to "new" faders
* concurrency in write( bytes ). Queueing?
* TODOs in code
* handle remote_control_id changed signal from Route.
* handle removal of route. Need another session signal?
* removal of a route results in a strip that isn't dead, but doesn't have any effect on the session
* bulk remote id changes cause too many surface updates
* use i18n. see string_compose
* MackieControlProtocol in namespace Mackie?
* Generic surface code to common location
* power-cycling of surface. fd_midiport doesn't close.
* remove couts
* jog with transport rolling doesn't work properly. My use of ScrollTimeline also doesn't work.
* docs in manual
* docs in manual, including button assignment diagram
Later
-----

View File

@ -260,7 +260,7 @@ void MackieControlProtocol::switch_banks( int initial )
uint32_t end_pos = min( route_table.size(), sorted.size() );
Sorted::iterator it = sorted.begin() + _current_initial_bank;
Sorted::iterator end = sorted.begin() + _current_initial_bank + end_pos;
cout << "switch to " << _current_initial_bank << ", " << end_pos << endl;
//cout << "switch to " << _current_initial_bank << ", " << end_pos << endl;
// link routes to strips
uint32_t i = 0;
@ -268,7 +268,7 @@ void MackieControlProtocol::switch_banks( int initial )
{
boost::shared_ptr<Route> route = *it;
Strip & strip = *surface().strips[i];
cout << "remote id " << route->remote_control_id() << " connecting " << route->name() << " to " << strip.name() << " with port " << port_for_id(i) << endl;
//cout << "remote id " << route->remote_control_id() << " connecting " << route->name() << " to " << strip.name() << " with port " << port_for_id(i) << endl;
route_table[i] = route;
RouteSignal * rs = new RouteSignal( *route, *this, strip, port_for_id(i) );
route_signals.push_back( rs );
@ -521,6 +521,14 @@ void MackieControlProtocol::connect_session_signals()
connections_back = Config->ParameterChanged.connect( ( mem_fun (*this, &MackieControlProtocol::notify_parameter_changed) ) );
// receive rude solo changed
connections_back = session->SoloActive.connect( ( mem_fun (*this, &MackieControlProtocol::notify_solo_active_changed) ) );
// make sure remote id changed signals reach here
// see also notify_route_added
Sorted sorted = get_sorted_routes();
for ( Sorted::iterator it = sorted.begin(); it != sorted.end(); ++it )
{
(*it)->RemoteControlIDChanged.connect( ( mem_fun (*this, &MackieControlProtocol::notify_remote_id_changed) ) );
}
}
void MackieControlProtocol::add_port( MIDI::Port & midi_port, int number )
@ -1128,6 +1136,13 @@ void MackieControlProtocol::notify_route_added( ARDOUR::Session::RouteList & rl
refresh_current_bank();
}
// otherwise route added, but current bank needs no updating
// make sure remote id changes in the new route are handled
typedef ARDOUR::Session::RouteList ARS;
for ( ARS::iterator it = rl.begin(); it != rl.end(); ++it )
{
(*it)->RemoteControlIDChanged.connect( ( mem_fun (*this, &MackieControlProtocol::notify_remote_id_changed) ) );
}
}
void MackieControlProtocol::notify_solo_active_changed( bool active )
@ -1136,6 +1151,24 @@ void MackieControlProtocol::notify_solo_active_changed( bool active )
mcu_port().write( builder.build_led( *rude_solo, active ? flashing : off ) );
}
void MackieControlProtocol::notify_remote_id_changed()
{
Sorted sorted = get_sorted_routes();
// if a remote id has been moved off the end, we need to shift
// the current bank backwards.
if ( sorted.size() - _current_initial_bank < route_signals.size() )
{
// but don't shift backwards past the zeroth channel
switch_banks( max( (unsigned int)0, sorted.size() - route_signals.size() ) );
}
// Otherwise just refresh the current bank
else
{
refresh_current_bank();
}
}
///////////////////////////////////////////
// Transport signals
///////////////////////////////////////////

View File

@ -101,7 +101,9 @@ class MackieControlProtocol
/// Signal handler for new routes added
void notify_route_added( ARDOUR::Session::RouteList & );
/// rebuild the current bank. Called on route added/removed and
void notify_remote_id_changed();
/// rebuild the current bank. Called on route added/removed and
/// remote id changed.
void refresh_current_bank();

View File

@ -65,6 +65,8 @@ void * MackieControlProtocol::monitor_work()
try { read_ports(); }
catch ( exception & e ) {
cout << "MackieControlProtocol::poll_ports caught exception: " << e.what() << endl;
_ports_changed = true;
update_ports();
}
}
// provide a cancellation point
@ -129,7 +131,7 @@ void MackieControlProtocol::read_ports()
bool MackieControlProtocol::poll_ports()
{
int timeout = 10; // milliseconds
int no_ports_sleep = 10; // milliseconds
int no_ports_sleep = 1000; // milliseconds
Glib::Mutex::Lock lock( update_mutex );
// if there are no ports