From f485cfa324717f57b9f820f43f1b53307b96a8b9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 25 Apr 2016 13:41:38 -0400 Subject: [PATCH] rearrange inheritance so that Automatable IS-A Slavable Share assign code via Slavable; add visibility tags to Slavable+SlavableAutomationControl --- libs/ardour/ardour/automatable.h | 21 ++++--- libs/ardour/ardour/route.h | 4 -- libs/ardour/ardour/slavable.h | 15 +++-- .../ardour/slavable_automation_control.h | 3 +- libs/ardour/ardour/vca.h | 5 -- libs/ardour/route.cc | 27 --------- libs/ardour/slavable.cc | 57 +++++++++++++++++++ libs/ardour/vca.cc | 55 ------------------ 8 files changed, 83 insertions(+), 104 deletions(-) diff --git a/libs/ardour/ardour/automatable.h b/libs/ardour/ardour/automatable.h index c9e14cfae5..5f9f7d2b91 100644 --- a/libs/ardour/ardour/automatable.h +++ b/libs/ardour/ardour/automatable.h @@ -23,10 +23,15 @@ #include #include #include + #include + #include "pbd/signals.h" + #include "evoral/ControlSet.hpp" + #include "ardour/libardour_visibility.h" +#include "ardour/slavable.h" #include "ardour/types.h" class XMLNode; @@ -39,7 +44,7 @@ class AutomationControl; /* The inherited ControlSet is virtual because AutomatableSequence inherits * from this AND EvoralSequence, which is also a ControlSet */ -class LIBARDOUR_API Automatable : virtual public Evoral::ControlSet +class LIBARDOUR_API Automatable : virtual public Evoral::ControlSet, public Slavable { public: Automatable(Session&); @@ -47,17 +52,17 @@ public: virtual ~Automatable(); - boost::shared_ptr - control_factory(const Evoral::Parameter& id); + boost::shared_ptr control_factory(const Evoral::Parameter& id); - boost::shared_ptr - automation_control (const Evoral::Parameter& id, bool create_if_missing=false); + boost::shared_ptr automation_control (const Evoral::Parameter& id) { + return automation_control (id, false); + } - boost::shared_ptr - automation_control (const Evoral::Parameter& id) const; + boost::shared_ptr automation_control (const Evoral::Parameter& id, bool create_if_missing); + boost::shared_ptr automation_control (const Evoral::Parameter& id) const; virtual void add_control(boost::shared_ptr); - virtual bool find_next_event(double start, double end, Evoral::ControlEvent& ev, bool only_active = true) const; + virtual bool find_next_event (double start, double end, Evoral::ControlEvent& ev, bool only_active = true) const; void clear_controls (); virtual void transport_located (framepos_t now); diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 52be8c94b4..2e2c1ccf72 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -91,7 +91,6 @@ class LIBARDOUR_API Route : public GraphNode, public Monitorable, public Automatable, public RouteGroupMember, - public Slavable, public boost::enable_shared_from_this { public: @@ -612,9 +611,6 @@ public: virtual void set_block_size (pframes_t nframes); protected: - int assign_controls (boost::shared_ptr); - int unassign_controls (boost::shared_ptr); - virtual framecnt_t check_initial_delay (framecnt_t nframes, framepos_t&) { return nframes; } void fill_buffers_with_input (BufferSet& bufs, boost::shared_ptr io, pframes_t nframes); diff --git a/libs/ardour/ardour/slavable.h b/libs/ardour/ardour/slavable.h index b0ef33e1b4..147f90fda0 100644 --- a/libs/ardour/ardour/slavable.h +++ b/libs/ardour/ardour/slavable.h @@ -26,7 +26,11 @@ #include -#include +#include "pbd/signals.h" + +#include "evoral/Parameter.hpp" + +#include "ardour/libardour_visibility.h" class XMLNode; @@ -34,8 +38,9 @@ namespace ARDOUR { class VCA; class VCAManager; +class AutomationControl; -class Slavable +class LIBARDOUR_API Slavable { public: Slavable (); @@ -47,14 +52,16 @@ class Slavable void assign (boost::shared_ptr); void unassign (boost::shared_ptr); + virtual boost::shared_ptr automation_control (const Evoral::Parameter& id) = 0; + static std::string xml_node_name; /* signal sent VCAManager once assignment is possible */ static PBD::Signal1 Assign; protected: - virtual int assign_controls (boost::shared_ptr) = 0; - virtual int unassign_controls (boost::shared_ptr) = 0; + virtual int assign_controls (boost::shared_ptr); + virtual int unassign_controls (boost::shared_ptr); private: mutable Glib::Threads::RWLock master_lock; diff --git a/libs/ardour/ardour/slavable_automation_control.h b/libs/ardour/ardour/slavable_automation_control.h index 98745e025d..45b555595f 100644 --- a/libs/ardour/ardour/slavable_automation_control.h +++ b/libs/ardour/ardour/slavable_automation_control.h @@ -21,10 +21,11 @@ #define __ardour_slavable_automation_control_h__ #include "ardour/automation_control.h" +#include "ardour/libardour_visibility.h" namespace ARDOUR { -class SlavableAutomationControl : public AutomationControl +class LIBARDOUR_API SlavableAutomationControl : public AutomationControl { public: SlavableAutomationControl(ARDOUR::Session&, diff --git a/libs/ardour/ardour/vca.h b/libs/ardour/ardour/vca.h index 926cd500e0..4225605f9b 100644 --- a/libs/ardour/ardour/vca.h +++ b/libs/ardour/ardour/vca.h @@ -46,7 +46,6 @@ class LIBARDOUR_API VCA : public Stripable, public Soloable, public Muteable, public Automatable, - public Slavable, public Recordable, public Monitorable, public boost::enable_shared_from_this { @@ -132,10 +131,6 @@ class LIBARDOUR_API VCA : public Stripable, virtual std::string send_name (uint32_t n) const { return std::string(); } virtual boost::shared_ptr master_send_enable_controllable () const { return boost::shared_ptr(); } - protected: - int assign_controls (boost::shared_ptr); - int unassign_controls (boost::shared_ptr); - private: uint32_t _number; diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index c36e501aef..a449540c6f 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -5444,33 +5444,6 @@ Route::slaved_to (boost::shared_ptr vca) const return _gain_control->slaved_to (vca->gain_control()); } -int -Route::assign_controls (boost::shared_ptr vca) -{ - _gain_control->add_master (vca->gain_control()); - _solo_control->add_master (vca->solo_control()); - _mute_control->add_master (vca->mute_control()); - - return 0; -} - -int -Route::unassign_controls (boost::shared_ptr vca) -{ - if (!vca) { - /* unassign from all */ - _gain_control->clear_masters (); - _solo_control->clear_masters (); - _mute_control->clear_masters (); - } else { - _gain_control->remove_master (vca->gain_control()); - _solo_control->remove_master (vca->solo_control()); - _mute_control->remove_master (vca->mute_control()); - } - - return 0; -} - bool Route::muted_by_others_soloing () const { diff --git a/libs/ardour/slavable.cc b/libs/ardour/slavable.cc index 7a7b8e2919..4a759f5fef 100644 --- a/libs/ardour/slavable.cc +++ b/libs/ardour/slavable.cc @@ -26,6 +26,7 @@ #include "pbd/xml++.h" #include "ardour/slavable.h" +#include "ardour/slavable_automation_control.h" #include "ardour/vca.h" #include "ardour/vca_manager.h" @@ -127,3 +128,59 @@ Slavable::unassign (boost::shared_ptr v) (void) unassign_controls (v); _masters.erase (v->number()); } + +int +Slavable::assign_controls (boost::shared_ptr vca) +{ + boost::shared_ptr slave; + boost::shared_ptr master; + AutomationType types[] = { + GainAutomation, + SoloAutomation, + MuteAutomation, + RecEnableAutomation, + MonitoringAutomation, + NullAutomation + }; + + for (uint32_t n = 0; types[n] != NullAutomation; ++n) { + + slave = boost::dynamic_pointer_cast (automation_control (types[n])); + master = vca->automation_control (types[n]); + + if (slave && master) { + slave->add_master (master); + } + } + + return 0; +} + +int +Slavable::unassign_controls (boost::shared_ptr vca) +{ + boost::shared_ptr slave; + boost::shared_ptr master; + AutomationType types[] = { + GainAutomation, + SoloAutomation, + MuteAutomation, + RecEnableAutomation, + MonitoringAutomation, + NullAutomation + }; + + for (uint32_t n = 0; types[n] != NullAutomation; ++n) { + + slave = boost::dynamic_pointer_cast (automation_control (types[n])); + if (!vca) { + /* unassign from all */ + slave->clear_masters (); + } else { + slave->remove_master (master); + } + } + + return 0; +} + diff --git a/libs/ardour/vca.cc b/libs/ardour/vca.cc index 2d1fbdec8f..8227bf8749 100644 --- a/libs/ardour/vca.cc +++ b/libs/ardour/vca.cc @@ -161,61 +161,6 @@ VCA::clear_all_solo_state () _solo_control->clear_all_solo_state (); } -int -VCA::assign_controls (boost::shared_ptr vca) -{ - boost::shared_ptr slave; - boost::shared_ptr master; - AutomationType types[] = { - GainAutomation, - SoloAutomation, - MuteAutomation, - RecEnableAutomation, - MonitoringAutomation, - NullAutomation - }; - - for (uint32_t n = 0; types[n] != NullAutomation; ++n) { - - slave = boost::dynamic_pointer_cast (automation_control (types[n])); - master = vca->automation_control (types[n]); - - if (slave && master) { - slave->add_master (master); - } - } - - return 0; -} - -int -VCA::unassign_controls (boost::shared_ptr vca) -{ - boost::shared_ptr slave; - boost::shared_ptr master; - AutomationType types[] = { - GainAutomation, - SoloAutomation, - MuteAutomation, - RecEnableAutomation, - MonitoringAutomation, - NullAutomation - }; - - for (uint32_t n = 0; types[n] != NullAutomation; ++n) { - - slave = boost::dynamic_pointer_cast (automation_control (types[n])); - if (!vca) { - /* unassign from all */ - slave->clear_masters (); - } else { - slave->remove_master (master); - } - } - - return 0; -} - MonitorState VCA::monitoring_state () const { -- 2.30.2