faderport: switch long-press mechanism to a timeout
[ardour.git] / libs / ardour / export_handler.cc
index bcc2783104d15c83d69accf52d3ab663364eb068..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 */
@@ -520,7 +522,10 @@ ExportHandler::get_cd_marker_filename(std::string filename, CDMarkerFormat forma
        case CDMarkerCUE:
                return filename + ".cue";
        case MP4Chaps:
-               return filename + ".chapters.txt";
+       {
+               unsigned lastdot = filename.find_last_of('.');
+               return filename.substr(0,lastdot) + ".chapters.txt";
+       }
        default:
                return filename + ".marker"; // Should not be reached when actually creating a file
        }
@@ -554,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) << "\" ";
@@ -588,7 +593,7 @@ ExportHandler::write_toc_header (CDMarkerStatus & status)
        string album_title  = SessionMetadata::Metadata()->album();
 
        if (barcode != "")
-               status.out << "CATALOG " << barcode << endl;
+               status.out << "CATALOG \"" << barcode << "\"" << endl;
 
        if (album_title != "")
                title = album_title;
@@ -596,7 +601,7 @@ ExportHandler::write_toc_header (CDMarkerStatus & status)
        status.out << "CD_DA" << endl;
        status.out << "CD_TEXT {" << endl << "  LANGUAGE_MAP {" << endl << "    0 : EN" << endl << "  }" << endl;
        status.out << "  LANGUAGE 0 {" << endl << "    TITLE " << toc_escape_cdtext (title) << endl ;
-       status.out << "    PERFORMER \"" << toc_escape_cdtext (album_artist) << "\"" << endl;
+       status.out << "    PERFORMER " << toc_escape_cdtext (album_artist) << endl;
        status.out << "  }" << endl << "}" << endl;
 }
 
@@ -678,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;
        }
@@ -806,7 +811,7 @@ ExportHandler::toc_escape_cdtext (const std::string& txt)
                        out += buf;
                }
        }
-       
+
        out += '"';
 
        return out;
@@ -831,7 +836,7 @@ ExportHandler::toc_escape_filename (const std::string& txt)
                        out += *c;
                }
        }
-       
+
        out += '"';
 
        return out;
@@ -842,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;