restore ability to create TOC and CUE files during export. this is an option in a...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 18 Jan 2012 21:56:06 +0000 (21:56 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 18 Jan 2012 21:56:06 +0000 (21:56 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11266 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/export_format_dialog.cc
gtk2_ardour/export_format_dialog.h
libs/ardour/ardour/export_format_manager.h
libs/ardour/ardour/export_format_specification.h
libs/ardour/export_format_manager.cc
libs/ardour/export_format_specification.cc
libs/ardour/export_handler.cc
libs/ardour/session_export.cc
libs/ardour/utils.cc

index 1a8ecf8ffab44dcee21893a0956ece5cbf148041..68c3f3c41f900b877c68da8bf39523820d7c440b 100644 (file)
@@ -64,6 +64,9 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
   sample_format_label (_("Sample Format"), Gtk::ALIGN_LEFT),
   dither_label (_("Dithering"), Gtk::ALIGN_LEFT),
 
+  with_cue (_("Create CUE file for disk-at-once CD/DVD creation")),
+  with_toc (_("Create TOC file for disk-at-once CD/DVD creation")),
+
   tag_checkbox (_("Tag file with session's metadata"))
 {
 
@@ -73,6 +76,7 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
        get_vbox()->pack_start (silence_table, false, false, 6);
        get_vbox()->pack_start (format_table, false, false, 6);
        get_vbox()->pack_start (encoding_options_vbox, false, false, 0);
+       get_vbox()->pack_start (cue_toc_vbox, false, false, 0);
 
        /* Name, new and remove */
 
@@ -129,6 +133,12 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
        close_button->signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatDialog::end_dialog));
        manager.CompleteChanged.connect (*this, invalidator (*this), ui_bind (&Gtk::Button::set_sensitive, close_button, _1), gui_context());
 
+       with_cue.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_cue));
+       with_toc.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_toc));
+
+       cue_toc_vbox.pack_start (with_cue, false, false);
+       cue_toc_vbox.pack_start (with_toc, false, false);
+
        /* Load state before hooking up the rest of the signals */
 
        load_state (format);
@@ -234,6 +244,9 @@ ExportFormatDialog::load_state (FormatPtr spec)
        silence_end = spec->silence_end_time();
        silence_end_checkbox.set_active (spec->silence_end_time().not_zero());
 
+       with_cue.set_active (spec->with_cue());
+       with_toc.set_active (spec->with_toc());
+
        for (Gtk::ListStore::Children::iterator it = src_quality_list->children().begin(); it != src_quality_list->children().end(); ++it) {
                if (it->get_value (src_quality_cols.id) == spec->src_quality()) {
                        src_quality_combo.set_active (it);
@@ -685,6 +698,18 @@ ExportFormatDialog::change_compatibility (bool compatibility, boost::weak_ptr<T>
        }
 }
 
+void
+ExportFormatDialog::update_with_cue ()
+{
+       manager.select_with_cue (with_cue.get_active());
+}
+
+void
+ExportFormatDialog::update_with_toc ()
+{
+       manager.select_with_toc (with_toc.get_active());
+}
+
 void
 ExportFormatDialog::update_name ()
 {
index 0371b775440a807b87557b219fa835e68961ce64..9e395da01d46d787fd4866e384167e10419a6576 100644 (file)
@@ -297,6 +297,14 @@ class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList
        Gtk::Label  sample_format_label;
        Gtk::Label  dither_label;
 
+       Gtk::CheckButton with_cue;
+       Gtk::CheckButton with_toc;
+
+       Gtk::VBox cue_toc_vbox;
+
+       void update_with_toc ();
+       void update_with_cue ();
+
        Gtk::TreeView sample_format_view;
        Gtk::TreeView dither_type_view;
 
index 019a986f350c3fd6ac00b9e471d10f890f1da32b..33a55532033192171b6aeb4d66ca1bdcc45d4e37 100644 (file)
@@ -97,6 +97,8 @@ class ExportFormatManager : public PBD::ScopedConnectionList
 
        void set_name (std::string name);
 
+       void select_with_cue (bool);
+       void select_with_toc (bool);
        void select_src_quality (ExportFormatBase::SRCQuality value);
        void select_trim_beginning (bool value);
        void select_silence_beginning (AnyTime const & time);
index 7afb0bc73492f4f37fd48d19026abf6c4df7bd1d..4bf3ed40133a8749ebf43594c2ef6164c193a634 100644 (file)
@@ -93,6 +93,8 @@ class ExportFormatSpecification : public ExportFormatBase {
        void set_normalize_target (float value) { _normalize_target = value; }
 
        void set_tag (bool tag_it) { _tag = tag_it; }
+       void set_with_cue (bool yn) { _with_cue = yn; }
+       void set_with_toc (bool yn) { _with_toc = yn; }
 
        void set_silence_beginning (AnyTime const & value) { _silence_beginning = value; }
        void set_silence_end (AnyTime const & value) { _silence_end = value; }
@@ -120,6 +122,8 @@ class ExportFormatSpecification : public ExportFormatBase {
        bool trim_end () const { return _trim_end; }
        bool normalize () const { return _normalize; }
        float normalize_target () const { return _normalize_target; }
+       bool with_toc() const { return _with_toc; }
+       bool with_cue() const { return _with_cue; }
 
        bool tag () const { return _tag && supports_tagging; }
 
@@ -167,6 +171,8 @@ class ExportFormatSpecification : public ExportFormatBase {
 
        bool            _normalize;
        float           _normalize_target;
+       bool            _with_toc;
+       bool            _with_cue;
 
        /* serialization helpers */
 
index c77e301a23a4238985a57ffec5135151e514b4e6..f995bc1b0e87991ccc87d4d517dba9f567b079a9 100644 (file)
@@ -264,6 +264,18 @@ ExportFormatManager::select_src_quality (ExportFormatBase::SRCQuality value)
        current_selection->set_src_quality (value);
 }
 
+void
+ExportFormatManager::select_with_cue (bool value)
+{
+       current_selection->set_with_cue (value);
+}
+
+void
+ExportFormatManager::select_with_toc (bool value)
+{
+       current_selection->set_with_toc (value);
+}
+
 void
 ExportFormatManager::select_trim_beginning (bool value)
 {
index 619c50b9f98f33a10302403094b9b7329a8f6495..6fad14d86a15b58ccb6d3cd56be99eaa836c2462 100644 (file)
@@ -167,6 +167,8 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s)
 
        , _normalize (false)
        , _normalize_target (1.0)
+       , _with_toc (false)
+       , _with_cue (false)
 {
        format_ids.insert (F_None);
        endiannesses.insert (E_FileDefault);
@@ -235,6 +237,8 @@ ExportFormatSpecification::get_state ()
 
        root->add_property ("name", _name);
        root->add_property ("id", _id.to_s());
+       root->add_property ("with-cue", _with_cue ? "true" : "false");
+       root->add_property ("with-toc", _with_toc ? "true" : "false");
 
        node = root->add_child ("Encoding");
        node->add_property ("id", enum_2_string (format_id()));
@@ -300,6 +304,18 @@ ExportFormatSpecification::set_state (const XMLNode & root)
                _id = prop->value();
        }
 
+       if ((prop = root.property ("with-cue"))) {
+               _with_cue = string_is_affirmative (prop->value());
+       } else {
+               _with_cue = false;
+       }
+       
+       if ((prop = root.property ("with-toc"))) {
+               _with_toc = string_is_affirmative (prop->value());
+       } else {
+               _with_toc = false;
+       }
+       
        /* Encoding and SRC */
 
        if ((child = root.child ("Encoding"))) {
@@ -320,7 +336,11 @@ ExportFormatSpecification::set_state (const XMLNode & root)
                }
 
                if ((prop = child->property ("has-sample-format"))) {
-                       has_sample_format = !prop->value().compare ("true");
+                       has_sample_format = string_is_affirmative (prop->value());
+               }
+
+               if ((prop = child->property ("has-sample-format"))) {
+                       has_sample_format = string_is_affirmative (prop->value());
                }
 
                if ((prop = child->property ("channel-limit"))) {
index 91b3429bff34bf01390156ed0b01f479362a56f1..f19dfe048cec4b7a75b2b7f6871f24e4008a5811 100644 (file)
@@ -237,6 +237,17 @@ void
 ExportHandler::finish_timespan ()
 {
        while (config_map.begin() != timespan_bounds.second) {
+
+               ExportFormatSpecPtr fmt = config_map.begin()->second.format;
+
+               if (fmt->with_cue()) {
+                       export_cd_marker_file (current_timespan, fmt, config_map.begin()->second.filename->get_path(fmt), CDMarkerCUE);
+               } 
+
+               if (fmt->with_toc()) {
+                       export_cd_marker_file (current_timespan, fmt, config_map.begin()->second.filename->get_path(fmt), CDMarkerTOC);
+               }
+
                config_map.erase (config_map.begin());
        }
 
@@ -256,12 +267,11 @@ ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSp
                                       std::string filename, CDMarkerFormat format)
 {
        string filepath;
-       string basename = Glib::path_get_basename(filename);
 
-       size_t ext_pos = basename.rfind('.');
-       if (ext_pos != string::npos) {
-               basename = basename.substr(0, ext_pos); /* strip file extension, if there is one */
-       }
+       /* do not strip file suffix because there may be more than one format, 
+          and we do not want the CD marker file from one format to overwrite
+          another (e.g. foo.wav.cue > foo.aiff.cue)
+       */
 
        void (ExportHandler::*header_func) (CDMarkerStatus &);
        void (ExportHandler::*track_func) (CDMarkerStatus &);
@@ -269,13 +279,15 @@ ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSp
 
        switch (format) {
          case CDMarkerTOC:
-               filepath = Glib::build_filename(Glib::path_get_dirname(filename), basename + ".toc");
+               filepath = filename;
+               filepath += ".toc";
                header_func = &ExportHandler::write_toc_header;
                track_func = &ExportHandler::write_track_info_toc;
                index_func = &ExportHandler::write_index_info_toc;
                break;
          case CDMarkerCUE:
-               filepath = Glib::build_filename(Glib::path_get_dirname(filename), basename + ".cue");
+               filepath = filename;
+               filepath += ".cue";
                header_func = &ExportHandler::write_cue_header;
                track_func = &ExportHandler::write_track_info_cue;
                index_func = &ExportHandler::write_index_info_cue;
index 7737e952796a8735ff89260fe12f81260ed159da..4f46535a978e88429c8e350a8da13afb1eb1d162 100644 (file)
@@ -178,7 +178,7 @@ Session::process_export (pframes_t nframes)
                ProcessExport (nframes);
 
        } catch (std::exception & e) {
-               std::cout << e.what() << std::endl;
+               error << string_compose (_("Export ended unexpectedly: %1"), e.what()) << endmsg;
                export_status->abort (true);
        }
 }
@@ -222,6 +222,9 @@ Session::finalize_audio_export ()
 
        _engine.freewheel (false);
        export_freewheel_connection.disconnect();
+       
+       /* maybe write CUE/TOC */
+
        export_handler.reset();
        export_status.reset();
 
index cc02386bf455af5261f68ac8878feaf5d0a667e1..1c52a6f6384e49141186c2a5369f01b6ec12fb78 100644 (file)
@@ -643,7 +643,8 @@ string_is_affirmative (const std::string& str)
         * in the way we desire when doing it in C.
         */
 
-       return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length()));
+       return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length())) ||
+               (!g_strncasecmp(str.c_str(), "true", str.length()));
 }
 
 const char*