From c104c9d4726f3ba1ecd352d13b88a57f2f964510 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 12 Oct 2016 17:26:46 -0400 Subject: [PATCH] change return type of AutomationControl::actually_set_value() from void to bool, to indicate if value was changed. Don't call Session::set_dirty() when no change occurs --- libs/ardour/ardour/automation_control.h | 4 ++-- libs/ardour/ardour/midi_track.h | 2 +- libs/ardour/ardour/monitor_control.h | 2 +- libs/ardour/ardour/mute_control.h | 2 +- libs/ardour/ardour/pan_controllable.h | 2 +- libs/ardour/ardour/phase_control.h | 2 +- libs/ardour/ardour/plugin_insert.h | 4 ++-- libs/ardour/ardour/record_enable_control.h | 2 +- libs/ardour/ardour/record_safe_control.h | 2 +- libs/ardour/ardour/slavable_automation_control.h | 2 +- libs/ardour/ardour/solo_control.h | 2 +- libs/ardour/ardour/solo_isolate_control.h | 2 +- libs/ardour/ardour/solo_safe_control.h | 2 +- libs/ardour/automation_control.cc | 11 ++++++++--- libs/ardour/midi_track.cc | 6 +++--- libs/ardour/monitor_control.cc | 6 +++--- libs/ardour/mute_control.cc | 4 ++-- libs/ardour/pan_controllable.cc | 9 +++++---- libs/ardour/phase_control.cc | 8 ++++---- libs/ardour/plugin_insert.cc | 12 ++++++------ libs/ardour/record_enable_control.cc | 6 +++--- libs/ardour/record_safe_control.cc | 6 +++--- libs/ardour/slavable_automation_control.cc | 9 ++++++--- libs/ardour/solo_control.cc | 6 +++--- libs/ardour/solo_isolate_control.cc | 12 ++++++++---- libs/ardour/solo_safe_control.cc | 10 +++++++--- 26 files changed, 76 insertions(+), 59 deletions(-) diff --git a/libs/ardour/ardour/automation_control.h b/libs/ardour/ardour/automation_control.h index 158996133c..fddb0685ab 100644 --- a/libs/ardour/ardour/automation_control.h +++ b/libs/ardour/ardour/automation_control.h @@ -105,7 +105,7 @@ class LIBARDOUR_API AutomationControl * this is only used by automation playback. */ void set_value_unchecked (double val) { - actually_set_value (val, PBD::Controllable::NoGroup); + (void) actually_set_value (val, PBD::Controllable::NoGroup); } double lower() const { return _desc.lower; } @@ -134,7 +134,7 @@ class LIBARDOUR_API AutomationControl Controllable::Changed signal is emitted when necessary. */ - virtual void actually_set_value (double value, PBD::Controllable::GroupControlDisposition); + virtual bool actually_set_value (double value, PBD::Controllable::GroupControlDisposition); /* Session needs to call this method before it queues up the real change for execution in a realtime context. C++ access control sucks. diff --git a/libs/ardour/ardour/midi_track.h b/libs/ardour/ardour/midi_track.h index f756812e71..8a0f8c9f95 100644 --- a/libs/ardour/ardour/midi_track.h +++ b/libs/ardour/ardour/midi_track.h @@ -95,7 +95,7 @@ public: MidiTrack* _route; private: - void actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override); + bool actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override); }; virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState); diff --git a/libs/ardour/ardour/monitor_control.h b/libs/ardour/ardour/monitor_control.h index b18517255e..362bcfbc30 100644 --- a/libs/ardour/ardour/monitor_control.h +++ b/libs/ardour/ardour/monitor_control.h @@ -46,7 +46,7 @@ class LIBARDOUR_API MonitorControl : public SlavableAutomationControl XMLNode& get_state (); protected: - void actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); + bool actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); private: Monitorable& _monitorable; diff --git a/libs/ardour/ardour/mute_control.h b/libs/ardour/ardour/mute_control.h index 909f0cbf02..b324e32908 100644 --- a/libs/ardour/ardour/mute_control.h +++ b/libs/ardour/ardour/mute_control.h @@ -71,7 +71,7 @@ class LIBARDOUR_API MuteControl : public SlavableAutomationControl protected: void master_changed (bool, PBD::Controllable::GroupControlDisposition, boost::shared_ptr); - void actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); + bool actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); void pre_remove_master (boost::shared_ptr); void post_add_master (boost::shared_ptr); diff --git a/libs/ardour/ardour/pan_controllable.h b/libs/ardour/ardour/pan_controllable.h index 82aa60fe10..30130e35c8 100644 --- a/libs/ardour/ardour/pan_controllable.h +++ b/libs/ardour/ardour/pan_controllable.h @@ -51,7 +51,7 @@ class LIBARDOUR_API PanControllable : public AutomationControl private: Pannable* owner; - void actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); + bool actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); }; } // namespace diff --git a/libs/ardour/ardour/phase_control.h b/libs/ardour/ardour/phase_control.h index 0693c8ee50..489673db2d 100644 --- a/libs/ardour/ardour/phase_control.h +++ b/libs/ardour/ardour/phase_control.h @@ -60,7 +60,7 @@ class LIBARDOUR_API PhaseControl : public AutomationControl XMLNode& get_state (); protected: - void actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); + bool actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); private: boost::dynamic_bitset<> _phase_invert; diff --git a/libs/ardour/ardour/plugin_insert.h b/libs/ardour/ardour/plugin_insert.h index 474df73e41..d3936cc797 100644 --- a/libs/ardour/ardour/plugin_insert.h +++ b/libs/ardour/ardour/plugin_insert.h @@ -198,7 +198,7 @@ class LIBARDOUR_API PluginInsert : public Processor private: PluginInsert* _plugin; - void actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override); + bool actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override); }; /** A control that manipulates a plugin property (message). */ @@ -212,7 +212,7 @@ class LIBARDOUR_API PluginInsert : public Processor double get_value (void) const; XMLNode& get_state(); protected: - void actually_set_value (double value, PBD::Controllable::GroupControlDisposition); + bool actually_set_value (double value, PBD::Controllable::GroupControlDisposition); private: PluginInsert* _plugin; diff --git a/libs/ardour/ardour/record_enable_control.h b/libs/ardour/ardour/record_enable_control.h index c5cb65c597..a9c4750eea 100644 --- a/libs/ardour/ardour/record_enable_control.h +++ b/libs/ardour/ardour/record_enable_control.h @@ -49,7 +49,7 @@ class LIBARDOUR_API RecordEnableControl : public SlavableAutomationControl void set_value (double, PBD::Controllable::GroupControlDisposition); protected: - void actually_set_value (double val, Controllable::GroupControlDisposition gcd); + bool actually_set_value (double val, Controllable::GroupControlDisposition gcd); void do_pre_realtime_queue_stuff (double value); private: diff --git a/libs/ardour/ardour/record_safe_control.h b/libs/ardour/ardour/record_safe_control.h index ef062aa9f0..c7432cf3d4 100644 --- a/libs/ardour/ardour/record_safe_control.h +++ b/libs/ardour/ardour/record_safe_control.h @@ -39,7 +39,7 @@ class LIBARDOUR_API RecordSafeControl : public SlavableAutomationControl ~RecordSafeControl() {} protected: - void actually_set_value (double val, Controllable::GroupControlDisposition gcd); + bool actually_set_value (double val, Controllable::GroupControlDisposition gcd); private: Recordable& _recordable; diff --git a/libs/ardour/ardour/slavable_automation_control.h b/libs/ardour/ardour/slavable_automation_control.h index 7e46dd5a74..c7133df89d 100644 --- a/libs/ardour/ardour/slavable_automation_control.h +++ b/libs/ardour/ardour/slavable_automation_control.h @@ -102,7 +102,7 @@ class LIBARDOUR_API SlavableAutomationControl : public AutomationControl void master_going_away (boost::weak_ptr); double get_value_locked() const; - void actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override); + bool actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override); void update_boolean_masters_records (boost::shared_ptr); virtual void master_changed (bool from_self, GroupControlDisposition gcd, boost::shared_ptr); diff --git a/libs/ardour/ardour/solo_control.h b/libs/ardour/ardour/solo_control.h index 3f0f522fc3..4678ca6049 100644 --- a/libs/ardour/ardour/solo_control.h +++ b/libs/ardour/ardour/solo_control.h @@ -96,7 +96,7 @@ class LIBARDOUR_API SoloControl : public SlavableAutomationControl XMLNode& get_state (); protected: - void actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); + bool actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); void master_changed (bool from_self, GroupControlDisposition, boost::shared_ptr m); void pre_remove_master (boost::shared_ptr); void post_add_master (boost::shared_ptr); diff --git a/libs/ardour/ardour/solo_isolate_control.h b/libs/ardour/ardour/solo_isolate_control.h index 1e49469067..e77591e272 100644 --- a/libs/ardour/ardour/solo_isolate_control.h +++ b/libs/ardour/ardour/solo_isolate_control.h @@ -74,7 +74,7 @@ class LIBARDOUR_API SoloIsolateControl : public SlavableAutomationControl protected: void master_changed (bool from_self, PBD::Controllable::GroupControlDisposition gcd, boost::shared_ptr); - void actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); + bool actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); private: Soloable& _soloable; diff --git a/libs/ardour/ardour/solo_safe_control.h b/libs/ardour/ardour/solo_safe_control.h index e969959e94..ba31692589 100644 --- a/libs/ardour/ardour/solo_safe_control.h +++ b/libs/ardour/ardour/solo_safe_control.h @@ -44,7 +44,7 @@ class LIBARDOUR_API SoloSafeControl : public SlavableAutomationControl XMLNode& get_state (); protected: - void actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); + bool actually_set_value (double, PBD::Controllable::GroupControlDisposition group_override); private: bool _solo_safe; diff --git a/libs/ardour/automation_control.cc b/libs/ardour/automation_control.cc index 9a6590ebe8..03871cf07c 100644 --- a/libs/ardour/automation_control.cc +++ b/libs/ardour/automation_control.cc @@ -116,11 +116,11 @@ AutomationControl::set_value (double val, PBD::Controllable::GroupControlDisposi * (e.g. record if necessary, etc.) * @param value `user' value */ -void +bool AutomationControl::actually_set_value (double value, PBD::Controllable::GroupControlDisposition gcd) { bool to_list = _list && boost::dynamic_pointer_cast(_list)->automation_write(); - //const double old_value = Control::user_double (); + const double old_value = get_value (); Control::set_double (value, _session.transport_frame(), to_list); @@ -128,7 +128,12 @@ AutomationControl::actually_set_value (double value, PBD::Controllable::GroupCon //std::cerr << "++++ Changed (" << enum_2_string (at) << ", " << enum_2_string (gcd) << ") = " << value //<< " (was " << old_value << ") @ " << this << std::endl; - Changed (true, gcd); + if (old_value != value) { + Changed (true, gcd); + return true; + } + + return false; } void diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc index f1344e7697..ac5cfc098a 100644 --- a/libs/ardour/midi_track.cc +++ b/libs/ardour/midi_track.cc @@ -712,7 +712,7 @@ MidiTrack::set_parameter_automation_state (Evoral::Parameter param, AutoState st } } -void +bool MidiTrack::MidiControl::actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override) { const Evoral::Parameter ¶meter = _list ? _list->parameter() : Control::parameter(); @@ -732,7 +732,7 @@ MidiTrack::MidiControl::actually_set_value (double val, PBD::Controllable::Group } if (!valid) { - return; + return false; } assert(val <= desc.upper); @@ -776,7 +776,7 @@ MidiTrack::MidiControl::actually_set_value (double val, PBD::Controllable::Group _route->write_immediate_event(size, ev); } - AutomationControl::actually_set_value(val, group_override); + return AutomationControl::actually_set_value(val, group_override); } void diff --git a/libs/ardour/monitor_control.cc b/libs/ardour/monitor_control.cc index 907a7473d7..a5907f769f 100644 --- a/libs/ardour/monitor_control.cc +++ b/libs/ardour/monitor_control.cc @@ -36,7 +36,7 @@ MonitorControl::MonitorControl (Session& session, std::string const & name, Moni set_flags (Controllable::Flag (flags() | Controllable::RealTime)); } -void +bool MonitorControl::actually_set_value (double val, Controllable::GroupControlDisposition gcd) { int v = (int) val; @@ -48,11 +48,11 @@ MonitorControl::actually_set_value (double val, Controllable::GroupControlDispos break; default: /* illegal value */ - return; + return false; } _monitoring = MonitorChoice (v); - AutomationControl::actually_set_value (val, gcd); + return AutomationControl::actually_set_value (val, gcd); } XMLNode& diff --git a/libs/ardour/mute_control.cc b/libs/ardour/mute_control.cc index 5b38547366..1b7f0f08f8 100644 --- a/libs/ardour/mute_control.cc +++ b/libs/ardour/mute_control.cc @@ -74,7 +74,7 @@ MuteControl::pre_remove_master (boost::shared_ptr m) } } -void +bool MuteControl::actually_set_value (double val, Controllable::GroupControlDisposition gcd) { if (muted_by_self() != bool (val)) { @@ -86,7 +86,7 @@ MuteControl::actually_set_value (double val, Controllable::GroupControlDispositi _muteable.act_on_mute (); } - SlavableAutomationControl::actually_set_value (val, gcd); + return SlavableAutomationControl::actually_set_value (val, gcd); } void diff --git a/libs/ardour/pan_controllable.cc b/libs/ardour/pan_controllable.cc index 89842b124b..e4ad360910 100644 --- a/libs/ardour/pan_controllable.cc +++ b/libs/ardour/pan_controllable.cc @@ -34,15 +34,14 @@ PanControllable::lower () const } } -void +bool PanControllable::actually_set_value (double v, Controllable::GroupControlDisposition group_override) { boost::shared_ptr p = owner->panner(); if (!p) { /* no panner: just do it */ - AutomationControl::actually_set_value (v, group_override); - return; + return AutomationControl::actually_set_value (v, group_override); } bool can_set = false; @@ -62,8 +61,10 @@ PanControllable::actually_set_value (double v, Controllable::GroupControlDisposi } if (can_set) { - AutomationControl::actually_set_value (v, group_override); + return AutomationControl::actually_set_value (v, group_override); } + + return false; } std::string diff --git a/libs/ardour/phase_control.cc b/libs/ardour/phase_control.cc index 9757c104b9..96d0d375b6 100644 --- a/libs/ardour/phase_control.cc +++ b/libs/ardour/phase_control.cc @@ -32,12 +32,12 @@ PhaseControl::PhaseControl (Session& session, std::string const & name) { } -void +bool PhaseControl::actually_set_value (double val, Controllable::GroupControlDisposition gcd) { _phase_invert = boost::dynamic_bitset<> (std::numeric_limits::digits, (unsigned long) val); - AutomationControl::actually_set_value (val, gcd); + return AutomationControl::actually_set_value (val, gcd); } /** @param c Audio channel index. @@ -48,7 +48,7 @@ PhaseControl::set_phase_invert (uint32_t c, bool yn) { if (_phase_invert[c] != yn) { _phase_invert[c] = yn; - AutomationControl::actually_set_value (_phase_invert.to_ulong(), Controllable::NoGroup); + (void) AutomationControl::actually_set_value (_phase_invert.to_ulong(), Controllable::NoGroup); _session.set_dirty (); } } @@ -58,7 +58,7 @@ PhaseControl::set_phase_invert (boost::dynamic_bitset<> p) { if (_phase_invert != p) { _phase_invert = p; - AutomationControl::actually_set_value (_phase_invert.to_ulong(), Controllable::NoGroup); + (void) AutomationControl::actually_set_value (_phase_invert.to_ulong(), Controllable::NoGroup); Changed (true, Controllable::NoGroup); /* EMIT SIGNAL */ _session.set_dirty (); } diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 2283f99e4b..a8348c1df3 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -2767,7 +2767,7 @@ PluginInsert::PluginControl::PluginControl (PluginInsert* p, /** @param val `user' value */ -void +bool PluginInsert::PluginControl::actually_set_value (double user_val, PBD::Controllable::GroupControlDisposition group_override) { /* FIXME: probably should be taking out some lock here.. */ @@ -2781,13 +2781,13 @@ PluginInsert::PluginControl::actually_set_value (double user_val, PBD::Controlla iasp->set_parameter (_list->parameter().id(), user_val); } - AutomationControl::actually_set_value (user_val, group_override); + return AutomationControl::actually_set_value (user_val, group_override); } void PluginInsert::PluginControl::catch_up_with_external_value (double user_val) { - AutomationControl::actually_set_value (user_val, Controllable::NoGroup); + (void) AutomationControl::actually_set_value (user_val, Controllable::NoGroup); } XMLNode& @@ -2834,7 +2834,7 @@ PluginInsert::PluginPropertyControl::PluginPropertyControl (PluginInsert* } } -void +bool PluginInsert::PluginPropertyControl::actually_set_value (double user_val, Controllable::GroupControlDisposition gcd) { /* Old numeric set_value(), coerce to appropriate datatype if possible. @@ -2843,7 +2843,7 @@ PluginInsert::PluginPropertyControl::actually_set_value (double user_val, Contro const Variant value(_desc.datatype, user_val); if (value.type() == Variant::NOTHING) { error << "set_value(double) called for non-numeric property" << endmsg; - return; + return false; } for (Plugins::iterator i = _plugin->_plugins.begin(); i != _plugin->_plugins.end(); ++i) { @@ -2852,7 +2852,7 @@ PluginInsert::PluginPropertyControl::actually_set_value (double user_val, Contro _value = value; - AutomationControl::actually_set_value (user_val, gcd); + return AutomationControl::actually_set_value (user_val, gcd); } XMLNode& diff --git a/libs/ardour/record_enable_control.cc b/libs/ardour/record_enable_control.cc index f3512c3204..c83c0d186d 100644 --- a/libs/ardour/record_enable_control.cc +++ b/libs/ardour/record_enable_control.cc @@ -45,15 +45,15 @@ RecordEnableControl::set_value (double val, Controllable::GroupControlDispositio SlavableAutomationControl::set_value (val, gcd); } -void +bool RecordEnableControl::actually_set_value (double val, Controllable::GroupControlDisposition gcd) { if (val && !_recordable.can_be_record_enabled()) { std::cerr << "rec-enable not allowed\n"; - return; + return false; } - SlavableAutomationControl::actually_set_value (val, gcd); + return SlavableAutomationControl::actually_set_value (val, gcd); } void diff --git a/libs/ardour/record_safe_control.cc b/libs/ardour/record_safe_control.cc index f3036e04ea..d9c698cbdb 100644 --- a/libs/ardour/record_safe_control.cc +++ b/libs/ardour/record_safe_control.cc @@ -36,14 +36,14 @@ RecordSafeControl::RecordSafeControl (Session& session, std::string const & name set_flags (Controllable::Flag (flags() | Controllable::RealTime)); } -void +bool RecordSafeControl::actually_set_value (double val, Controllable::GroupControlDisposition gcd) { if (val && !_recordable.can_be_record_safe()) { std::cerr << "rec-enable not allowed\n"; - return; + return false; } - SlavableAutomationControl::actually_set_value (val, gcd); + return SlavableAutomationControl::actually_set_value (val, gcd); } diff --git a/libs/ardour/slavable_automation_control.cc b/libs/ardour/slavable_automation_control.cc index a80598439d..2f67946705 100644 --- a/libs/ardour/slavable_automation_control.cc +++ b/libs/ardour/slavable_automation_control.cc @@ -96,7 +96,7 @@ SlavableAutomationControl::get_value() const } } -void +bool SlavableAutomationControl::actually_set_value (double val, Controllable::GroupControlDisposition group_override) { val = std::max (std::min (val, (double)_desc.upper), (double)_desc.lower); @@ -112,9 +112,12 @@ SlavableAutomationControl::actually_set_value (double val, Controllable::GroupCo /* this sets the Evoral::Control::_user_value for us, which will be retrieved by AutomationControl::get_value () */ - AutomationControl::actually_set_value (val, group_override); + if (AutomationControl::actually_set_value (val, group_override)) { + _session.set_dirty (); + return true; + } - _session.set_dirty (); + return false; } void diff --git a/libs/ardour/solo_control.cc b/libs/ardour/solo_control.cc index 087e5d04ab..ca41ee7aac 100644 --- a/libs/ardour/solo_control.cc +++ b/libs/ardour/solo_control.cc @@ -157,11 +157,11 @@ SoloControl::mod_solo_by_others_upstream (int32_t delta) Changed (false, Controllable::NoGroup); /* EMIT SIGNAL */ } -void +bool SoloControl::actually_set_value (double val, PBD::Controllable::GroupControlDisposition group_override) { if (_soloable.is_safe() || !_soloable.can_solo()) { - return; + return false; } set_self_solo (val == 1.0); @@ -170,7 +170,7 @@ SoloControl::actually_set_value (double val, PBD::Controllable::GroupControlDisp be retrieved by AutomationControl::get_value (), and emits Changed */ - SlavableAutomationControl::actually_set_value (val, group_override); + return SlavableAutomationControl::actually_set_value (val, group_override); } double diff --git a/libs/ardour/solo_isolate_control.cc b/libs/ardour/solo_isolate_control.cc index 7964f7eb66..ebd046fba6 100644 --- a/libs/ardour/solo_isolate_control.cc +++ b/libs/ardour/solo_isolate_control.cc @@ -88,11 +88,11 @@ SoloIsolateControl::mod_solo_isolated_by_upstream (int32_t delta) } } -void +bool SoloIsolateControl::actually_set_value (double val, PBD::Controllable::GroupControlDisposition gcd) { if (!_soloable.can_solo()) { - return; + return false; } set_solo_isolated (val, gcd); @@ -101,8 +101,12 @@ SoloIsolateControl::actually_set_value (double val, PBD::Controllable::GroupCont be retrieved by AutomationControl::get_value (), and emits Changed */ - AutomationControl::actually_set_value (val, gcd); - _session.set_dirty (); + if (AutomationControl::actually_set_value (val, gcd)) { + _session.set_dirty (); + return true; + } + + return false; } void diff --git a/libs/ardour/solo_safe_control.cc b/libs/ardour/solo_safe_control.cc index 01d56ddf58..7e8de603a7 100644 --- a/libs/ardour/solo_safe_control.cc +++ b/libs/ardour/solo_safe_control.cc @@ -36,7 +36,7 @@ SoloSafeControl::SoloSafeControl (Session& session, std::string const & name) _list->set_interpolation(Evoral::ControlList::Discrete); } -void +bool SoloSafeControl::actually_set_value (double val, PBD::Controllable::GroupControlDisposition gcd) { _solo_safe = (val ? true : false); @@ -45,8 +45,12 @@ SoloSafeControl::actually_set_value (double val, PBD::Controllable::GroupControl be retrieved by AutomationControl::get_value (), and emits Changed */ - AutomationControl::actually_set_value (val, gcd); - _session.set_dirty (); + if (AutomationControl::actually_set_value (val, gcd)) { + _session.set_dirty (); + return true; + } + + return false; } double