summaryrefslogtreecommitdiff
path: root/libs/ardour/export_handler.cc
diff options
context:
space:
mode:
authorSakari Bergen <sakari.bergen@beatwaves.net>2013-03-17 12:32:48 +0200
committerSakari Bergen <sakari.bergen@beatwaves.net>2013-03-17 12:32:48 +0200
commit8cbb9727e959a744057de387a293aecdce09a62c (patch)
treec7f6fb66b7057dff243ee68364d6778941817a53 /libs/ardour/export_handler.cc
parent2d081e43e197851636c0da3ed46a7b0be97120b0 (diff)
Handle mutiple export files with the same extension but different format.
If multiple filenames have the same extension, append the format name to the filename. This still requires a bit of extra logic to be optimal, as the format name will now be added in some situations where it is not needed. However, this is better than producing a broken file...
Diffstat (limited to 'libs/ardour/export_handler.cc')
-rw-r--r--libs/ardour/export_handler.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc
index d93ec7779a..4a6b0552c5 100644
--- a/libs/ardour/export_handler.cc
+++ b/libs/ardour/export_handler.cc
@@ -171,6 +171,7 @@ ExportHandler::start_timespan ()
timespan_bounds = config_map.equal_range (current_timespan);
graph_builder->reset ();
graph_builder->set_current_timespan (current_timespan);
+ handle_duplicate_format_extensions();
for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) {
// Filenames can be shared across timespans
FileSpec & spec = it->second;
@@ -186,6 +187,27 @@ ExportHandler::start_timespan ()
session.start_audio_export (process_position);
}
+void
+ExportHandler::handle_duplicate_format_extensions()
+{
+ typedef std::map<std::string, int> ExtCountMap;
+
+ ExtCountMap counts;
+ for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) {
+ counts[it->second.format->extension()]++;
+ }
+
+ bool duplicates_found = false;
+ for (ExtCountMap::iterator it = counts.begin(); it != counts.end(); ++it) {
+ if (it->second > 1) { duplicates_found = true; }
+ }
+
+ // Set this always, as the filenames are shared...
+ for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) {
+ it->second.filename->include_format_name = duplicates_found;
+ }
+}
+
int
ExportHandler::process (framecnt_t frames)
{