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::get_rt_event (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override,
37 void (Session::*method) (boost::shared_ptr<RouteList>, bool, bool))
39 SessionEvent* ev = new SessionEvent (SessionEvent::RealTimeOperation, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0);
40 ev->rt_slot = boost::bind (method, this, rl, yn, group_override);
41 ev->rt_return = after;
42 ev->ui = UICallback::get_ui_for_thread ();
48 Session::set_solo (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
50 queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_solo));
54 Session::rt_set_solo (boost::shared_ptr<RouteList> rl, bool yn, bool /* group_override */)
56 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
57 if (!(*i)->is_hidden()) {
58 (*i)->set_solo (yn, this);
66 Session::set_just_one_solo (boost::shared_ptr<Route> r, bool yn, SessionEvent::RTeventCallback after)
68 /* its a bit silly to have to do this, but it keeps the API for this public method sane (we're
69 only going to solo one route) and keeps our ability to use get_rt_event() for the internal
73 boost::shared_ptr<RouteList> rl (new RouteList);
76 queue_event (get_rt_event (rl, yn, after, false, &Session::rt_set_just_one_solo));
80 Session::rt_set_just_one_solo (boost::shared_ptr<RouteList> just_one, bool yn, bool /*ignored*/)
82 boost::shared_ptr<RouteList> rl = routes.reader ();
83 boost::shared_ptr<Route> r = just_one->front();
85 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
86 if (!(*i)->is_hidden() && r != *i) {
87 (*i)->set_solo (!yn, (*i)->route_group());
91 r->set_solo (yn, r->route_group());
97 Session::set_listen (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
99 queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_listen));
103 Session::rt_set_listen (boost::shared_ptr<RouteList> rl, bool yn, bool /*group_override*/ )
105 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
106 if (!(*i)->is_hidden()) {
107 (*i)->set_listen (yn, this);
115 Session::set_mute (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
117 queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_mute));
121 Session::rt_set_mute (boost::shared_ptr<RouteList> rl, bool yn, bool /*group_override*/)
123 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
124 if (!(*i)->is_hidden()) {
125 (*i)->set_mute (yn, this);
133 Session::set_record_enable (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
139 queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_record_enable));
143 Session::rt_set_record_enable (boost::shared_ptr<RouteList> rl, bool yn, bool group_override)
145 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
146 if ((*i)->is_hidden()) {
150 boost::shared_ptr<Track> t;
152 if ((t = boost::dynamic_pointer_cast<Track>(*i)) != 0) {
153 t->set_record_enable (yn, (group_override ? (void*) t->route_group() : (void *) this));
161 Session::process_rtop (SessionEvent* ev)
166 ev->ui->call_slot (boost::bind (ev->rt_return, ev));
168 warning << string_compose ("programming error: %1", X_("Session RT event queued from thread without a UI - cleanup in RT thread!")) << endmsg;