+
+void
+SoloControl::master_changed (bool /*from self*/, GroupControlDisposition, boost::shared_ptr<AutomationControl> m)
+{
+ bool send_signal = false;
+
+ _transition_into_solo = 0;
+
+ /* Notice that we call get_boolean_masters() BEFORE we call
+ * update_boolean_masters_records(), in order to know what
+ * our master state was BEFORE it gets changed.
+ */
+
+
+ if (m->get_value()) {
+ /* this master is now enabled */
+ if (!self_soloed() && get_boolean_masters() == 0) {
+ /* not self-soloed, wasn't soloed by masters before */
+ send_signal = true;
+ _transition_into_solo = 1;
+ }
+ } else {
+ if (!self_soloed() && get_boolean_masters() == 1) {
+ /* not self-soloed, soloed by just 1 master before */
+ _transition_into_solo = -1;
+ send_signal = true;
+ }
+ }
+
+ update_boolean_masters_records (m);
+
+ if (send_signal) {
+ set_mute_master_solo ();
+ Changed (false, Controllable::UseGroup);
+ }
+
+}
+
+void
+SoloControl::post_add_master (boost::shared_ptr<AutomationControl> m)
+{
+ if (m->get_value()) {
+
+ /* boolean masters records are not updated until AFTER
+ * ::post_add_master() is called, so we can use them to check
+ * on whether any master was already enabled before the new
+ * one was added.
+ */
+
+ if (!self_soloed() && !get_boolean_masters()) {
+ _transition_into_solo = 1;
+ Changed (false, Controllable::NoGroup);
+ }
+ }
+}
+
+void
+SoloControl::pre_remove_master (boost::shared_ptr<AutomationControl> m)
+{
+ if (!m) {
+ /* null control ptr means we're removing all masters. Nothing
+ * to do. Changed will be emitted in
+ * SlavableAutomationControl::clear_masters()
+ */
+ return;
+ }
+
+ if (m->get_value()) {
+ if (!self_soloed() && (get_boolean_masters() == 1)) {
+ /* we're not self-soloed, this master is, and we're
+ removing
+ it. SlavableAutomationControl::remove_master() will
+ ensure that we reset our own value after actually
+ removing the master, so that our state does not
+ change (this is a precondition of the
+ SlavableAutomationControl API). This will emit
+ Changed(), and we need to make sure that any
+ listener knows that there has been no transition.
+ */
+ _transition_into_solo = 0;
+ } else {
+ _transition_into_solo = 1;
+ }
+ } else {
+ _transition_into_solo = 0;
+ }
+}
+
+bool
+SoloControl::can_solo () const
+{
+ return _soloable.can_solo ();
+}