diff options
author | Robin Gareus <robin@gareus.org> | 2019-07-17 17:04:25 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-07-17 17:31:08 +0200 |
commit | 42fef352992f83bfd135f17726a269056a4684fc (patch) | |
tree | 59f9a7f185c755cb2337e1277ad1bb1881f2833e /gtk2_ardour/latency_gui.cc | |
parent | 2fd57d23fa9eb3c5ccb090f30bfc4b7843ac4585 (diff) |
Update Latency GUI behavior
This allows to set the current nominal latency as custom latency.
Previously it was not possible to use the "initial_value" as custom
parameter.
Diffstat (limited to 'gtk2_ardour/latency_gui.cc')
-rw-r--r-- | gtk2_ardour/latency_gui.cc | 28 |
1 files changed, 16 insertions, 12 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 |