Skip delayline updates if no change is required
This commit is contained in:
parent
38c61b6dab
commit
8aa4ae825d
@ -346,7 +346,7 @@ public:
|
||||
*/
|
||||
bool remove_sidechain (boost::shared_ptr<Processor> proc) { return add_remove_sidechain (proc, false); }
|
||||
|
||||
samplecnt_t update_signal_latency (bool apply_to_delayline = false);
|
||||
samplecnt_t update_signal_latency (bool apply_to_delayline = false, bool* delayline_update_needed = NULL);
|
||||
virtual void apply_latency_compensation ();
|
||||
|
||||
samplecnt_t set_private_port_latencies (bool playback) const;
|
||||
|
@ -1342,7 +1342,7 @@ private:
|
||||
void remove_monitor_section ();
|
||||
|
||||
void update_latency (bool playback);
|
||||
bool update_route_latency (bool reverse, bool apply_to_delayline);
|
||||
bool update_route_latency (bool reverse, bool apply_to_delayline, bool* delayline_update_needed);
|
||||
void initialize_latencies ();
|
||||
void set_worst_output_latency ();
|
||||
void set_worst_input_latency ();
|
||||
|
@ -4221,7 +4221,7 @@ Route::add_export_point()
|
||||
}
|
||||
|
||||
samplecnt_t
|
||||
Route::update_signal_latency (bool apply_to_delayline)
|
||||
Route::update_signal_latency (bool apply_to_delayline, bool* delayline_update_needed)
|
||||
{
|
||||
if (!active()) {
|
||||
_signal_latency = 0;
|
||||
@ -4303,6 +4303,15 @@ Route::update_signal_latency (bool apply_to_delayline)
|
||||
if (apply_to_delayline) {
|
||||
/* see also Session::post_playback_latency() */
|
||||
apply_latency_compensation ();
|
||||
} else if (delayline_update_needed && _delayline) {
|
||||
samplecnt_t play_lat_in = _input->connected_latency (true);
|
||||
samplecnt_t latcomp = play_lat_in - play_lat_out - _signal_latency;
|
||||
if (latcomp < 0) {
|
||||
latcomp = 0;
|
||||
}
|
||||
if (_delayline->delay () != latcomp) {
|
||||
*delayline_update_needed = true;
|
||||
}
|
||||
}
|
||||
|
||||
_output_latency = _output->latency ();
|
||||
|
@ -6473,7 +6473,7 @@ Session::send_latency_compensation_change ()
|
||||
}
|
||||
|
||||
bool
|
||||
Session::update_route_latency (bool playback, bool apply_to_delayline)
|
||||
Session::update_route_latency (bool playback, bool apply_to_delayline, bool* delayline_update_needed)
|
||||
{
|
||||
/* apply_to_delayline can no be called concurrently with processing
|
||||
* caller must hold process lock when apply_to_delayline == true */
|
||||
@ -6502,7 +6502,7 @@ restart:
|
||||
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
|
||||
// if (!(*i)->active()) { continue ; } // TODO
|
||||
samplecnt_t l;
|
||||
if ((*i)->signal_latency () != (l = (*i)->update_signal_latency (apply_to_delayline))) {
|
||||
if ((*i)->signal_latency () != (l = (*i)->update_signal_latency (apply_to_delayline, delayline_update_needed))) {
|
||||
changed = true;
|
||||
}
|
||||
_worst_route_latency = std::max (l, _worst_route_latency);
|
||||
@ -6603,7 +6603,7 @@ Session::update_latency (bool playback)
|
||||
/* prevent any concurrent latency updates */
|
||||
Glib::Threads::Mutex::Lock lx (_update_latency_lock);
|
||||
set_worst_output_latency ();
|
||||
update_route_latency (true, /*apply_to_delayline*/ true);
|
||||
update_route_latency (true, /*apply_to_delayline*/ true, NULL);
|
||||
|
||||
/* relese before emiting signals */
|
||||
lm.release ();
|
||||
@ -6613,7 +6613,7 @@ Session::update_latency (bool playback)
|
||||
lm.release ();
|
||||
Glib::Threads::Mutex::Lock lx (_update_latency_lock);
|
||||
set_worst_input_latency ();
|
||||
update_route_latency (false, false);
|
||||
update_route_latency (false, false, NULL);
|
||||
}
|
||||
|
||||
DEBUG_TRACE (DEBUG::LatencyCompensation, "Engine latency callback: DONE\n");
|
||||
@ -6691,7 +6691,8 @@ Session::update_latency_compensation (bool force_whole_graph, bool called_from_b
|
||||
|
||||
DEBUG_TRACE (DEBUG::LatencyCompensation, string_compose ("update_latency_compensation%1.\n", (force_whole_graph ? " of whole graph" : "")));
|
||||
|
||||
bool some_track_latency_changed = update_route_latency (false, false);
|
||||
bool delayline_update_needed = false;
|
||||
bool some_track_latency_changed = update_route_latency (false, false, &delayline_update_needed);
|
||||
|
||||
if (some_track_latency_changed || force_whole_graph) {
|
||||
|
||||
@ -6724,8 +6725,9 @@ Session::update_latency_compensation (bool force_whole_graph, bool called_from_b
|
||||
} else {
|
||||
DEBUG_TRACE (DEBUG::LatencyCompensation, "update_latency_compensation called from engine, don't call back into engine\n");
|
||||
}
|
||||
} else {
|
||||
} else if (delayline_update_needed) {
|
||||
DEBUG_TRACE (DEBUG::LatencyCompensation, "update_latency_compensation: directly apply to routes\n");
|
||||
lx.release (); // XXX cannot hold this lock when acquiring process_lock ?!
|
||||
#ifndef MIXBUS
|
||||
Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock (), Glib::Threads::NOT_LOCK);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user