mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 00:04:56 +01:00
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:
parent
591c219349
commit
23baeee829
3 changed files with 18 additions and 4 deletions
|
|
@ -728,7 +728,7 @@ AudioEngine::set_session (Session *s)
|
||||||
SessionHandlePtr::set_session (s);
|
SessionHandlePtr::set_session (s);
|
||||||
|
|
||||||
if (_session) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2086,7 +2086,6 @@ AlsaAudioBackend::main_process_thread ()
|
||||||
double dll_w2 = dll_w1 * dll_w1;
|
double dll_w2 = dll_w1 * dll_w1;
|
||||||
|
|
||||||
uint64_t clock1;
|
uint64_t clock1;
|
||||||
_pcmi->pcm_start ();
|
|
||||||
int no_proc_errors = 0;
|
int no_proc_errors = 0;
|
||||||
const int bailout = 5 * _samplerate / _samples_per_period;
|
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;
|
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) {
|
while (_run) {
|
||||||
long nr;
|
long nr;
|
||||||
bool xrun = false;
|
bool xrun = false;
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ snd_pcm_sframes_t Alsa_pcmi::pcm_wait (void)
|
||||||
{
|
{
|
||||||
_state = -1;
|
_state = -1;
|
||||||
if (!recover ()) {
|
if (!recover ()) {
|
||||||
_state = 1;
|
_state = 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -239,7 +239,7 @@ snd_pcm_sframes_t Alsa_pcmi::pcm_wait (void)
|
||||||
{
|
{
|
||||||
_state = -1;
|
_state = -1;
|
||||||
if (!recover ()) {
|
if (!recover ()) {
|
||||||
_state = 1;
|
_state = 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue