Add polarity-invert processor
[ardour.git] / libs / ardour / delayline.cc
index 689fd58c8175116ea6eb70162ebf9438d738efd2..19ef460fd0f05b1e61c783fd5f262b6a84d3b40c 100644 (file)
@@ -33,7 +33,7 @@ using namespace PBD;
 using namespace ARDOUR;
 
 DelayLine::DelayLine (Session& s, const std::string& name)
-    : Processor (s, string_compose ("latency-compensation-%1-%2", name, this))
+    : Processor (s, string_compose ("latcomp-%1-%2", name, this))
                , _delay(0)
                , _pending_delay(0)
                , _bsiz(0)
@@ -48,6 +48,12 @@ DelayLine::~DelayLine ()
 {
 }
 
+bool
+DelayLine::set_name (const string& name)
+{
+       return Processor::set_name (string_compose ("latcomp-%1-%2", name, this));
+}
+
 #define FADE_LEN (16)
 void
 DelayLine::run (BufferSet& bufs, samplepos_t /* start_sample */, samplepos_t /* end_sample */, double /* speed */, pframes_t nsamples, bool)
@@ -277,7 +283,7 @@ DelayLine::run (BufferSet& bufs, samplepos_t /* start_sample */, samplepos_t /*
        _delay = pending_delay;
 }
 
-void
+bool
 DelayLine::set_delay(samplecnt_t signal_delay)
 {
        if (signal_delay < 0) {
@@ -285,13 +291,20 @@ DelayLine::set_delay(samplecnt_t signal_delay)
                cerr << "WARNING: latency compensation is not possible.\n";
        }
 
+       if (signal_delay == _pending_delay) {
+               DEBUG_TRACE (DEBUG::LatencyCompensation,
+                               string_compose ("%1 set_delay - no change: %2 samples for %3 channels\n",
+                                       name(), signal_delay, _configured_output.n_audio()));
+               return false;
+       }
+
        DEBUG_TRACE (DEBUG::LatencyCompensation,
                        string_compose ("%1 set_delay to %2 samples for %3 channels\n",
                                name(), signal_delay, _configured_output.n_audio()));
 
        if (signal_delay <= _bsiz) {
                _pending_delay = signal_delay;
-               return;
+               return true;
        }
 
        if (_pending_bsiz) {
@@ -300,7 +313,7 @@ DelayLine::set_delay(samplecnt_t signal_delay)
                } else {
                        _pending_delay = signal_delay;
                }
-               return;
+               return true;
        }
 
        allocate_pending_buffers (signal_delay);
@@ -310,6 +323,8 @@ DelayLine::set_delay(samplecnt_t signal_delay)
        DEBUG_TRACE (DEBUG::LatencyCompensation,
                        string_compose ("allocated buffer for %1 of size %2\n",
                                name(), signal_delay));
+
+       return true;
 }
 
 bool
@@ -370,9 +385,9 @@ DelayLine::flush()
 }
 
 XMLNode&
-DelayLine::state (bool full_state)
+DelayLine::state ()
 {
-       XMLNode& node (Processor::state (full_state));
+       XMLNode& node (Processor::state ());
        node.set_property("type", "delay");
        return node;
 }