Mackie control: non-existent controls zero pot ring fix.
[ardour.git] / libs / ardour / session_rtevents.cc
index ca1ee319c7d93e32c7497c2a52dbf84547977148..2b24b59970175c4e581a3c38edf3ce85d1ae69ec 100644 (file)
@@ -42,7 +42,7 @@ 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()) {
+               if (!(*i)->is_auditioner()) {
                        boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*i);
                        if (t) {
                                t->set_monitoring (mc);
@@ -53,6 +53,24 @@ Session::rt_set_monitoring (boost::shared_ptr<RouteList> rl, MonitorChoice mc, b
        set_dirty();
 }
 
+void
+Session::clear_all_solo_state (boost::shared_ptr<RouteList> rl)
+{
+       queue_event (get_rt_event (rl, false, rt_cleanup, false, &Session::rt_clear_all_solo_state));
+}
+
+void
+Session::rt_clear_all_solo_state (boost::shared_ptr<RouteList> rl, bool /* yn */, bool /* group_override */)
+{
+       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
+               if ((*i)->is_auditioner()) {
+                       continue;
+               }
+               (*i)->clear_all_solo_state();
+       }
+       set_dirty();
+}
+
 void
 Session::set_solo (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
 {
@@ -60,15 +78,19 @@ Session::set_solo (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeve
 }
 
 void
-Session::rt_set_solo (boost::shared_ptr<RouteList> rl, bool yn, bool /* group_override */)
+Session::rt_set_solo (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_solo (yn, this);
+               if (!(*i)->is_auditioner()) {
+                       (*i)->set_solo (yn, this, group_override);
                }
        }
 
        set_dirty();
+       /* XXX boost::shared_ptr<RouteList>  goes out of scope here and is likley free()ed in RT context
+        * because boost's shared_ptr does reference counting and free/delete in the dtor.
+        * (this also applies to other rt_  methods here)
+        */
 }
 
 void
@@ -92,7 +114,7 @@ Session::rt_set_just_one_solo (boost::shared_ptr<RouteList> just_one, bool yn, b
        boost::shared_ptr<Route> r = just_one->front();
 
        for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-               if (!(*i)->is_hidden() && r != *i) {
+               if (!(*i)->is_auditioner() && r != *i) {
                        (*i)->set_solo (!yn, (*i)->route_group());
                }
        }
@@ -109,11 +131,11 @@ Session::set_listen (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTe
 }
 
 void
-Session::rt_set_listen (boost::shared_ptr<RouteList> rl, bool yn, bool /*group_override*/ )
+Session::rt_set_listen (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_listen (yn, this);
+               if (!(*i)->is_auditioner()) {
+                       (*i)->set_listen (yn, this, group_override);
                }
        }
 
@@ -123,6 +145,12 @@ Session::rt_set_listen (boost::shared_ptr<RouteList> rl, bool yn, bool /*group_o
 void
 Session::set_mute (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
 {
+       /* Set superficial value of mute controls for automation. */
+       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
+               boost::shared_ptr<Route::MuteControllable> mc = (*i)->mute_control();
+               mc->set_superficial_value(yn);
+       }
+
        queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_mute));
 }
 
@@ -130,7 +158,7 @@ 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()) {
+               if (!(*i)->is_monitor() && !(*i)->is_auditioner()) {
                        (*i)->set_mute (yn, this);
                }
        }
@@ -148,7 +176,7 @@ 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()) {
+               if (!(*i)->is_master() && !(*i)->is_monitor() && !(*i)->is_auditioner()) {
                        (*i)->set_solo_isolated (yn, this);
                }
        }
@@ -163,6 +191,25 @@ Session::set_record_enabled (boost::shared_ptr<RouteList> rl, bool yn, SessionEv
                return;
        }
 
+       /* do the non-RT part of rec-enabling first - the RT part will be done
+        * on the next process cycle. This does mean that theoretically we are
+        * doing things provisionally on the assumption that the rec-enable
+        * change will work, but this had better be a solid assumption for
+        * other reasons.
+        */
+
+       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
+               if ((*i)->is_auditioner() || (*i)->record_safe ()) {
+                       continue;
+               }
+
+               boost::shared_ptr<Track> t;
+
+               if ((t = boost::dynamic_pointer_cast<Track>(*i)) != 0) {
+                       t->prep_record_enabled (yn, (group_override ? (void*) t->route_group() : (void *) this));
+               }
+       }
+
        queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_record_enabled));
 }
 
@@ -170,7 +217,7 @@ void
 Session::rt_set_record_enabled (boost::shared_ptr<RouteList> rl, bool yn, bool group_override)
 {
        for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-               if ((*i)->is_hidden()) {
+               if ((*i)->is_auditioner() || (*i)->record_safe ()) {
                        continue;
                }
 
@@ -184,6 +231,32 @@ Session::rt_set_record_enabled (boost::shared_ptr<RouteList> rl, bool yn, bool g
        set_dirty ();
 }
 
+
+void
+Session::set_record_safe (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override)
+{
+       set_record_enabled (rl, false, after, group_override);
+       queue_event (get_rt_event (rl, yn, after, group_override, &Session::rt_set_record_safe));
+}
+
+void
+Session::rt_set_record_safe (boost::shared_ptr<RouteList> rl, bool yn, bool group_override)
+{
+       for (RouteList::iterator i = rl->begin (); i != rl->end (); ++i) {
+               if ((*i)->is_auditioner ()) { // REQUIRES REVIEW Can audiotioner be in Record Safe mode?
+                       continue;
+               }
+
+               boost::shared_ptr<Track> t;
+
+               if ((t = boost::dynamic_pointer_cast<Track>(*i)) != 0) {
+                       t->set_record_safe (yn, (group_override ? (void*) t->route_group () : (void *) this));
+               }
+       }
+
+       set_dirty ();
+}
+
 void
 Session::process_rtop (SessionEvent* ev)
 {