mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
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...
This commit is contained in:
parent
2d081e43e1
commit
8cbb9727e9
7 changed files with 39 additions and 4 deletions
|
|
@ -92,6 +92,7 @@ class ExportFilename {
|
||||||
bool include_session;
|
bool include_session;
|
||||||
bool include_revision;
|
bool include_revision;
|
||||||
bool include_channel_config;
|
bool include_channel_config;
|
||||||
|
bool include_format_name;
|
||||||
bool include_channel;
|
bool include_channel;
|
||||||
bool include_timespan;
|
bool include_timespan;
|
||||||
bool include_time;
|
bool include_time;
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ class ExportFormatSpecification : public ExportFormatBase {
|
||||||
ExportFormatSpecification (Session & s, XMLNode const & state);
|
ExportFormatSpecification (Session & s, XMLNode const & state);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExportFormatSpecification (ExportFormatSpecification const & other);
|
ExportFormatSpecification (ExportFormatSpecification const & other, bool modify_name = true);
|
||||||
~ExportFormatSpecification ();
|
~ExportFormatSpecification ();
|
||||||
|
|
||||||
/* compatibility */
|
/* compatibility */
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ class ExportHandler : public ExportElementFactory
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void handle_duplicate_format_extensions();
|
||||||
int process (framecnt_t frames);
|
int process (framecnt_t frames);
|
||||||
|
|
||||||
Session & session;
|
Session & session;
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ ExportFilename::ExportFilename (Session & session) :
|
||||||
include_session (false),
|
include_session (false),
|
||||||
include_revision (false),
|
include_revision (false),
|
||||||
include_channel_config (false),
|
include_channel_config (false),
|
||||||
|
include_format_name (false),
|
||||||
include_channel (false),
|
include_channel (false),
|
||||||
include_timespan (true), // Include timespan name always
|
include_timespan (true), // Include timespan name always
|
||||||
include_time (false),
|
include_time (false),
|
||||||
|
|
@ -206,6 +207,12 @@ ExportFilename::get_path (ExportFormatSpecPtr format) const
|
||||||
filename_empty = false;
|
filename_empty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (include_format_name) {
|
||||||
|
path += filename_empty ? "" : "_";
|
||||||
|
path += format->name();
|
||||||
|
filename_empty = false;
|
||||||
|
}
|
||||||
|
|
||||||
path += ".";
|
path += ".";
|
||||||
path += format->extension ();
|
path += format->extension ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -189,13 +189,17 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s, XMLNode const
|
||||||
set_state (state);
|
set_state (state);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportFormatSpecification::ExportFormatSpecification (ExportFormatSpecification const & other)
|
ExportFormatSpecification::ExportFormatSpecification (ExportFormatSpecification const & other, bool modify_name)
|
||||||
: ExportFormatBase(other)
|
: ExportFormatBase(other)
|
||||||
, session (other.session)
|
, session (other.session)
|
||||||
, _silence_beginning (other.session)
|
, _silence_beginning (other.session)
|
||||||
, _silence_end (other.session)
|
, _silence_end (other.session)
|
||||||
{
|
{
|
||||||
|
if (modify_name) {
|
||||||
set_name (other.name() + " (copy)");
|
set_name (other.name() + " (copy)");
|
||||||
|
} else {
|
||||||
|
set_name (other.name());
|
||||||
|
}
|
||||||
|
|
||||||
_format_name = other._format_name;
|
_format_name = other._format_name;
|
||||||
has_sample_format = other.has_sample_format;
|
has_sample_format = other.has_sample_format;
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ ExportGraphBuilder::add_config (FileSpec const & config)
|
||||||
// If the sample rate is "session rate", change it to the real value.
|
// If the sample rate is "session rate", change it to the real value.
|
||||||
// However, we need to copy it to not change the config which is saved...
|
// However, we need to copy it to not change the config which is saved...
|
||||||
FileSpec new_config (config);
|
FileSpec new_config (config);
|
||||||
new_config.format.reset(new ExportFormatSpecification(*new_config.format));
|
new_config.format.reset(new ExportFormatSpecification(*new_config.format, false));
|
||||||
if(new_config.format->sample_rate() == ExportFormatBase::SR_Session) {
|
if(new_config.format->sample_rate() == ExportFormatBase::SR_Session) {
|
||||||
framecnt_t session_rate = session.nominal_frame_rate();
|
framecnt_t session_rate = session.nominal_frame_rate();
|
||||||
new_config.format->set_sample_rate(ExportFormatBase::nearest_sample_rate(session_rate));
|
new_config.format->set_sample_rate(ExportFormatBase::nearest_sample_rate(session_rate));
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,7 @@ ExportHandler::start_timespan ()
|
||||||
timespan_bounds = config_map.equal_range (current_timespan);
|
timespan_bounds = config_map.equal_range (current_timespan);
|
||||||
graph_builder->reset ();
|
graph_builder->reset ();
|
||||||
graph_builder->set_current_timespan (current_timespan);
|
graph_builder->set_current_timespan (current_timespan);
|
||||||
|
handle_duplicate_format_extensions();
|
||||||
for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) {
|
for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) {
|
||||||
// Filenames can be shared across timespans
|
// Filenames can be shared across timespans
|
||||||
FileSpec & spec = it->second;
|
FileSpec & spec = it->second;
|
||||||
|
|
@ -186,6 +187,27 @@ ExportHandler::start_timespan ()
|
||||||
session.start_audio_export (process_position);
|
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
|
int
|
||||||
ExportHandler::process (framecnt_t frames)
|
ExportHandler::process (framecnt_t frames)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue