2 Copyright (C) 1999-2009 Paul Davis
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.
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.
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.
19 #include <boost/bind.hpp>
21 #include "pbd/error.h"
22 #include "pbd/compose.h"
24 #include "ardour/session.h"
25 #include "ardour/route.h"
26 #include "ardour/track.h"
32 using namespace ARDOUR;
36 Session::set_monitoring (boost::shared_ptr<RouteList> rl, MonitorChoice mc,
37 SessionEvent::RTeventCallback after,
38 Controllable::GroupControlDisposition group_override)
40 queue_event (get_rt_event (rl, mc, after, group_override, &Session::rt_set_monitoring));
44 Session::rt_set_monitoring (boost::shared_ptr<RouteList> rl, MonitorChoice mc, Controllable::GroupControlDisposition group_override)
46 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
47 if (!(*i)->is_auditioner()) {
48 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*i);
50 t->set_monitoring (mc, group_override);
59 Session::clear_all_solo_state (boost::shared_ptr<RouteList> rl)
61 queue_event (get_rt_event (rl, false, rt_cleanup, Controllable::NoGroup, &Session::rt_clear_all_solo_state));
65 Session::rt_clear_all_solo_state (boost::shared_ptr<RouteList> rl, bool /* yn */, Controllable::GroupControlDisposition /* group_override */)
67 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
68 if ((*i)->is_auditioner()) {
71 (*i)->clear_all_solo_state();
77 Session::set_solo (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after,
78 Controllable::GroupControlDisposition group_override)
80 queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_solo));
84 Session::rt_set_solo (boost::shared_ptr<RouteList> rl, bool yn, Controllable::GroupControlDisposition group_override)
86 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
87 if (!(*i)->is_auditioner()) {
88 (*i)->set_solo (yn, group_override);
94 /* XXX boost::shared_ptr<RouteList> goes out of scope here and is likley free()ed in RT context
95 * because boost's shared_ptr does reference counting and free/delete in the dtor.
96 * (this also applies to other rt_ methods here)
101 Session::set_implicit_solo (boost::shared_ptr<RouteList> rl, int delta, bool upstream, SessionEvent::RTeventCallback after,
102 Controllable::GroupControlDisposition group_override)
104 queue_event (get_rt_event (rl, delta, upstream, after, group_override, &Session::rt_set_implicit_solo));
108 Session::rt_set_implicit_solo (boost::shared_ptr<RouteList> rl, int delta, bool upstream, PBD::Controllable::GroupControlDisposition)
110 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
111 if (!(*i)->is_auditioner()) {
113 (*i)->mod_solo_by_others_upstream (delta);
115 (*i)->mod_solo_by_others_downstream (delta);
122 /* XXX boost::shared_ptr<RouteList> goes out of scope here and is likley free()ed in RT context
123 * because boost's shared_ptr does reference counting and free/delete in the dtor.
124 * (this also applies to other rt_ methods here)
129 Session::set_just_one_solo (boost::shared_ptr<Route> r, bool yn, SessionEvent::RTeventCallback after)
131 /* its a bit silly to have to do this, but it keeps the API for this public method sane (we're
132 only going to solo one route) and keeps our ability to use get_rt_event() for the internal
136 boost::shared_ptr<RouteList> rl (new RouteList);
139 queue_event (get_rt_event (rl, yn, after, Controllable::NoGroup, &Session::rt_set_just_one_solo));
143 Session::rt_set_just_one_solo (boost::shared_ptr<RouteList> just_one, bool yn, Controllable::GroupControlDisposition /*ignored*/)
145 boost::shared_ptr<RouteList> rl = routes.reader ();
146 boost::shared_ptr<Route> r = just_one->front();
148 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
149 if (!(*i)->is_auditioner() && r != *i) {
150 (*i)->set_solo (!yn, Controllable::NoGroup);
154 r->set_solo (yn, Controllable::NoGroup);
160 Session::set_listen (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, Controllable::GroupControlDisposition group_override)
162 queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_listen));
166 Session::rt_set_listen (boost::shared_ptr<RouteList> rl, bool yn, Controllable::GroupControlDisposition group_override)
168 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
169 if (!(*i)->is_auditioner()) {
170 (*i)->set_listen (yn, group_override);
178 Session::set_mute (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, Controllable::GroupControlDisposition group_override)
180 /* Set superficial value of mute controls for automation. */
181 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
182 boost::shared_ptr<Route::MuteControllable> mc = boost::dynamic_pointer_cast<Route::MuteControllable> ((*i)->mute_control());
183 mc->set_superficial_value(yn);
186 queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_mute));
190 Session::rt_set_mute (boost::shared_ptr<RouteList> rl, bool yn, Controllable::GroupControlDisposition group_override)
192 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
193 if (!(*i)->is_monitor() && !(*i)->is_auditioner()) {
194 (*i)->set_mute (yn, group_override);
202 Session::set_solo_isolated (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, Controllable::GroupControlDisposition group_override)
204 queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_solo_isolated));
208 Session::rt_set_solo_isolated (boost::shared_ptr<RouteList> rl, bool yn, Controllable::GroupControlDisposition group_override)
210 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
211 if (!(*i)->is_master() && !(*i)->is_monitor() && !(*i)->is_auditioner()) {
212 (*i)->set_solo_isolated (yn, group_override);
220 Session::set_record_enabled (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, Controllable::GroupControlDisposition group_override)
226 /* do the non-RT part of rec-enabling first - the RT part will be done
227 * on the next process cycle. This does mean that theoretically we are
228 * doing things provisionally on the assumption that the rec-enable
229 * change will work, but this had better be a solid assumption for
233 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
234 if ((*i)->is_auditioner() || (*i)->record_safe ()) {
238 boost::shared_ptr<Track> t;
240 if ((t = boost::dynamic_pointer_cast<Track>(*i)) != 0) {
241 t->prep_record_enabled (yn, group_override);
245 queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_record_enabled));
249 Session::rt_set_record_enabled (boost::shared_ptr<RouteList> rl, bool yn, Controllable::GroupControlDisposition group_override)
251 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
252 if ((*i)->is_auditioner() || (*i)->record_safe ()) {
256 boost::shared_ptr<Track> t;
258 if ((t = boost::dynamic_pointer_cast<Track>(*i)) != 0) {
259 t->set_record_enabled (yn, group_override);
268 Session::set_record_safe (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, Controllable::GroupControlDisposition group_override)
270 set_record_enabled (rl, false, after, group_override);
271 queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_record_safe));
275 Session::rt_set_record_safe (boost::shared_ptr<RouteList> rl, bool yn, Controllable::GroupControlDisposition group_override)
277 for (RouteList::iterator i = rl->begin (); i != rl->end (); ++i) {
278 if ((*i)->is_auditioner ()) { // REQUIRES REVIEW Can audiotioner be in Record Safe mode?
282 boost::shared_ptr<Track> t;
284 if ((t = boost::dynamic_pointer_cast<Track>(*i)) != 0) {
285 t->set_record_safe (yn, group_override);
293 Session::process_rtop (SessionEvent* ev)
297 if (ev->event_loop) {
298 ev->event_loop->call_slot (MISSING_INVALIDATOR, boost::bind (ev->rt_return, ev));
300 warning << string_compose ("programming error: %1", X_("Session RT event queued from thread without a UI - cleanup in RT thread!")) << endmsg;