From 0937c7cabe4ae973f429384f4e6f0eaf7eb64080 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 11 Mar 2022 04:19:15 +0100 Subject: [PATCH] Work-around emit Session::Exported signal for all exported files This will eventually have to be fixed, currently split-channel files are not correctly tagged and post process commands are only emitted for the last file. But fixing this is complicated, so meanwhile a workaround is used. Eventually this commit should be [mostly] reverted! --- libs/ardour/ardour/export_graph_builder.h | 10 ++++++++++ libs/ardour/export_graph_builder.cc | 5 ++++- libs/ardour/export_handler.cc | 17 +++++++++++++---- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/libs/ardour/ardour/export_graph_builder.h b/libs/ardour/ardour/export_graph_builder.h index 8fe3bb8a83..cab23362ed 100644 --- a/libs/ardour/ardour/export_graph_builder.h +++ b/libs/ardour/ardour/export_graph_builder.h @@ -83,12 +83,22 @@ class LIBARDOUR_API ExportGraphBuilder void add_config (FileSpec const & config, bool rt); void get_analysis_results (AnalysisResults& results); + std::vector exported_files () const { + return _exported_files; + } + private: void add_analyser (const std::string& fn, AnalysisPtr ap) { analysis_map.insert (std::make_pair (fn, ap)); } + void add_export_fn (std::string const& fn) { + _exported_files.push_back (fn); + } + + std::vector _exported_files; + void add_split_config (FileSpec const & config); class Encoder { diff --git a/libs/ardour/export_graph_builder.cc b/libs/ardour/export_graph_builder.cc index 2ab38cfbb0..94e73c72dc 100644 --- a/libs/ardour/export_graph_builder.cc +++ b/libs/ardour/export_graph_builder.cc @@ -140,6 +140,7 @@ ExportGraphBuilder::reset () channels.clear (); intermediates.clear (); analysis_map.clear(); + _exported_files.clear(); _realtime = false; _master_align = 0; } @@ -447,6 +448,9 @@ ExportGraphBuilder::SFC::SFC (ExportGraphBuilder &parent, FileSpec const & new_c boost::shared_ptr > intermediate = limiter; + config.filename->set_channel_config (config.channel_config); + parent.add_export_fn (config.filename->get_path (config.format)); + if (_analyse) { samplecnt_t sample_rate = parent.session.nominal_sample_rate(); samplecnt_t sb = config.format->silence_beginning_at (parent.timespan->get_start(), sample_rate); @@ -460,7 +464,6 @@ ExportGraphBuilder::SFC::SFC (ExportGraphBuilder &parent, FileSpec const & new_c 800 * ui_scale_factor, 200 * ui_scale_factor )); - config.filename->set_channel_config (config.channel_config); parent.add_analyser (config.filename->get_path (config.format), analyser); limiter->set_result (analyser->result (true)); diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index f4a54391ee..6537f0ef91 100644 --- a/libs/ardour/export_handler.cc +++ b/libs/ardour/export_handler.cc @@ -371,14 +371,25 @@ ExportHandler::finish_timespan () { graph_builder->get_analysis_results (export_status->result_map); + /* work-around: split-channel will produce several files + * for a single config, config_map iterator below does not yet + * take that into account. + */ + for (auto const& f : graph_builder->exported_files ()) { + Session::Exported (current_timespan->name(), f); /* EMIT SIGNAL */ + } + while (config_map.begin() != timespan_bounds.second) { // XXX single timespan+format may produce multiple files // e.g export selection == session // -> TagLib::FileRef is null - ExportFormatSpecPtr fmt = config_map.begin()->second.format; - std::string filename = config_map.begin()->second.filename->get_path(fmt); + FileSpec& config = config_map.begin()->second; + ExportFormatSpecPtr fmt = config.format; + config.filename->set_channel_config (config.channel_config); + std::string filename = config.filename->get_path (fmt); + if (fmt->with_cue()) { export_cd_marker_file (current_timespan, fmt, filename, CDMarkerCUE); } @@ -391,8 +402,6 @@ ExportHandler::finish_timespan () export_cd_marker_file (current_timespan, fmt, filename, MP4Chaps); } - Session::Exported (current_timespan->name(), filename); /* EMIT SIGNAL */ - /* close file first, otherwise TagLib enounters an ERROR_SHARING_VIOLATION * The process cannot access the file because it is being used. * ditto for post-export and upload.