13
0

Tweak engine startup, initial silence

This can help when running with very low latency and the
initial process callback is [indirectly] expensive.

E.g. load a heavy session the a RPi4, initial setup can pull
in a lot of data, which blocks the bus.

In particular with the ALSA backend this can lead to poll timeout
which effectively stops the backend.
This commit is contained in:
Robin Gareus 2020-03-30 06:14:41 +02:00
parent 591c219349
commit 23baeee829
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 18 additions and 4 deletions

View File

@ -728,7 +728,7 @@ AudioEngine::set_session (Session *s)
SessionHandlePtr::set_session (s);
if (_session) {
_init_countdown = std::max (8, (int)(_backend->sample_rate () / _backend->buffer_size ()) / 2);
_init_countdown = std::max (8, (int)(_backend->sample_rate () / _backend->buffer_size ()) / 4);
}
}

View File

@ -2086,7 +2086,6 @@ AlsaAudioBackend::main_process_thread ()
double dll_w2 = dll_w1 * dll_w1;
uint64_t clock1;
_pcmi->pcm_start ();
int no_proc_errors = 0;
const int bailout = 5 * _samplerate / _samples_per_period;
@ -2095,6 +2094,21 @@ AlsaAudioBackend::main_process_thread ()
const double sr_norm = 1e-6 * (double) _samplerate / (double)_samples_per_period;
/* warm up */
int cnt = std::max (8, (int)(_samplerate / _samples_per_period) / 2);
for (int w = 0; w < cnt; ++w) {
for (std::vector<AlsaPort*>::const_iterator it = _system_inputs.begin (); it != _system_inputs.end (); ++it) {
memset ((*it)->get_buffer (_samples_per_period), 0, _samples_per_period * sizeof (Sample));
}
if (engine.process_callback (_samples_per_period)) {
_active = false;
return 0;
}
Glib::usleep (1000000 * (_samples_per_period / _samplerate ));
}
_pcmi->pcm_start ();
while (_run) {
long nr;
bool xrun = false;