From f81442c3bfd315d15b566ccc7a1f295b3fd5c235 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 29 Mar 2020 01:44:03 +0100 Subject: [PATCH] Engine: Silence outputs for 1/2 second when loading a session This allows for caches to warm up, background worker threads to spin up and things settle down. This also prevents initial audible artifacts of live input. In almost all cases this completes before the GUI is brought up. --- libs/ardour/audioengine.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index b82b9628f8..c525c33fd4 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -288,9 +288,12 @@ AudioEngine::process_callback (pframes_t nframes) --_init_countdown; /* Warm up caches */ PortManager::cycle_start (nframes); - PortManager::silence (nframes); _session->process (nframes); + PortManager::silence (nframes); PortManager::cycle_end (nframes); + if (_init_countdown == 0) { + _session->reset_xrun_count(); + } return 0; } @@ -723,7 +726,7 @@ AudioEngine::set_session (Session *s) SessionHandlePtr::set_session (s); if (_session) { - _init_countdown = 8; + _init_countdown = std::max (8, (int)(_backend->sample_rate () / _backend->buffer_size ()) / 2); } }