#include "ardour/vca.h"
#include "ardour/vca_manager.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace PBD;
using namespace ARDOUR;
return 0;
}
+
int
Slavable::do_assign (VCAManager* manager)
{
void
Slavable::assign (boost::shared_ptr<VCA> v)
{
+ assert (v);
Glib::Threads::RWLock::WriterLock lm (master_lock);
if (assign_controls (v) == 0) {
_masters.insert (v->number());
}
+
+ /* Do NOT use ::unassign() because it will store a
+ * boost::shared_ptr<VCA> in the functor, leaving a dangling ref to the
+ * VCA.
+ */
+
+
+ v->Drop.connect_same_thread (unassign_connections, boost::bind (&Slavable::weak_unassign, this, boost::weak_ptr<VCA>(v)));
+ v->DropReferences.connect_same_thread (unassign_connections, boost::bind (&Slavable::weak_unassign, this, boost::weak_ptr<VCA>(v)));
+}
+
+void
+Slavable::weak_unassign (boost::weak_ptr<VCA> v)
+{
+ boost::shared_ptr<VCA> sv (v.lock());
+ if (sv) {
+ unassign (sv);
+ }
}
void
}
}
+/* Gain, solo & mute are currently the only controls that are
+ * automatically slaved to the master's own equivalent controls.
+ */
+
+static AutomationType auto_slave_types[] = {
+ GainAutomation,
+ SoloAutomation,
+ MuteAutomation,
+ NullAutomation
+};
+
int
Slavable::assign_controls (boost::shared_ptr<VCA> vca)
{
boost::shared_ptr<SlavableAutomationControl> slave;
boost::shared_ptr<AutomationControl> master;
- AutomationType types[] = {
- GainAutomation,
- SoloAutomation,
- MuteAutomation,
- RecEnableAutomation,
- MonitoringAutomation,
- NullAutomation
- };
- for (uint32_t n = 0; types[n] != NullAutomation; ++n) {
+ for (uint32_t n = 0; auto_slave_types[n] != NullAutomation; ++n) {
- slave = boost::dynamic_pointer_cast<SlavableAutomationControl> (automation_control (types[n]));
- master = vca->automation_control (types[n]);
+ slave = boost::dynamic_pointer_cast<SlavableAutomationControl> (automation_control (auto_slave_types[n]));
+ master = vca->automation_control (auto_slave_types[n]);
if (slave && master) {
slave->add_master (master);
{
boost::shared_ptr<SlavableAutomationControl> slave;
boost::shared_ptr<AutomationControl> master;
- AutomationType types[] = {
- GainAutomation,
- SoloAutomation,
- MuteAutomation,
- RecEnableAutomation,
- MonitoringAutomation,
- NullAutomation
- };
- for (uint32_t n = 0; types[n] != NullAutomation; ++n) {
+ for (uint32_t n = 0; auto_slave_types[n] != NullAutomation; ++n) {
- slave = boost::dynamic_pointer_cast<SlavableAutomationControl> (automation_control (types[n]));
+ slave = boost::dynamic_pointer_cast<SlavableAutomationControl> (automation_control (auto_slave_types[n]));
if (!vca) {
/* unassign from all */
slave->clear_masters ();
}
} else {
- master = vca->automation_control (types[n]);
+ master = vca->automation_control (auto_slave_types[n]);
if (slave && master) {
slave->remove_master (master);
}