-gain_t
-GainControl::get_master_gain () const
-{
- Glib::Threads::RWLock::ReaderLock sm (master_lock, Glib::Threads::TRY_LOCK);
-
- if (sm.locked()) {
- return get_master_gain_locked ();
- }
-
- return 1.0;
-}
-
-gain_t
-GainControl::get_master_gain_locked () const
-{
- /* Master lock MUST be held (read or write lock is acceptable) */
-
- gain_t g = 1.0;
-
- for (Masters::const_iterator mr = _masters.begin(); mr != _masters.end(); ++mr) {
- /* get current master value, scale by our current ratio with that master */
- g *= mr->second.master()->get_value () * mr->second.ratio();
- }
-
- return g;
-}
-
-void
-GainControl::add_master (boost::shared_ptr<VCA> vca)
-{
- 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->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->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);
- }
-}
-