- 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;
- gain_t new_master_val;
- set<boost::shared_ptr<GainControl> >::size_type erased = 0;
-
- {
- Glib::Threads::Mutex::Lock lm (master_lock);
- old_master_val = get_master_gain_locked ();
- erased = _masters.erase (vca->control());
- _masters_numbers.erase (vca->number());
- new_master_val = get_master_gain_locked ();
- }
-
- if (old_master_val != new_master_val) {
- Changed(); /* EMIT SIGNAL */
- }
-
- if (erased) {
- VCAStatusChange (); /* EMIT SIGNAL */
- }
-}
-
-void
-GainControl::clear_masters ()
-{
- gain_t old_master_val;
- gain_t new_master_val;
- bool had_masters = false;
-
- {
- Glib::Threads::Mutex::Lock lm (master_lock);
- old_master_val = get_master_gain_locked ();
- if (!_masters.empty()) {
- had_masters = true;
- }
- _masters.clear ();
- _masters_numbers.clear ();
- new_master_val = get_master_gain_locked ();
- }
-
- if (old_master_val != new_master_val) {
- Changed(); /* EMIT SIGNAL */
- }
-
- if (had_masters) {
- VCAStatusChange (); /* EMIT SIGNAL */
- }
-}
-
-bool
-GainControl::slaved_to (boost::shared_ptr<VCA> vca) const
-{
- Glib::Threads::Mutex::Lock lm (master_lock);
- return find (_masters.begin(), _masters.end(), vca->control()) != _masters.end();
-}
-
-XMLNode&
-GainControl::get_state ()
-{
- XMLNode& node (AutomationControl::get_state());
-
- /* store VCA master IDs */
-
- string str;
-
- {
- Glib::Threads::Mutex::Lock lm (master_lock);
- for (set<uint32_t>::const_iterator m = _masters_numbers.begin(); m != _masters_numbers.end(); ++m) {
- if (!str.empty()) {
- str += ',';
- }
- str += PBD::to_string (*m, std::dec);
- }
- }
-
- if (!str.empty()) {
- node.add_property (X_("masters"), str);
- }
-
- return node;
-}
-
-int
-GainControl::set_state (XMLNode const& node, int version)
-{
- AutomationControl::set_state (node, version);
-
- XMLProperty const* prop = node.property (X_("masters"));
-
- /* XXXProblem here if we allow VCA's to be slaved to other VCA's .. we
- * have to load all VCAs first, then call ::set_state() so that
- * vca_by_number() will succeed.