- gain_t old_master_val;
- std::pair<Masters::iterator,bool> res;
-
- {
- Glib::Threads::RWLock::WriterLock lm (master_lock);
- old_master_val = get_master_gain_locked ();
-
- /* ratio will be recomputed below */
-
- MasterRecord mr (vca->control(), vca->number(), 0.0);
-
- res = _masters.insert (mr);
- recompute_masters_ratios (old_master_val);
-
- /* note that we bind @param m as a weak_ptr<GainControl>, thus
- avoiding holding a reference to the control in the binding
- itself.
- */
-
- vca->DropReferences.connect_same_thread (masters_connections, boost::bind (&GainControl::master_going_away, this, vca));
- vca->control()->Changed.connect_same_thread (masters_connections, boost::bind (&PBD::Signal0<void>::operator(), &Changed));
- }
-
- if (res.second) {
- VCAStatusChange (); /* EMIT SIGNAL */
- }
-}
-
-void
-GainControl::master_going_away (boost::weak_ptr<VCA> wv)
-{
- boost::shared_ptr<VCA> v = wv.lock();
- if (v) {
- remove_master (v);
- }
-}
-
-void
-GainControl::remove_master (boost::shared_ptr<VCA> vca)
-{
- gain_t old_master_val;
- Masters::size_type erased = 0;
-
- {
- Glib::Threads::RWLock::WriterLock lm (master_lock);
- old_master_val = get_master_gain_locked ();
- MasterRecord mr (vca->control(), vca->number(), 0.0);
- erased = _masters.erase (mr);
- if (erased) {
- recompute_masters_ratios (old_master_val);
- }
- }
-
- if (erased) {
- VCAStatusChange (); /* EMIT SIGNAL */
- }
-}
-
-void
-GainControl::clear_masters ()
-{
- bool had_masters = false;