Fix missing thread-buffers when using region-compounds w/regionFx

When adding a region with regionFx to a compound,
AudioPlaylistSource::read_unlocked needs to be able
to process Fx. This can happen from various threads
(peak-file creation, waveform-rendering, peak-amplitude..) etc

depending on the plugin(s) in question, some process-thread
buffers are required, notably ProcessThread::get_silent_buffers
This commit is contained in:
Robin Gareus 2024-12-01 23:29:05 +01:00
parent 8a238de551
commit 388931293d
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
3 changed files with 24 additions and 3 deletions

View file

@ -2652,6 +2652,12 @@ AudioRegion::apply_region_fx (BufferSet& bufs, samplepos_t start_sample, samplep
return;
}
ProcessThread* pt = 0;
if (!ProcessThread::have_thread_buffers ()) {
pt = new ProcessThread ();
pt->get_buffers ();
}
pframes_t block_size = _session.get_block_size ();
if (_fx_block_size != block_size) {
_fx_block_size = block_size;
@ -2677,7 +2683,7 @@ AudioRegion::apply_region_fx (BufferSet& bufs, samplepos_t start_sample, samplep
lm.release ();
/* this triggers a re-read */
const_cast<AudioRegion*>(this)->remove_plugin (rfx);
return;
goto out;
}
remain -= run;
offset += run;
@ -2698,4 +2704,10 @@ AudioRegion::apply_region_fx (BufferSet& bufs, samplepos_t start_sample, samplep
}
_fx_pos = end_sample;
_fx_latent_read = false;
out:
if (pt) {
pt->drop_buffers ();
delete pt;
}
}

View file

@ -742,9 +742,12 @@ ARDOUR::init (bool try_optimization, const char* localedir, bool with_gui)
* each I/O thread (up to hardware_concurrency) and one for itself
* (butler's main thread).
*
* In theory (2 * hw + 4) should be sufficient, let's add one for luck.
* In theory (2 * hw + 4) should be sufficient, were it not for
* AudioPlaylistSource and AudioRegionEditor::peak_amplitude_thread(s).
* WaveViewThreads::start_threads adds `min (8, hw - 1)`
*
*/
BufferManager::init (hardware_concurrency () * 2 + 5);
BufferManager::init (hardware_concurrency () * 3 + 6);
PannerManager::instance ().discover_panners ();

View file

@ -3190,9 +3190,15 @@ Playlist::combine (const RegionList& rl, std::shared_ptr<Track>)
pair<timepos_t,timepos_t> extent = pl->get_extent();
timepos_t zero (_type == DataType::AUDIO ? Temporal::AudioTime : Temporal::BeatTime);
/* This may require regionFx processing, via AudioRegion::read_at */
ARDOUR::ProcessThread* pt = new ProcessThread ();
pt->get_buffers ();
for (uint32_t chn = 0; chn < channels; ++chn) {
sources.push_back (SourceFactory::createFromPlaylist (_type, _session, pl, id(), parent_name, chn, zero, extent.second, false, false));
}
pt->drop_buffers ();
delete pt;
/* now a new whole-file region using the list of sources */