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