fix bypassing plugins with sidechain i/o
[ardour.git] / libs / ardour / export_filename.cc
index 0f8b4f4ee8cc9f96c322714e31eb5f13d808b2e9..efeb3398e52127ce412daf07ba6c9fe3fd6ef26a 100644 (file)
@@ -26,6 +26,7 @@
 #include "pbd/xml++.h"
 #include "pbd/convert.h"
 #include "pbd/enumwriter.h"
+#include "pbd/localtime_r.h"
 
 #include "ardour/libardour_visibility.h"
 #include "ardour/session.h"
@@ -55,14 +56,14 @@ ExportFilename::ExportFilename (Session & session) :
   include_timespan (true), // Include timespan name always
   include_time (false),
   include_date (false),
-  date_format (D_None),
-  time_format (T_None),
   session (session),
-  revision (1)
+  revision (1),
+  date_format (D_None),
+  time_format (T_None)
 {
        time_t rawtime;
        std::time (&rawtime);
-       time_struct = localtime (&rawtime);
+       localtime_r (&rawtime, &time_struct);
 
        folder = session.session_directory().export_path();
 
@@ -90,6 +91,7 @@ ExportFilename::get_state ()
 
        add_field (node, "label", include_label, label);
        add_field (node, "session", include_session);
+       add_field (node, "timespan", include_timespan);
        add_field (node, "revision", include_revision);
        add_field (node, "time", include_time, enum_2_string (time_format));
        add_field (node, "date", include_date, enum_2_string (date_format));
@@ -105,7 +107,7 @@ int
 ExportFilename::set_state (const XMLNode & node)
 {
        XMLNode * child;
-       XMLProperty * prop;
+       XMLProperty const * prop;
        FieldPair pair;
 
        child = node.child ("Folder");
@@ -128,7 +130,7 @@ ExportFilename::set_state (const XMLNode & node)
                        folder = tmp;
                }
        }
-       
+
        if (folder.empty()) {
                folder = session.session_directory().export_path();
        }
@@ -140,6 +142,9 @@ ExportFilename::set_state (const XMLNode & node)
        pair = get_field (node, "session");
        include_session = pair.first;
 
+       pair = get_field (node, "timespan");
+       include_timespan = pair.first;
+
        pair = get_field (node, "revision");
        include_revision = pair.first;
 
@@ -169,6 +174,18 @@ ExportFilename::get_path (ExportFormatSpecPtr format) const
 {
        string path;
        bool filename_empty = true;
+       bool with_timespan = include_timespan;
+
+       if (!include_session
+                       && !include_label
+                       && !include_revision
+                       && !include_timespan
+                       && !include_channel_config
+                       && !include_channel
+                       && !include_date
+                       && !include_format_name) {
+               with_timespan = true;
+       }
 
        if (include_session) {
                path += filename_empty ? "" : "_";
@@ -189,7 +206,7 @@ ExportFilename::get_path (ExportFormatSpecPtr format) const
                filename_empty = false;
        }
 
-       if (include_timespan && timespan) {
+       if (with_timespan && timespan) {
                path += filename_empty ? "" : "_";
                path += timespan->name();
                filename_empty = false;
@@ -226,6 +243,10 @@ ExportFilename::get_path (ExportFormatSpecPtr format) const
                filename_empty = false;
        }
 
+       if (path.empty ()) {
+               path = "export";
+       }
+
        path += ".";
        path += format->extension ();
 
@@ -319,7 +340,7 @@ string
 ExportFilename::get_formatted_time (string const & format) const
 {
        char buffer [80];
-       strftime (buffer, 80, format.c_str(), time_struct);
+       strftime (buffer, 80, format.c_str(), &time_struct);
 
        string return_value (buffer);
        return return_value;
@@ -351,7 +372,7 @@ ExportFilename::get_field (XMLNode const & node, string const & name)
        XMLNodeList children = node.children();
 
        for (XMLNodeList::iterator it = children.begin(); it != children.end(); ++it) {
-               XMLProperty * prop = (*it)->property ("name");
+               XMLProperty const * prop = (*it)->property ("name");
                if (prop && !prop->value().compare (name)) {
 
                        prop = (*it)->property ("enabled");