From 31c39ed8696658a0b4d4d7dc7e4ab5880bcecd4d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 26 Apr 2020 21:34:26 +0200 Subject: Remove duplicate i/o latency calculation Port and connection changes always imply a latency_callback from the engine. Worst I/O latency is updated directly in Session::update_latency() which is called from AudioEngine::latency_callback. Explicit subscriptions to route->output()->changed() is not needed to update the worst I/O latency. Only set_block_size() needs to to update the I/O latency when the buffer-size changes. --- libs/ardour/ardour/session.h | 3 --- libs/ardour/session.cc | 61 +++++++++++++++----------------------------- 2 files changed, 21 insertions(+), 43 deletions(-) (limited to 'libs') diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index b9c875c95c..ac50c07a29 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1343,14 +1343,11 @@ private: void update_latency (bool playback); bool update_route_latency (bool reverse, bool apply_to_delayline); - void initialize_latencies (); - void set_worst_io_latencies (); void set_worst_output_latency (); void set_worst_input_latency (); void send_latency_compensation_change (); - void set_worst_io_latencies_x (IOChange, void *); void ensure_buffers (ChanCount howmany = ChanCount::ZERO); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 3c0945e033..7518285109 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2082,32 +2082,33 @@ void Session::set_block_size (pframes_t nframes) { /* the AudioEngine guarantees - that it will not be called while we are also in - ::process(). It is therefore fine to do things that block - here. - */ - - { - current_block_size = nframes; + * that it will not be called while we are also in + * ::process(). It is therefore fine to do things that block + * here. + */ + current_block_size = nframes; - ensure_buffers (); + ensure_buffers (); - boost::shared_ptr r = routes.reader (); + boost::shared_ptr r = routes.reader (); - for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { - (*i)->set_block_size (nframes); - } + for (RouteList::iterator i = r->begin(); i != r->end(); ++i) { + (*i)->set_block_size (nframes); + } - boost::shared_ptr rl = routes.reader (); - for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { - boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); - if (tr) { - tr->set_block_size (nframes); - } + boost::shared_ptr rl = routes.reader (); + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + boost::shared_ptr tr = boost::dynamic_pointer_cast (*i); + if (tr) { + tr->set_block_size (nframes); } - - set_worst_io_latencies (); } + + DEBUG_TRACE (DEBUG::LatencyCompensation, "Session::set_block_size -> update worst i/o latency\n"); + /* when this is called from the auto-connect thread, the process-lock is held */ + Glib::Threads::Mutex::Lock lx (_update_latency_lock); + set_worst_output_latency (); + set_worst_input_latency (); } @@ -3201,7 +3202,6 @@ Session::add_routes_inner (RouteList& new_routes, bool input_auto_connect, bool r->solo_isolate_control()->Changed.connect_same_thread (*this, boost::bind (&Session::route_solo_isolated_changed, this, wpr)); r->mute_control()->Changed.connect_same_thread (*this, boost::bind (&Session::route_mute_changed, this)); - r->output()->changed.connect_same_thread (*this, boost::bind (&Session::set_worst_io_latencies_x, this, _1, _2)); r->processors_changed.connect_same_thread (*this, boost::bind (&Session::route_processors_changed, this, _1)); r->processor_latency_changed.connect_same_thread (*this, boost::bind (&Session::queue_latency_recompute, this)); @@ -6452,15 +6452,6 @@ Session::initialize_latencies () { update_latency (false); update_latency (true); - - set_worst_io_latencies (); -} - -void -Session::set_worst_io_latencies_x (IOChange, void *) -{ - DEBUG_TRACE (DEBUG::LatencyCompensation, "Session::set_worst_io_latencies_x\n"); - set_worst_io_latencies (); } void @@ -6587,16 +6578,6 @@ Session::update_latency (bool playback) LatencyUpdated (playback); /* EMIT SIGNAL */ } -void -Session::set_worst_io_latencies () -{ - DEBUG_TRACE (DEBUG::LatencyCompensation, "Session::set_worst_io_latencies\n"); - /* when this is called from the auto-connect thread, the process-lock is held */ - Glib::Threads::Mutex::Lock lx (_update_latency_lock); - set_worst_output_latency (); - set_worst_input_latency (); -} - void Session::set_worst_output_latency () { -- cgit v1.2.3