use new record safe control in libardour
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 27 May 2016 20:11:47 +0000 (16:11 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 31 May 2016 19:30:45 +0000 (15:30 -0400)
libs/ardour/ardour/stripable.h
libs/ardour/ardour/track.h
libs/ardour/ardour/utils.h
libs/ardour/ardour/vca.h
libs/ardour/session.cc
libs/ardour/track.cc
libs/ardour/vca.cc
libs/ardour/wscript

index 0ebd1f55ada02bf976261acabefdf9adb07d9209..b21b98f2bb1b81433643a601fb7024b22fcaf848 100644 (file)
@@ -44,6 +44,8 @@ class SoloIsolateControl;
 class SoloSafeControl;
 class MonitorControl;
 class MonitorProcessor;
+class RecordEnableControl;
+class RecordSafeControl;
 
 /* This is a virtual base class for any object that needs to be potentially
  * represented by a control-centric user interface using the general model of a
@@ -104,7 +106,9 @@ class LIBARDOUR_API Stripable : public SessionObject {
        virtual boost::shared_ptr<GainControl> trim_control() const = 0;
 
        virtual boost::shared_ptr<MonitorControl> monitoring_control() const = 0;
+
        virtual boost::shared_ptr<AutomationControl> rec_enable_control() const { return boost::shared_ptr<AutomationControl>(); }
+       virtual boost::shared_ptr<AutomationControl> rec_safe_control() const { return boost::shared_ptr<AutomationControl>(); }
 
        /* "well-known" controls for panning. Any or all of these may return
          * null.
index d57e0a2b5a9b33e1f69b3297a3db8b0ad065bca8..243d40faf08b6d1ffc3815a2272a9fa63c75f1f8 100644 (file)
@@ -36,6 +36,8 @@ class Region;
 class Diskstream;
 class IO;
 class MonitorControl;
+class RecordEnableControl;
+class RecordSafeControl;
 
 /** A track is an route (bus) with a recordable diskstream and
  * related objects relevant to tracking, playback and editing.
index 1dc7c2baf4ac591af5914a99bda717a9d057a7d6..4edf9fb446f92a74fc6976567783d93ae7754bc8 100644 (file)
@@ -176,7 +176,7 @@ LIBARDOUR_API bool matching_unsuffixed_filename_exists_in (const std::string& di
 
 LIBARDOUR_API uint32_t how_many_dsp_threads ();
 
-template<typename T> boost::shared_ptr<ControlList> route_list_to_control_list (boost::shared_ptr<RouteList> rl, boost::shared_ptr<T> (Route::*get_control)() const) {
+template<typename T> boost::shared_ptr<ControlList> route_list_to_control_list (boost::shared_ptr<RouteList> rl, boost::shared_ptr<T> (Stripable::*get_control)() const) {
        boost::shared_ptr<ControlList> cl (new ControlList);
        for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
                boost::shared_ptr<AutomationControl> ac = ((*r).get()->*get_control)();
@@ -187,18 +187,6 @@ template<typename T> boost::shared_ptr<ControlList> route_list_to_control_list (
        return cl;
 }
 
-template<typename T> boost::shared_ptr<ControlList> route_list_to_control_list (boost::shared_ptr<RouteList> rl, boost::shared_ptr<T> (Track::*get_control)() const) {
-       boost::shared_ptr<ControlList> cl (new ControlList);
-       for (RouteList::const_iterator r = rl->begin(); r != rl->end(); ++r) {
-               boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (*r);
-               boost::shared_ptr<AutomationControl> ac = (t.get()->*get_control)();
-               if (ac) {
-                       cl->push_back (ac);
-               }
-       }
-       return cl;
-}
-
 #if __APPLE__
 LIBARDOUR_API std::string CFStringRefToStdString(CFStringRef stringRef);
 #endif // __APPLE__
index 1583e453fc8a4593d9d6d6fde68a3f8b5e69eadc..de0117ae8c4c74c074a3ccaff0379a499ad07f8b 100644 (file)
@@ -101,46 +101,45 @@ class LIBARDOUR_API VCA : public Stripable,
        static uint32_t get_next_vca_number ();
        static void set_next_vca_number (uint32_t);
 
-       virtual boost::shared_ptr<GainControl> gain_control() const { return _gain_control; }
-       virtual boost::shared_ptr<SoloControl> solo_control() const { return _solo_control; }
-       virtual boost::shared_ptr<MuteControl> mute_control() const { return _mute_control; }
-       virtual boost::shared_ptr<AutomationControl> rec_enable_control() const { return _recenable_control; }
-       virtual boost::shared_ptr<MonitorControl>    monitoring_control() const { return _monitor_control; }
+       boost::shared_ptr<GainControl> gain_control() const { return _gain_control; }
+       boost::shared_ptr<SoloControl> solo_control() const { return _solo_control; }
+       boost::shared_ptr<MuteControl> mute_control() const { return _mute_control; }
 
        /* null Stripable API, because VCAs don't have any of this */
 
-       virtual boost::shared_ptr<SoloIsolateControl> solo_isolate_control() const { return boost::shared_ptr<SoloIsolateControl>(); }
-       virtual boost::shared_ptr<SoloSafeControl> solo_safe_control() const { return boost::shared_ptr<SoloSafeControl>(); }
-       virtual boost::shared_ptr<PeakMeter>         peak_meter() { return boost::shared_ptr<PeakMeter>(); }
-       virtual boost::shared_ptr<const PeakMeter>   peak_meter() const { return boost::shared_ptr<PeakMeter>(); }
-       virtual boost::shared_ptr<PhaseControl>      phase_control() const { return boost::shared_ptr<PhaseControl>(); }
-       virtual boost::shared_ptr<GainControl>       trim_control() const { return boost::shared_ptr<GainControl>(); }
-       virtual boost::shared_ptr<AutomationControl> pan_azimuth_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> pan_elevation_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> pan_width_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> pan_frontback_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> pan_lfe_control() const { return boost::shared_ptr<AutomationControl>(); }
-       virtual uint32_t eq_band_cnt () const { return 0; }
-       virtual std::string eq_band_name (uint32_t) const { return std::string(); }
-       virtual boost::shared_ptr<AutomationControl> eq_gain_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> eq_freq_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> eq_q_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> eq_shape_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> eq_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> eq_hpf_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_threshold_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_speed_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_mode_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_makeup_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> comp_redux_controllable () const { return boost::shared_ptr<AutomationControl>(); }
-       virtual std::string comp_mode_name (uint32_t mode) const { return std::string(); }
-       virtual std::string comp_speed_name (uint32_t mode) const { return std::string(); }
-       virtual boost::shared_ptr<AutomationControl> send_level_controllable (uint32_t n) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual boost::shared_ptr<AutomationControl> send_enable_controllable (uint32_t n) const { return boost::shared_ptr<AutomationControl>(); }
-       virtual std::string send_name (uint32_t n) const { return std::string(); }
-       virtual boost::shared_ptr<AutomationControl> master_send_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<SoloIsolateControl> solo_isolate_control() const { return boost::shared_ptr<SoloIsolateControl>(); }
+       boost::shared_ptr<SoloSafeControl> solo_safe_control() const { return boost::shared_ptr<SoloSafeControl>(); }
+       boost::shared_ptr<PeakMeter>         peak_meter() { return boost::shared_ptr<PeakMeter>(); }
+       boost::shared_ptr<const PeakMeter>   peak_meter() const { return boost::shared_ptr<PeakMeter>(); }
+       boost::shared_ptr<PhaseControl>      phase_control() const { return boost::shared_ptr<PhaseControl>(); }
+       boost::shared_ptr<GainControl>       trim_control() const { return boost::shared_ptr<GainControl>(); }
+       boost::shared_ptr<AutomationControl> pan_azimuth_control() const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> pan_elevation_control() const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> pan_width_control() const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> pan_frontback_control() const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> pan_lfe_control() const { return boost::shared_ptr<AutomationControl>(); }
+       uint32_t eq_band_cnt () const { return 0; }
+       std::string eq_band_name (uint32_t) const { return std::string(); }
+       boost::shared_ptr<AutomationControl> eq_gain_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> eq_freq_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> eq_q_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> eq_shape_controllable (uint32_t band) const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> eq_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> eq_hpf_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_threshold_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_speed_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_mode_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_makeup_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> comp_redux_controllable () const { return boost::shared_ptr<AutomationControl>(); }
+       std::string comp_mode_name (uint32_t mode) const { return std::string(); }
+       std::string comp_speed_name (uint32_t mode) const { return std::string(); }
+       boost::shared_ptr<AutomationControl> send_level_controllable (uint32_t n) const { return boost::shared_ptr<AutomationControl>(); }
+       boost::shared_ptr<AutomationControl> send_enable_controllable (uint32_t n) const { return boost::shared_ptr<AutomationControl>(); }
+       std::string send_name (uint32_t n) const { return std::string(); }
+       boost::shared_ptr<AutomationControl> master_send_enable_controllable () const { return boost::shared_ptr<AutomationControl>(); }
        boost::shared_ptr<MonitorProcessor> monitor_control() const { return boost::shared_ptr<MonitorProcessor>(); }
+       boost::shared_ptr<MonitorControl> monitoring_control() const { return boost::shared_ptr<MonitorControl>(); }
 
   private:
        uint32_t _number;
@@ -148,9 +147,7 @@ class LIBARDOUR_API VCA : public Stripable,
        boost::shared_ptr<GainControl> _gain_control;
        boost::shared_ptr<SoloControl> _solo_control;
        boost::shared_ptr<MuteControl> _mute_control;
-       boost::shared_ptr<AutomationControl> _recenable_control;
-       // boost::shared_ptr<AutomationControl> _record_safe_control;
-       boost::shared_ptr<MonitorControl> _monitor_control;
+
 
        static uint32_t next_number;
        static Glib::Threads::Mutex number_lock;
index 6caa41e9ed917de6e039215d8c72fb4ee912293c..1d285d66115ff91211d2b0ff66f4bfa41fe87c4b 100644 (file)
@@ -1942,7 +1942,7 @@ void
 Session::set_all_tracks_record_enabled (bool enable )
 {
        boost::shared_ptr<RouteList> rl = routes.reader();
-       set_controls (route_list_to_control_list (rl, &Track::rec_enable_control), enable, Controllable::NoGroup);
+       set_controls (route_list_to_control_list (rl, &Stripable::rec_enable_control), enable, Controllable::NoGroup);
 }
 
 void
@@ -6182,7 +6182,7 @@ Session::solo_control_mode_changed ()
                   the session's saved solo state). So just explicitly turn
                   them all off.
                */
-               set_controls (route_list_to_control_list (get_routes(), &Route::solo_control), 0.0, Controllable::NoGroup);
+               set_controls (route_list_to_control_list (get_routes(), &Stripable::solo_control), 0.0, Controllable::NoGroup);
        }
 }
 
index 17a7c13295de391afc3bb8186d6b3c5e00fdde28..75cb689441efc2a8063bd5351ef87bf924f89f1b 100644 (file)
@@ -28,6 +28,7 @@
 #include "ardour/port.h"
 #include "ardour/processor.h"
 #include "ardour/record_enable_control.h"
+#include "ardour/record_safe_control.h"
 #include "ardour/route_group_specialized.h"
 #include "ardour/session.h"
 #include "ardour/session_playlists.h"
@@ -67,9 +68,7 @@ Track::init ()
        _record_enable_control.reset (new RecordEnableControl (_session, X_("recenable"), *this));
        add_control (_record_enable_control);
 
-       _record_safe_control.reset (new AutomationControl (_session, RecSafeAutomation, ParameterDescriptor (RecSafeAutomation),
-                                                          boost::shared_ptr<AutomationList> (new AutomationList (Evoral::Parameter (RecSafeAutomation))),
-                                                          X_("recsafe")));
+       _record_safe_control.reset (new RecordSafeControl (_session, X_("recsafe"), *this));
        add_control (_record_safe_control);
 
        _monitoring_control.reset (new MonitorControl (_session, X_("monitoring"), *this));
@@ -241,27 +240,15 @@ Track::record_safe_changed (bool, Controllable::GroupControlDisposition)
 }
 
 bool
-Track::record_safe () const
+Track::can_be_record_safe ()
 {
-       return _diskstream && _diskstream->record_safe ();
+       return !_record_enable_control->get_value() && _diskstream && _session.writable() && (_freeze_record.state != Frozen);
 }
 
-void
-Track::set_record_safe (bool yn, Controllable::GroupControlDisposition group_override)
+bool
+Track::can_be_record_enabled ()
 {
-       if (!_session.writable()) {
-               return;
-       }
-
-       if (_freeze_record.state == Frozen) {
-               return;
-       }
-
-       if (record_enabled ()) {
-               return;
-       }
-
-       _rec_safe_control->set_value (yn, group_override);
+       return !_record_safe_control->get_value() && _diskstream && !_diskstream->record_safe() && _session.writable() && (_freeze_record.state != Frozen);
 }
 
 void
index 27ecec7910364e992453b146f438e1875588c548..2c87a80db4c28a8c92ba06316b17fe22c03b706a 100644 (file)
@@ -23,7 +23,6 @@
 #include "ardour/gain_control.h"
 #include "ardour/monitor_control.h"
 #include "ardour/rc_configuration.h"
-#include "ardour/record_enable_control.h"
 #include "ardour/route.h"
 #include "ardour/session.h"
 #include "ardour/vca.h"
@@ -82,8 +81,6 @@ VCA::init ()
 {
        _solo_control.reset (new SoloControl (_session, X_("solo"), *this, *this));
        _mute_control.reset (new MuteControl (_session, X_("mute"), *this));
-       _recenable_control.reset (new RecordEnableControl (_session, X_("recenable"), *this));
-       _monitor_control.reset (new MonitorControl (_session, X_("monitoring"), *this));
 
        add_control (_gain_control);
        add_control (_solo_control);
index 44e2f21c65f4efc00df93b60429c380c5d40b325..d85e6a4d4a7780b35bde4cbb4210a9e3baae8a67 100644 (file)
@@ -178,6 +178,7 @@ libardour_sources = [
         'rc_configuration.cc',
         'recent_sessions.cc',
         'record_enable_control.cc',
+        'record_safe_control.cc',
         'region_factory.cc',
         'resampled_source.cc',
         'region.cc',