Collect plugin runtime profile statistics.
[ardour.git] / libs / ardour / session_rtevents.cc
index 43d291c45870b239d51e513a2f43e71eb14a41b1..9e84d86a2392a5e52cc2e821351d3f0d43814b91 100644 (file)
 #include "pbd/error.h"
 #include "pbd/compose.h"
 
-#include "ardour/session.h"
+#include "ardour/monitor_control.h"
 #include "ardour/route.h"
+#include "ardour/session.h"
 #include "ardour/track.h"
+#include "ardour/vca_manager.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace PBD;
@@ -33,175 +35,78 @@ using namespace ARDOUR;
 using namespace Glib;
 
 void
-Session::set_monitoring (boost::shared_ptr<RouteList> rl, MonitorChoice mc, SessionEvent::RTeventCallback after, bool group_override)
-{
-       queue_event (get_rt_event (rl, mc, after, group_override, &Session::rt_set_monitoring));
-}
-
-void
-Session::rt_set_monitoring (boost::shared_ptr<RouteList> rl, MonitorChoice mc, bool /* group_override */)
-{
-       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-               if (!(*i)->is_hidden()) {
-                       boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*i);
-                       if (t) {
-                               t->set_monitoring (mc);
-                       }
-               }
-       }
-
-       set_dirty();
-}
-
-void
-Session::set_solo (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
-{
-       queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_solo));
-}
-
-void
-Session::rt_set_solo (boost::shared_ptr<RouteList> rl, bool yn, bool /* group_override */)
+Session::set_controls (boost::shared_ptr<ControlList> cl, double val, Controllable::GroupControlDisposition gcd)
 {
-       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-               if (!(*i)->is_hidden()) {
-                       (*i)->set_solo (yn, this);
-               }
+       if (cl->empty()) {
+               return;
        }
 
-       set_dirty();
-}
-
-void
-Session::cancel_solo_after_disconnect (boost::shared_ptr<Route> r, SessionEvent::RTeventCallback after)
-{
-       boost::shared_ptr<RouteList> rl (new RouteList);
-       rl->push_back (r);
-
-       queue_event (get_rt_event (rl, false, after, false, &Session::rt_cancel_solo_after_disconnect));
-}
-
-void
-Session::rt_cancel_solo_after_disconnect (boost::shared_ptr<RouteList> rl, bool /*yn */, bool /* group_override */)
-{
-       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-               if (!(*i)->is_hidden()) {
-                       (*i)->cancel_solo_after_disconnect ();
-               }
+       for (ControlList::iterator ci = cl->begin(); ci != cl->end(); ++ci) {
+               /* as of july 2017 this is a no-op for everything except record enable */
+               (*ci)->pre_realtime_queue_stuff (val, gcd);
        }
-       /* no need to call set-dirty - the disconnect will already have done that */
-}
 
-void
-Session::set_just_one_solo (boost::shared_ptr<Route> r, bool yn, SessionEvent::RTeventCallback after)
-{
-       /* its a bit silly to have to do this, but it keeps the API for this public method sane (we're
-          only going to solo one route) and keeps our ability to use get_rt_event() for the internal
-          private method.
-       */
-
-       boost::shared_ptr<RouteList> rl (new RouteList);
-       rl->push_back (r);
-
-       queue_event (get_rt_event (rl, yn, after, false, &Session::rt_set_just_one_solo));
+       queue_event (get_rt_event (cl, val, gcd));
 }
 
 void
-Session::rt_set_just_one_solo (boost::shared_ptr<RouteList> just_one, bool yn, bool /*ignored*/)
+Session::set_control (boost::shared_ptr<AutomationControl> ac, double val, Controllable::GroupControlDisposition gcd)
 {
-       boost::shared_ptr<RouteList> rl = routes.reader ();
-       boost::shared_ptr<Route> r = just_one->front();
-
-       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-               if (!(*i)->is_hidden() && r != *i) {
-                       (*i)->set_solo (!yn, (*i)->route_group());
-               }
+       if (!ac) {
+               return;
        }
 
-       r->set_solo (yn, r->route_group());
-
-       set_dirty();
-}
-
-void
-Session::set_listen (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
-{
-       queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_listen));
+       boost::shared_ptr<ControlList> cl (new ControlList);
+       cl->push_back (ac);
+       set_controls (cl, val, gcd);
 }
 
 void
-Session::rt_set_listen (boost::shared_ptr<RouteList> rl, bool yn, bool /*group_override*/ )
+Session::rt_set_controls (boost::shared_ptr<ControlList> cl, double val, Controllable::GroupControlDisposition gcd)
 {
-       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-               if (!(*i)->is_hidden()) {
-                       (*i)->set_listen (yn, this);
-               }
+       /* Note that we require that all controls in the ControlList are of the
+          same type.
+       */
+       if (cl->empty()) {
+               return;
        }
 
-       set_dirty();
-}
-
-void
-Session::set_mute (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
-{
-       queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_mute));
-}
-
-void
-Session::rt_set_mute (boost::shared_ptr<RouteList> rl, bool yn, bool /*group_override*/)
-{
-       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-               if (!(*i)->is_hidden()) {
-                       (*i)->set_mute (yn, this);
-               }
+       for (ControlList::iterator c = cl->begin(); c != cl->end(); ++c) {
+               (*c)->set_value (val, gcd);
        }
 
-       set_dirty();
-}
-
-void
-Session::set_solo_isolated (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
-{
-       queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_solo_isolated));
-}
+       /* some controls need global work to take place after they are set. Do
+        * that here.
+        */
 
-void
-Session::rt_set_solo_isolated (boost::shared_ptr<RouteList> rl, bool yn, bool /*group_override*/)
-{
-       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-               if (!(*i)->is_master() && !(*i)->is_monitor() && !(*i)->is_hidden()) {
-                       (*i)->set_solo_isolated (yn, this);
-               }
+       switch (cl->front()->parameter().type()) {
+       case SoloAutomation:
+               update_route_solo_state ();
+               break;
+       default:
+               break;
        }
-
-       set_dirty();
 }
 
 void
-Session::set_record_enabled (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
+Session::clear_all_solo_state (boost::shared_ptr<RouteList> rl)
 {
-       if (!writable()) {
-               return;
-       }
-
-       queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_record_enabled));
+       queue_event (get_rt_event (rl, false, rt_cleanup, Controllable::NoGroup, &Session::rt_clear_all_solo_state));
 }
 
 void
-Session::rt_set_record_enabled (boost::shared_ptr<RouteList> rl, bool yn, bool group_override)
+Session::rt_clear_all_solo_state (boost::shared_ptr<RouteList> rl, bool /* yn */, Controllable::GroupControlDisposition /* group_override */)
 {
        for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-               if ((*i)->is_hidden()) {
+               if ((*i)->is_auditioner()) {
                        continue;
                }
-
-               boost::shared_ptr<Track> t;
-
-               if ((t = boost::dynamic_pointer_cast<Track>(*i)) != 0) {
-                       t->set_record_enabled (yn, (group_override ? (void*) t->route_group() : (void *) this));
-               }
+               (*i)->clear_all_solo_state();
        }
 
-       set_dirty ();
+       _vca_manager->clear_all_solo_state ();
+
+       update_route_solo_state ();
 }
 
 void