summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/latency_gui.cc28
-rw-r--r--gtk2_ardour/latency_gui.h8
2 files changed, 21 insertions, 15 deletions
diff --git a/gtk2_ardour/latency_gui.cc b/gtk2_ardour/latency_gui.cc
index 61e9d15eea..a323b4fbc2 100644
--- a/gtk2_ardour/latency_gui.cc
+++ b/gtk2_ardour/latency_gui.cc
@@ -65,12 +65,12 @@ LatencyBarController::get_label (double&)
return s.str ();
}
-LatencyGUI::LatencyGUI (Latent& l, samplepos_t sr, samplepos_t psz, bool apply)
+LatencyGUI::LatencyGUI (Latent& l, samplepos_t sr, samplepos_t psz)
: _latent (l)
- , initial_value (_latent.effective_latency ())
, sample_rate (sr)
, period_size (psz)
, ignored (new PBD::IgnorableControllable())
+ , _ignore_change (false)
, adjustment (0, 0.0, sample_rate, 1.0, sample_rate / 1000.0f) /* max 1 second, step by samples, page by msecs */
, bc (adjustment, this)
, reset_button (_("Reset"))
@@ -104,6 +104,12 @@ LatencyGUI::LatencyGUI (Latent& l, samplepos_t sr, samplepos_t psz, bool apply)
plus_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &LatencyGUI::change_latency_from_button), 1));
reset_button.signal_clicked().connect (sigc::mem_fun (*this, &LatencyGUI::reset));
+ /* Limit value to adjustment range (max = sample_rate).
+ * Otherwise if the signal_latency() is larger than the adjustment's max,
+ * LatencyGUI::finish() would set the adjustment's max value as custom-latency.
+ */
+ adjustment.set_value (std::min (sample_rate, _latent.signal_latency ()));
+
adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &LatencyGUI::finish));
bc.set_size_request (-1, 25);
@@ -117,28 +123,26 @@ LatencyGUI::LatencyGUI (Latent& l, samplepos_t sr, samplepos_t psz, bool apply)
void
LatencyGUI::finish ()
{
- samplepos_t new_value = (samplepos_t) adjustment.get_value();
- if (new_value != initial_value) {
- _latent.set_user_latency (new_value);
+ if (_ignore_change) {
+ return;
}
+ samplepos_t new_value = (samplepos_t) adjustment.get_value();
+ _latent.set_user_latency (new_value);
}
void
LatencyGUI::reset ()
{
_latent.unset_user_latency ();
- initial_value = std::min (sample_rate, _latent.signal_latency ());
- adjustment.set_value (initial_value);
+ PBD::Unwinder<bool> uw (_ignore_change, true);
+ adjustment.set_value (std::min (sample_rate, _latent.signal_latency ()));
}
void
LatencyGUI::refresh ()
{
- /* limit to adjustment range, otherwise LatencyGUI::finish() would
- * set the adjustment's value as custom-latency
- */
- initial_value = std::min (sample_rate, _latent.effective_latency ());
- adjustment.set_value (initial_value);
+ PBD::Unwinder<bool> uw (_ignore_change, true);
+ adjustment.set_value (std::min (sample_rate, _latent.effective_latency ()));
}
void
diff --git a/gtk2_ardour/latency_gui.h b/gtk2_ardour/latency_gui.h
index 943944571e..25e469abfc 100644
--- a/gtk2_ardour/latency_gui.h
+++ b/gtk2_ardour/latency_gui.h
@@ -60,17 +60,19 @@ public:
LatencyGUI (ARDOUR::Latent&, samplepos_t sample_rate, samplepos_t period_size);
~LatencyGUI() { }
- void finish ();
- void reset ();
void refresh ();
private:
+ void reset ();
+ void finish ();
+
ARDOUR::Latent& _latent;
- samplepos_t initial_value;
samplepos_t sample_rate;
samplepos_t period_size;
+
boost::shared_ptr<PBD::IgnorableControllable> ignored;
+ bool _ignore_change;
Gtk::Adjustment adjustment;
LatencyBarController bc;
Gtk::HBox hbox1;