when clearing route solo state, do the required update
[ardour.git] / libs / ardour / session_rtevents.cc
1 /*
2     Copyright (C) 1999-2009 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18
19 #include <boost/bind.hpp>
20
21 #include "pbd/error.h"
22 #include "pbd/compose.h"
23
24 #include "ardour/monitor_control.h"
25 #include "ardour/route.h"
26 #include "ardour/session.h"
27 #include "ardour/track.h"
28 #include "ardour/vca_manager.h"
29
30 #include "pbd/i18n.h"
31
32 using namespace std;
33 using namespace PBD;
34 using namespace ARDOUR;
35 using namespace Glib;
36
37 void
38 Session::set_controls (boost::shared_ptr<ControlList> cl, double val, Controllable::GroupControlDisposition gcd)
39 {
40         if (cl->empty()) {
41                 return;
42         }
43
44         for (ControlList::iterator ci = cl->begin(); ci != cl->end(); ++ci) {
45                 /* as of july 2017 this is a no-op for everything except record enable */
46                 (*ci)->do_pre_realtime_queue_stuff (val);
47         }
48
49         queue_event (get_rt_event (cl, val, gcd));
50 }
51
52 void
53 Session::set_control (boost::shared_ptr<AutomationControl> ac, double val, Controllable::GroupControlDisposition gcd)
54 {
55         if (!ac) {
56                 return;
57         }
58
59         boost::shared_ptr<ControlList> cl (new ControlList);
60         cl->push_back (ac);
61         set_controls (cl, val, gcd);
62 }
63
64 void
65 Session::rt_set_controls (boost::shared_ptr<ControlList> cl, double val, Controllable::GroupControlDisposition gcd)
66 {
67         /* Note that we require that all controls in the ControlList are of the
68            same type.
69         */
70         if (cl->empty()) {
71                 return;
72         }
73
74         for (ControlList::iterator c = cl->begin(); c != cl->end(); ++c) {
75                 (*c)->set_value (val, gcd);
76         }
77
78         /* some controls need global work to take place after they are set. Do
79          * that here.
80          */
81
82         switch (cl->front()->parameter().type()) {
83         case SoloAutomation:
84                 update_route_solo_state ();
85                 break;
86         default:
87                 break;
88         }
89 }
90
91 void
92 Session::clear_all_solo_state (boost::shared_ptr<RouteList> rl)
93 {
94         queue_event (get_rt_event (rl, false, rt_cleanup, Controllable::NoGroup, &Session::rt_clear_all_solo_state));
95 }
96
97 void
98 Session::rt_clear_all_solo_state (boost::shared_ptr<RouteList> rl, bool /* yn */, Controllable::GroupControlDisposition /* group_override */)
99 {
100         for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
101                 if ((*i)->is_auditioner()) {
102                         continue;
103                 }
104                 (*i)->clear_all_solo_state();
105         }
106
107         _vca_manager->clear_all_solo_state ();
108
109         update_route_solo_state ();
110 }
111
112 void
113 Session::process_rtop (SessionEvent* ev)
114 {
115         ev->rt_slot ();
116
117         if (ev->event_loop) {
118                 ev->event_loop->call_slot (MISSING_INVALIDATOR, boost::bind (ev->rt_return, ev));
119         } else {
120                 warning << string_compose ("programming error: %1", X_("Session RT event queued from thread without a UI - cleanup in RT thread!")) << endmsg;
121                 ev->rt_return (ev);
122         }
123 }