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.
This commit is contained in:
Robin Gareus 2019-07-17 17:04:25 +02:00
parent 2fd57d23fa
commit 42fef35299
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 21 additions and 15 deletions

View File

@ -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

View File

@ -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;