From ebc887e33dcb78b78932b06c63754e85154190be Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 7 Dec 2023 22:45:30 +0100 Subject: [PATCH] Continue export-roll to flush buffers This is required when using plugins to write data. --- libs/ardour/export_handler.cc | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index 40a9e29da9..2ccda2aaa8 100644 --- a/libs/ardour/export_handler.cc +++ b/libs/ardour/export_handler.cc @@ -295,11 +295,31 @@ ExportHandler::process_timespan (samplecnt_t samples) samplecnt_t samples_to_read = 0; samplepos_t const end = current_timespan->get_end(); + if (process_position >= end) { + /* export complete, post-roll to feed and flush latent plugins + * (This is mainly neede for Vapor) */ + if (process_position + samples < end + session.worst_latency_preroll ()) { + process_position += samples; + return 0; + } + + export_status->stop = true; + + /* Start post-processing/normalizing if necessary */ + post_processing = graph_builder->need_postprocessing (); + if (post_processing) { + export_status->total_postprocessing_cycles = graph_builder->get_postprocessing_cycle_count(); + export_status->current_postprocessing_cycle = 0; + } else { + finish_timespan (); + } + return 1; /* trigger realtime_stop() */ + } + bool const last_cycle = (process_position + samples >= end); if (last_cycle) { samples_to_read = end - process_position; - export_status->stop = true; } else { samples_to_read = samples; } @@ -312,18 +332,6 @@ ExportHandler::process_timespan (samplecnt_t samples) export_status->processed_samples_current_timespan += ret; } - /* Start post-processing/normalizing if necessary */ - if (last_cycle) { - post_processing = graph_builder->need_postprocessing (); - if (post_processing) { - export_status->total_postprocessing_cycles = graph_builder->get_postprocessing_cycle_count(); - export_status->current_postprocessing_cycle = 0; - } else { - finish_timespan (); - } - return 1; /* trigger realtime_stop() */ - } - return 0; }