13
0

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 (); 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) : _latent (l)
, initial_value (_latent.effective_latency ())
, sample_rate (sr) , sample_rate (sr)
, period_size (psz) , period_size (psz)
, ignored (new PBD::IgnorableControllable()) , 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 */ , adjustment (0, 0.0, sample_rate, 1.0, sample_rate / 1000.0f) /* max 1 second, step by samples, page by msecs */
, bc (adjustment, this) , bc (adjustment, this)
, reset_button (_("Reset")) , 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)); 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)); 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)); adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &LatencyGUI::finish));
bc.set_size_request (-1, 25); bc.set_size_request (-1, 25);
@ -117,28 +123,26 @@ LatencyGUI::LatencyGUI (Latent& l, samplepos_t sr, samplepos_t psz, bool apply)
void void
LatencyGUI::finish () LatencyGUI::finish ()
{ {
samplepos_t new_value = (samplepos_t) adjustment.get_value(); if (_ignore_change) {
if (new_value != initial_value) { return;
_latent.set_user_latency (new_value);
} }
samplepos_t new_value = (samplepos_t) adjustment.get_value();
_latent.set_user_latency (new_value);
} }
void void
LatencyGUI::reset () LatencyGUI::reset ()
{ {
_latent.unset_user_latency (); _latent.unset_user_latency ();
initial_value = std::min (sample_rate, _latent.signal_latency ()); PBD::Unwinder<bool> uw (_ignore_change, true);
adjustment.set_value (initial_value); adjustment.set_value (std::min (sample_rate, _latent.signal_latency ()));
} }
void void
LatencyGUI::refresh () LatencyGUI::refresh ()
{ {
/* limit to adjustment range, otherwise LatencyGUI::finish() would PBD::Unwinder<bool> uw (_ignore_change, true);
* set the adjustment's value as custom-latency adjustment.set_value (std::min (sample_rate, _latent.effective_latency ()));
*/
initial_value = std::min (sample_rate, _latent.effective_latency ());
adjustment.set_value (initial_value);
} }
void void

View File

@ -60,17 +60,19 @@ public:
LatencyGUI (ARDOUR::Latent&, samplepos_t sample_rate, samplepos_t period_size); LatencyGUI (ARDOUR::Latent&, samplepos_t sample_rate, samplepos_t period_size);
~LatencyGUI() { } ~LatencyGUI() { }
void finish ();
void reset ();
void refresh (); void refresh ();
private: private:
void reset ();
void finish ();
ARDOUR::Latent& _latent; ARDOUR::Latent& _latent;
samplepos_t initial_value;
samplepos_t sample_rate; samplepos_t sample_rate;
samplepos_t period_size; samplepos_t period_size;
boost::shared_ptr<PBD::IgnorableControllable> ignored; boost::shared_ptr<PBD::IgnorableControllable> ignored;
bool _ignore_change;
Gtk::Adjustment adjustment; Gtk::Adjustment adjustment;
LatencyBarController bc; LatencyBarController bc;
Gtk::HBox hbox1; Gtk::HBox hbox1;