13
0

Address rare race condition when creating sidechain inputs

Do not run the sidechaing processor before the processor
was configured. This ensure that Route::configure_processors()
has completed and ensure_buffers() was called.

Otherwise it may happen Sidechain::run could request a buffer
that is n/a (BufferSet::get_available assertion, see also 687149d8d2)
This commit is contained in:
Robin Gareus 2022-01-22 19:26:27 +01:00
parent 0e6561b009
commit f9f3f598c4
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 10 additions and 5 deletions

View File

@ -243,7 +243,14 @@ PluginInsert::set_preset_out (const ChanCount& c)
bool bool
PluginInsert::add_sidechain (uint32_t n_audio, uint32_t n_midi) PluginInsert::add_sidechain (uint32_t n_audio, uint32_t n_midi)
{ {
// caller must hold process lock /* Caller must not hold process lock, since add_port() takes the lock.
*
* Since the SC adds a port, an additional buffer may be needed.
* So Route::configure_processors() has to be called to set
* processor_max_streams -> _session.ensure_buffers ().
* SideChain::run () will do nothing before
* _sidechain->configure_io () is called.
*/
if (_sidechain) { if (_sidechain) {
return false; return false;
} }
@ -255,8 +262,7 @@ PluginInsert::add_sidechain (uint32_t n_audio, uint32_t n_midi)
} else { } else {
n << "toBeRenamed" << id().to_s(); n << "toBeRenamed" << id().to_s();
} }
SideChain *sc = new SideChain (_session, n.str ()); _sidechain.reset (new SideChain (_session, n.str ()));
_sidechain = boost::shared_ptr<SideChain> (sc);
_sidechain->activate (); _sidechain->activate ();
for (uint32_t n = 0; n < n_audio; ++n) { for (uint32_t n = 0; n < n_audio; ++n) {
_sidechain->input()->add_port ("", owner(), DataType::AUDIO); // add a port, don't connect. _sidechain->input()->add_port ("", owner(), DataType::AUDIO); // add a port, don't connect.

View File

@ -63,8 +63,7 @@ SideChain::set_state (const XMLNode& node, int version)
void void
SideChain::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double /*speed*/, pframes_t nframes, bool) SideChain::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double /*speed*/, pframes_t nframes, bool)
{ {
if (_input->n_ports () == ChanCount::ZERO) { if (_input->n_ports () == ChanCount::ZERO || !_configured) {
// inplace pass-through
return; return;
} }