From 9b3aefec1b0da4b838ecc90df7080be539b2edba Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 25 Jan 2012 21:19:48 +0000 Subject: [PATCH] an improvement to the previous patch to catch up with solo state after a disconnect, but still not really done because it doesn't get triggered for both ends of a disconnect git-svn-id: svn://localhost/ardour2/branches/3.0@11353 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/route.h | 2 +- libs/ardour/ardour/session.h | 4 +-- libs/ardour/route.cc | 46 ++++++++++++++++++++++++++++----- libs/ardour/session_rtevents.cc | 8 +++--- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 5c77627877..a0f9573562 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -148,7 +148,7 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember, void set_solo (bool yn, void *src); bool soloed () const { return self_soloed () || soloed_by_others (); } - void cancel_solo_after_disconnect (); + void cancel_solo_after_disconnect (bool upstream); bool soloed_by_others () const { return _soloed_by_others_upstream||_soloed_by_others_downstream; } bool soloed_by_others_upstream () const { return _soloed_by_others_upstream; } diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 885b5aae24..ee9c457ca4 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -618,7 +618,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void set_solo (boost::shared_ptr, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false); void set_just_one_solo (boost::shared_ptr, bool, SessionEvent::RTeventCallback after = rt_cleanup); - void cancel_solo_after_disconnect (boost::shared_ptr, SessionEvent::RTeventCallback after = rt_cleanup); + void cancel_solo_after_disconnect (boost::shared_ptr, bool upstream, SessionEvent::RTeventCallback after = rt_cleanup); void set_mute (boost::shared_ptr, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false); void set_listen (boost::shared_ptr, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false); void set_record_enabled (boost::shared_ptr, bool, SessionEvent::RTeventCallback after = rt_cleanup, bool group_override = false); @@ -1478,7 +1478,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi return ev; } - void rt_cancel_solo_after_disconnect (boost::shared_ptr, bool /* ignored */, bool /* ignored*/ ); + void rt_cancel_solo_after_disconnect (boost::shared_ptr, bool upstream, bool /* ignored*/ ); void rt_set_solo (boost::shared_ptr, bool yn, bool group_override); void rt_set_just_one_solo (boost::shared_ptr, bool yn, bool /* ignored*/ ); void rt_set_mute (boost::shared_ptr, bool yn, bool group_override); diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 9233a77b14..645addd7ab 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -145,6 +145,8 @@ Route::init () _input->changed.connect_same_thread (*this, boost::bind (&Route::input_change_handler, this, _1, _2)); _input->PortCountChanging.connect_same_thread (*this, boost::bind (&Route::input_port_count_changing, this, _1)); + _output->changed.connect_same_thread (*this, boost::bind (&Route::output_change_handler, this, _1, _2)); + /* add amp processor */ _amp.reset (new Amp (_session)); @@ -2820,32 +2822,64 @@ Route::nonrealtime_handle_transport_stopped (bool /*abort_ignored*/, bool did_lo _roll_delay = _initial_delay; } -/** Called with the process lock held if change contains ConfigurationChanged */ void Route::input_change_handler (IOChange change, void * /*src*/) { bool need_to_queue_solo_change = true; if ((change.type & IOChange::ConfigurationChanged)) { + /* This is called with the process lock held if change + contains ConfigurationChanged + */ need_to_queue_solo_change = false; configure_processors (0); _phase_invert.resize (_input->n_ports().n_audio ()); io_changed (); /* EMIT SIGNAL */ } - if (_fed_by.size() == 0 && _soloed_by_others_upstream) { + cerr << _name << ": input change, connected ? " << _input->connected() << endl; + + if (!_input->connected() && _soloed_by_others_upstream) { if (need_to_queue_solo_change) { - _session.cancel_solo_after_disconnect (shared_from_this()); + _session.cancel_solo_after_disconnect (shared_from_this(), true); } else { - cancel_solo_after_disconnect (); + cancel_solo_after_disconnect (true); } } } void -Route::cancel_solo_after_disconnect () +Route::output_change_handler (IOChange change, void * /*src*/) { - _soloed_by_others_upstream = 0; + bool need_to_queue_solo_change = true; + + if ((change.type & IOChange::ConfigurationChanged)) { + /* This is called with the process lock held if change + contains ConfigurationChanged + */ + need_to_queue_solo_change = false; + } + + cerr << _name << ": output change, connected ? " << _output->connected() << endl; + + if (!_output->connected() && _soloed_by_others_downstream) { + if (need_to_queue_solo_change) { + _session.cancel_solo_after_disconnect (shared_from_this(), false); + } else { + cancel_solo_after_disconnect (false); + } + } +} + +void +Route::cancel_solo_after_disconnect (bool upstream) +{ + cerr << _name << " CSAD upstream ? " << upstream << endl; + if (upstream) { + _soloed_by_others_upstream = 0; + } else { + _soloed_by_others_downstream = 0; + } set_mute_master_solo (); solo_changed (false, this); } diff --git a/libs/ardour/session_rtevents.cc b/libs/ardour/session_rtevents.cc index 43d291c458..b5328a1548 100644 --- a/libs/ardour/session_rtevents.cc +++ b/libs/ardour/session_rtevents.cc @@ -72,20 +72,20 @@ Session::rt_set_solo (boost::shared_ptr rl, bool yn, bool /* group_ov } void -Session::cancel_solo_after_disconnect (boost::shared_ptr r, SessionEvent::RTeventCallback after) +Session::cancel_solo_after_disconnect (boost::shared_ptr r, bool upstream, SessionEvent::RTeventCallback after) { boost::shared_ptr rl (new RouteList); rl->push_back (r); - queue_event (get_rt_event (rl, false, after, false, &Session::rt_cancel_solo_after_disconnect)); + queue_event (get_rt_event (rl, upstream, after, false, &Session::rt_cancel_solo_after_disconnect)); } void -Session::rt_cancel_solo_after_disconnect (boost::shared_ptr rl, bool /*yn */, bool /* group_override */) +Session::rt_cancel_solo_after_disconnect (boost::shared_ptr rl, bool upstream, bool /* group_override */) { for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { if (!(*i)->is_hidden()) { - (*i)->cancel_solo_after_disconnect (); + (*i)->cancel_solo_after_disconnect (upstream); } } /* no need to call set-dirty - the disconnect will already have done that */