diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 90364e13ac..80ba4d405b 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -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(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; + } } diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 4c0abd5720..65af635a14 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -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 (); diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 517a0e9296..e5ca961e67 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -3190,9 +3190,15 @@ Playlist::combine (const RegionList& rl, std::shared_ptr) pair 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 */