faderport: switch long-press mechanism to a timeout
[ardour.git] / libs / ardour / export_handler.cc
index e755d9b70b2e772b2e6f26838fad5738eaae1363..f53f270918fba0c572b912331f73d6ecf25f1dc2 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "ardour/export_handler.h"
 
-#include <glib/gstdio.h>
+#include "pbd/gstdio_compat.h"
 #include <glibmm.h>
 #include <glibmm/convert.h>
 
@@ -118,7 +118,7 @@ ExportHandler::ExportHandler (Session & session)
 
 ExportHandler::~ExportHandler ()
 {
-       // TODO remove files that were written but not finished
+       graph_builder->cleanup (export_status->aborted () );
 }
 
 /** Add an export to the `to-do' list */
@@ -168,7 +168,7 @@ ExportHandler::start_timespan ()
           this is the timespan to do this time
        */
        current_timespan = config_map.begin()->first;
-       
+
        export_status->total_frames_current_timespan = current_timespan->get_length();
        export_status->timespan_name = current_timespan->name();
        export_status->processed_frames_current_timespan = 0;
@@ -310,6 +310,13 @@ ExportHandler::finish_timespan ()
                }
 
                if (fmt->tag()) {
+                       /* close file first, otherwise TagLib enounters an ERROR_SHARING_VIOLATION
+                        * The process cannot access the file because it is being used.
+                        *
+                        * TODO: check Umlauts and encoding in filename.
+                        * TagLib eventually calls CreateFileA(),
+                        */
+                       graph_builder->reset ();
                        AudiofileTagger::tag_file(filename, *SessionMetadata::Metadata());
                }
 
@@ -418,11 +425,6 @@ ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSp
 
                CDMarkerStatus status (filepath, timespan, file_format, filename);
 
-               if (!status.out) {
-                       error << string_compose(_("Editor: cannot open \"%1\" as export file for CD marker file"), filepath) << endmsg;
-                       return;
-               }
-
                (this->*header_func) (status);
 
                /* Get locations and sort */
@@ -557,8 +559,8 @@ ExportHandler::write_cue_header (CDMarkerStatus & status)
                BINARY   = "header-less" audio (44.1 kHz, 16 Bit, little endian),
                MOTOROLA = "header-less" audio (44.1 kHz, 16 Bit, big endian),
                and MP3
-               
-               We try to use these file types whenever appropriate and 
+
+               We try to use these file types whenever appropriate and
                default to our own names otherwise.
        */
        status.out << "FILE \"" << Glib::path_get_basename(status.filename) << "\" ";
@@ -681,14 +683,14 @@ ExportHandler::write_track_info_toc (CDMarkerStatus & status)
 
        status.out << "CD_TEXT {" << endl << "  LANGUAGE 0 {" << endl;
        status.out << "     TITLE " << toc_escape_cdtext (status.marker->name()) << endl;
-       
+
        status.out << "     PERFORMER ";
        if (status.marker->cd_info.find("performer") != status.marker->cd_info.end()) {
                status.out << toc_escape_cdtext (status.marker->cd_info["performer"]) << endl;
        } else {
                status.out << "\"\"" << endl;
        }
-       
+
        if (status.marker->cd_info.find("composer") != status.marker->cd_info.end()) {
                status.out  << "     SONGWRITER " << toc_escape_cdtext (status.marker->cd_info["composer"]) << endl;
        }
@@ -809,7 +811,7 @@ ExportHandler::toc_escape_cdtext (const std::string& txt)
                        out += buf;
                }
        }
-       
+
        out += '"';
 
        return out;
@@ -834,7 +836,7 @@ ExportHandler::toc_escape_filename (const std::string& txt)
                        out += *c;
                }
        }
-       
+
        out += '"';
 
        return out;
@@ -845,15 +847,15 @@ ExportHandler::cue_escape_cdtext (const std::string& txt)
 {
        std::string latin1_txt;
        std::string out;
-       
+
        try {
                latin1_txt = Glib::convert (txt, "ISO-8859-1", "UTF-8");
        } catch (Glib::ConvertError& err) {
                throw Glib::ConvertError (err.code(), string_compose (_("Cannot convert %1 to Latin-1 text"), txt));
        }
-       
+
        // does not do much mor than UTF-8 to Latin1 translation yet, but
-       // that may have to change if cue parsers in burning programs change 
+       // that may have to change if cue parsers in burning programs change
        out = '"' + latin1_txt + '"';
 
        return out;