- gain_t current_value;
- std::pair<Masters::iterator,bool> res;
-
- {
- Glib::Threads::RWLock::WriterLock lm (master_lock);
- current_value = get_value_locked ();
-
- /* ratio will be recomputed below */
-
- res = _masters.insert (make_pair<uint32_t,MasterRecord> (vca->number(), MasterRecord (vca->gain_control(), 0.0)));
-
- if (res.second) {
-
- recompute_masters_ratios (current_value);
-
- /* 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));
-
- /* Store the connection inside the MasterRecord, so that when we destroy it, the connection is destroyed
- and we no longer hear about changes to the VCA.
- */
-
- vca->gain_control()->Changed.connect_same_thread (res.first->second.connection, 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 current_value;
- Masters::size_type erased = 0;
-
- {
- Glib::Threads::RWLock::WriterLock lm (master_lock);
- current_value = get_value_locked ();
- erased = _masters.erase (vca->number());
- if (erased) {
- recompute_masters_ratios (current_value);
- }
- }
-
- if (erased) {
- VCAStatusChange (); /* EMIT SIGNAL */
- }
-}