use pbd's gstdio compatibility wrapper
[ardour.git] / libs / ardour / export_handler.cc
index 33e19d663f90777bcb41443e881b23b9e060623a..0def821ef623b5bb874268a74c40098cf96b9940 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 */
@@ -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());
                }
 
@@ -520,7 +527,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
        }
@@ -588,7 +598,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,13 +606,14 @@ 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;
 }
 
 void
 ExportHandler::write_mp4ch_header (CDMarkerStatus & status)
 {
+       status.out << "00:00:00.000 Intro" << endl;
 }
 
 void