2 Copyright (C) 2008 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "pbd/gstdio_compat.h"
28 #include <glibmm/fileutils.h>
29 #include <glibmm/miscutils.h>
31 #include "pbd/enumwriter.h"
32 #include "pbd/enum_convert.h"
33 #include "pbd/xml++.h"
35 #include "ardour/export_profile_manager.h"
36 #include "ardour/export_format_specification.h"
37 #include "ardour/search_paths.h"
38 #include "ardour/export_timespan.h"
39 #include "ardour/export_channel_configuration.h"
40 #include "ardour/export_filename.h"
41 #include "ardour/export_preset.h"
42 #include "ardour/export_handler.h"
43 #include "ardour/export_failed.h"
44 #include "ardour/directory_names.h"
45 #include "ardour/filename_extensions.h"
46 #include "ardour/profile.h"
47 #include "ardour/route.h"
48 #include "ardour/session.h"
49 #include "ardour/broadcast_info.h"
54 DEFINE_ENUM_CONVERT(ARDOUR::ExportProfileManager::TimeFormat);
64 ExportProfileManager::ExportProfileManager (Session & s, ExportType type)
66 , handler (s.get_export_handler())
69 , ranges (new LocationList ())
70 , single_range_mode (false)
72 , format_list (new FormatList ())
76 xml_node_name = X_("ExportProfile");
79 xml_node_name = X_("RangeExportProfile");
82 xml_node_name = X_("SelectionExportProfile");
85 xml_node_name = X_("RegionExportProfile");
88 xml_node_name = X_("StemExportProfile");
92 /* Initialize path variables */
94 export_config_dir = Glib::build_filename (user_config_directory(), export_dir_name);
96 search_path += export_formats_search_path();
98 info << string_compose (_("Searching for export formats in %1"), search_path.to_string()) << endmsg;
100 /* create export config directory if necessary */
102 if (!Glib::file_test (export_config_dir, Glib::FILE_TEST_EXISTS)) {
103 if (g_mkdir_with_parents (export_config_dir.c_str(), 0755) != 0) {
104 error << string_compose (_("Unable to create export format directory %1: %2"), export_config_dir, g_strerror(errno)) << endmsg;
111 /* Initialize all lists with an empty config */
114 init_timespans (dummy);
115 init_channel_configs (dummy);
116 init_formats (dummy);
117 init_filenames (dummy);
120 ExportProfileManager::~ExportProfileManager ()
122 XMLNode * extra_xml (new XMLNode (xml_node_name));
123 serialize_profile (*extra_xml);
124 session.add_extra_xml (*extra_xml);
128 ExportProfileManager::load_profile ()
130 XMLNode * extra_node = session.extra_xml (xml_node_name);
131 /* Legacy sessions used Session instant.xml for this */
133 extra_node = session.instant_xml (xml_node_name);
137 set_state (*extra_node);
139 XMLNode empty_node (xml_node_name);
140 set_state (empty_node);
145 ExportProfileManager::prepare_for_export ()
147 TimespanListPtr ts_list = timespans.front()->timespans;
149 FormatStateList::const_iterator format_it;
150 FilenameStateList::const_iterator filename_it;
154 for (TimespanList::iterator ts_it = ts_list->begin(); ts_it != ts_list->end(); ++ts_it) {
155 // ..., each format-filename pair
156 for (format_it = formats.begin(), filename_it = filenames.begin();
157 format_it != formats.end() && filename_it != filenames.end();
158 ++format_it, ++filename_it) {
160 ExportFilenamePtr filename = (*filename_it)->filename;
161 // filename->include_timespan = (ts_list->size() > 1); Disabled for now...
163 boost::shared_ptr<BroadcastInfo> b;
164 if ((*format_it)->format->has_broadcast_info()) {
165 b.reset (new BroadcastInfo);
166 b->set_from_session (session, (*ts_it)->get_start());
169 // ...and each channel config
170 filename->include_channel_config = (_type == StemExport) ||
171 (channel_configs.size() > 1);
172 for(ChannelConfigStateList::iterator cc_it = channel_configs.begin(); cc_it != channel_configs.end(); ++cc_it) {
173 handler->add_export_config (*ts_it, (*cc_it)->config, (*format_it)->format, filename, b);
180 ExportProfileManager::load_preset (ExportPresetPtr preset)
184 current_preset = preset;
185 if (!preset) { return false; }
187 XMLNode const * state;
188 /* local state is saved in instant.xml and contains timespan
189 * and channel config for per session.
190 * It may not be present for a given preset/session combination
191 * and is never preset for system-wide presets, but that's OK.
193 if ((state = preset->get_local_state())) {
194 set_local_state (*state);
197 if ((state = preset->get_global_state())) {
198 if (!set_global_state (*state)) {
201 } else { ok = false; }
207 ExportProfileManager::load_presets ()
209 vector<std::string> found = find_file (string_compose (X_("*%1"),export_preset_suffix));
211 for (vector<std::string>::iterator it = found.begin(); it != found.end(); ++it) {
212 load_preset_from_disk (*it);
217 ExportProfileManager::preset_filename (std::string const & preset_name)
219 string safe_name = legalize_for_path (preset_name);
220 return Glib::build_filename (export_config_dir, safe_name + export_preset_suffix);
224 ExportProfileManager::new_preset (string const & name)
226 // Generate new ID and do regular save
227 string filename = preset_filename (name);
228 current_preset.reset (new ExportPreset (filename, session));
229 preset_list.push_back (current_preset);
230 return save_preset (name);
234 ExportProfileManager::save_preset (string const & name)
236 string filename = preset_filename (name);
238 if (!current_preset) {
239 current_preset.reset (new ExportPreset (filename, session));
240 preset_list.push_back (current_preset);
243 XMLNode * global_preset = new XMLNode ("ExportPreset");
244 XMLNode * local_preset = new XMLNode ("ExportPreset");
246 serialize_global_profile (*global_preset);
247 serialize_local_profile (*local_preset);
249 current_preset->set_name (name);
250 current_preset->set_global_state (*global_preset);
251 current_preset->set_local_state (*local_preset);
253 current_preset->save (filename);
255 return current_preset;
259 ExportProfileManager::remove_preset ()
261 if (!current_preset) { return; }
263 for (PresetList::iterator it = preset_list.begin(); it != preset_list.end(); ++it) {
264 if (*it == current_preset) {
265 preset_list.erase (it);
270 FileMap::iterator it = preset_file_map.find (current_preset->id());
271 if (it != preset_file_map.end()) {
272 if (g_remove (it->second.c_str()) != 0) {
273 error << string_compose (_("Unable to remove export preset %1: %2"), it->second, g_strerror(errno)) << endmsg;
275 preset_file_map.erase (it);
278 current_preset->remove_local();
279 current_preset.reset();
283 ExportProfileManager::load_preset_from_disk (std::string const & path)
285 ExportPresetPtr preset (new ExportPreset (path, session));
287 /* Handle id to filename mapping and don't add duplicates to list */
289 FilePair pair (preset->id(), path);
290 if (preset_file_map.insert (pair).second) {
291 preset_list.push_back (preset);
296 ExportProfileManager::set_state (XMLNode const & root)
298 return set_global_state (root) & set_local_state (root);
302 ExportProfileManager::set_global_state (XMLNode const & root)
304 return init_filenames (root.children ("ExportFilename")) &
305 init_formats (root.children ("ExportFormat"));
309 ExportProfileManager::set_local_state (XMLNode const & root)
311 return init_timespans (root.children ("ExportTimespan")) &
312 init_channel_configs (root.children ("ExportChannelConfiguration"));
316 ExportProfileManager::serialize_profile (XMLNode & root)
318 serialize_local_profile (root);
319 serialize_global_profile (root);
323 ExportProfileManager::serialize_global_profile (XMLNode & root)
325 for (FormatStateList::iterator it = formats.begin(); it != formats.end(); ++it) {
326 root.add_child_nocopy (serialize_format (*it));
329 for (FilenameStateList::iterator it = filenames.begin(); it != filenames.end(); ++it) {
330 root.add_child_nocopy ((*it)->filename->get_state());
335 ExportProfileManager::serialize_local_profile (XMLNode & root)
337 for (TimespanStateList::iterator it = timespans.begin(); it != timespans.end(); ++it) {
338 root.add_child_nocopy (serialize_timespan (*it));
341 for (ChannelConfigStateList::iterator it = channel_configs.begin(); it != channel_configs.end(); ++it) {
342 root.add_child_nocopy ((*it)->config->get_state());
346 std::vector<std::string>
347 ExportProfileManager::find_file (std::string const & pattern)
349 vector<std::string> found;
351 find_files_matching_pattern (found, search_path, pattern);
357 ExportProfileManager::set_selection_range (samplepos_t start, samplepos_t end)
361 selection_range.reset (new Location (session));
362 selection_range->set_name (_("Selection"));
363 selection_range->set (start, end);
365 selection_range.reset();
368 for (TimespanStateList::iterator it = timespans.begin(); it != timespans.end(); ++it) {
369 (*it)->selection_range = selection_range;
374 ExportProfileManager::set_single_range (samplepos_t start, samplepos_t end, string name)
376 single_range_mode = true;
378 single_range.reset (new Location (session));
379 single_range->set_name (name);
380 single_range->set (start, end);
384 return single_range->id().to_s();
388 ExportProfileManager::init_timespans (XMLNodeList nodes)
394 for (XMLNodeList::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
395 TimespanStatePtr span = deserialize_timespan (**it);
397 timespans.push_back (span);
398 } else { ok = false; }
401 if (timespans.empty()) {
402 TimespanStatePtr state (new TimespanState (selection_range, ranges));
403 timespans.push_back (state);
405 // Add session as default selection
406 Location * session_range;
408 if (Profile->get_trx()) {
409 session_range = (session.get_play_loop () ? session.locations()->auto_loop_location () : session.locations()->session_range_location());
411 session_range = session.locations()->session_range_location();
414 if (!session_range) { return false; }
416 ExportTimespanPtr timespan = handler->add_timespan();
417 timespan->set_name (session_range->name());
418 timespan->set_range_id (session_range->id().to_s());
419 timespan->set_range (session_range->start(), session_range->end());
420 state->timespans->push_back (timespan);
427 ExportProfileManager::TimespanStatePtr
428 ExportProfileManager::deserialize_timespan (XMLNode & root)
430 TimespanStatePtr state (new TimespanState (selection_range, ranges));
432 XMLNodeList spans = root.children ("Range");
433 for (XMLNodeList::iterator node_it = spans.begin(); node_it != spans.end(); ++node_it) {
436 if (!(*node_it)->get_property ("id", id)) {
440 Location * location = 0;
441 for (LocationList::iterator it = ranges->begin(); it != ranges->end(); ++it) {
442 if ((id == "selection" && *it == selection_range.get()) ||
443 (id == (*it)->id().to_s())) {
449 if (!location) { continue; }
451 ExportTimespanPtr timespan = handler->add_timespan();
452 timespan->set_name (location->name());
453 timespan->set_range_id (location->id().to_s());
454 timespan->set_range (location->start(), location->end());
455 state->timespans->push_back (timespan);
458 root.get_property ("format", state->time_format);
460 if (state->timespans->empty()) {
461 return TimespanStatePtr();
468 ExportProfileManager::serialize_timespan (TimespanStatePtr state)
470 XMLNode & root = *(new XMLNode ("ExportTimespan"));
474 for (TimespanList::iterator it = state->timespans->begin(); it != state->timespans->end(); ++it) {
475 if ((span = root.add_child ("Range"))) {
476 span->set_property ("id", (*it)->range_id());
480 root.set_property ("format", state->time_format);
486 ExportProfileManager::update_ranges () {
489 if (single_range_mode) {
490 ranges->push_back (single_range.get());
496 if (session.locations()->auto_loop_location ()) {
497 ranges->push_back (session.locations()->auto_loop_location ());
501 if (session.locations()->session_range_location()) {
502 ranges->push_back (session.locations()->session_range_location());
507 if (selection_range) {
508 ranges->push_back (selection_range.get());
513 LocationList const & list (session.locations()->list());
514 for (LocationList::const_iterator it = list.begin(); it != list.end(); ++it) {
515 if ((*it)->is_range_marker()) {
516 ranges->push_back (*it);
521 ExportProfileManager::ChannelConfigStatePtr
522 ExportProfileManager::add_channel_config ()
524 ChannelConfigStatePtr ptr(new ChannelConfigState(handler->add_channel_config()));
525 channel_configs.push_back(ptr);
530 ExportProfileManager::init_channel_configs (XMLNodeList nodes)
532 channel_configs.clear();
535 ChannelConfigStatePtr config (new ChannelConfigState (handler->add_channel_config()));
536 channel_configs.push_back (config);
538 // Add master outs as default
539 if (!session.master_out()) { return false; }
541 IO* master_out = session.master_out()->output().get();
542 if (!master_out) { return false; }
544 for (uint32_t n = 0; n < master_out->n_ports().n_audio(); ++n) {
545 PortExportChannel * channel = new PortExportChannel ();
546 channel->add_port (master_out->audio (n));
548 ExportChannelPtr chan_ptr (channel);
549 config->config->register_channel (chan_ptr);
554 for (XMLNodeList::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
555 ChannelConfigStatePtr config (new ChannelConfigState (handler->add_channel_config()));
556 config->config->set_state (**it);
557 channel_configs.push_back (config);
563 ExportProfileManager::FormatStatePtr
564 ExportProfileManager::duplicate_format_state (FormatStatePtr state)
566 /* Note: The pointer in the new FormatState should point to the same format spec
567 as the original state's pointer. The spec itself should not be copied! */
569 FormatStatePtr format (new FormatState (format_list, state->format));
570 formats.push_back (format);
575 ExportProfileManager::remove_format_state (FormatStatePtr state)
577 for (FormatStateList::iterator it = formats.begin(); it != formats.end(); ++it) {
586 ExportProfileManager::save_format_to_disk (ExportFormatSpecPtr format)
588 // TODO filename character stripping
590 /* Get filename for file */
592 string new_name = format->name();
593 new_name += export_format_suffix;
595 /* make sure its legal for the filesystem */
597 new_name = legalize_for_path (new_name);
599 std::string new_path = Glib::build_filename (export_config_dir, new_name);
601 /* Check if format is on disk already */
602 FileMap::iterator it;
603 if ((it = format_file_map.find (format->id())) != format_file_map.end()) {
605 /* Check if config is not in user config dir */
606 if (Glib::path_get_dirname (it->second) != export_config_dir) {
610 XMLTree tree (new_path);
611 tree.set_root (&format->get_state());
616 /* Update file and rename if necessary */
618 XMLTree tree (it->second);
619 tree.set_root (&format->get_state());
622 if (new_name != Glib::path_get_basename (it->second)) {
623 if (g_rename (it->second.c_str(), new_path.c_str()) != 0) {
624 error << string_compose (_("Unable to rename export format %1 to %2: %3"), it->second, new_path, g_strerror(errno)) << endmsg;
629 it->second = new_path;
634 XMLTree tree (new_path);
635 tree.set_root (&format->get_state());
643 ExportProfileManager::remove_format_profile (ExportFormatSpecPtr format)
645 for (FormatList::iterator it = format_list->begin(); it != format_list->end(); ++it) {
647 format_list->erase (it);
652 FileMap::iterator it = format_file_map.find (format->id());
653 if (it != format_file_map.end()) {
654 if (g_remove (it->second.c_str()) != 0) {
655 error << string_compose (_("Unable to remove export profile %1: %2"), it->second, g_strerror(errno)) << endmsg;
658 format_file_map.erase (it);
661 FormatListChanged ();
665 ExportProfileManager::revert_format_profile (ExportFormatSpecPtr format)
667 FileMap::iterator it;
668 if ((it = format_file_map.find (format->id())) == format_file_map.end()) {
673 if (!tree.read (it->second.c_str())) {
677 format->set_state (*tree.root());
678 FormatListChanged ();
682 ExportProfileManager::get_new_format (ExportFormatSpecPtr original)
684 ExportFormatSpecPtr format;
686 format.reset (new ExportFormatSpecification (*original));
687 std::cerr << "After new format created from original, format has id [" << format->id().to_s() << ']' << std::endl;
689 format = handler->add_format();
690 format->set_name (_("empty format"));
693 std::string path = save_format_to_disk (format);
694 FilePair pair (format->id(), path);
695 format_file_map.insert (pair);
697 format_list->push_back (format);
698 FormatListChanged ();
704 ExportProfileManager::init_formats (XMLNodeList nodes)
709 for (XMLNodeList::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
710 FormatStatePtr format = deserialize_format (**it);
712 formats.push_back (format);
713 } else { ok = false; }
716 if (formats.empty ()) {
717 FormatStatePtr format (new FormatState (format_list, ExportFormatSpecPtr ()));
718 formats.push_back (format);
725 ExportProfileManager::FormatStatePtr
726 ExportProfileManager::deserialize_format (XMLNode & root)
728 XMLProperty const * prop;
731 if ((prop = root.property ("id"))) {
735 for (FormatList::iterator it = format_list->begin(); it != format_list->end(); ++it) {
736 if ((*it)->id() == id) {
737 return FormatStatePtr (new FormatState (format_list, *it));
741 return FormatStatePtr ();
745 ExportProfileManager::serialize_format (FormatStatePtr state)
747 XMLNode * root = new XMLNode ("ExportFormat");
749 string id = state->format ? state->format->id().to_s() : "";
750 root->set_property ("id", id);
756 ExportProfileManager::load_formats ()
758 vector<std::string> found = find_file (string_compose ("*%1", export_format_suffix));
760 for (vector<std::string>::iterator it = found.begin(); it != found.end(); ++it) {
761 load_format_from_disk (*it);
766 ExportProfileManager::load_format_from_disk (std::string const & path)
770 if (!tree.read (path)) {
771 error << string_compose (_("Cannot load export format from %1"), path) << endmsg;
775 XMLNode* root = tree.root();
777 error << string_compose (_("Cannot export format read from %1"), path) << endmsg;
781 ExportFormatSpecPtr format = handler->add_format (*root);
783 if (format->format_id() == ExportFormatBase::F_FFMPEG) {
785 if (!ArdourVideoToolPaths::transcoder_exe (unused, unused)) {
786 error << string_compose (_("Ignored format '%1': encoder is not avilable"), path) << endmsg;
790 /* Handle id to filename mapping and don't add duplicates to list */
792 FilePair pair (format->id(), path);
793 if (format_file_map.insert (pair).second) {
794 format_list->push_back (format);
797 FormatListChanged ();
800 ExportProfileManager::FilenameStatePtr
801 ExportProfileManager::duplicate_filename_state (FilenameStatePtr state)
803 FilenameStatePtr filename (new FilenameState (handler->add_filename_copy (state->filename)));
804 filenames.push_back (filename);
809 ExportProfileManager::remove_filename_state (FilenameStatePtr state)
811 for (FilenameStateList::iterator it = filenames.begin(); it != filenames.end(); ++it) {
813 filenames.erase (it);
820 ExportProfileManager::get_sample_filename_for_format (ExportFilenamePtr filename, ExportFormatSpecPtr format)
824 if (channel_configs.empty()) { return ""; }
826 std::list<string> filenames;
827 build_filenames (filenames, filename, timespans.front()->timespans,
828 channel_configs.front()->config, format);
830 if (filenames.empty()) { return ""; }
831 return filenames.front();
835 ExportProfileManager::init_filenames (XMLNodeList nodes)
839 for (XMLNodeList::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
840 ExportFilenamePtr filename = handler->add_filename();
841 filename->set_state (**it);
842 filenames.push_back (FilenameStatePtr (new FilenameState (filename)));
845 if (filenames.empty()) {
846 FilenameStatePtr filename (new FilenameState (handler->add_filename()));
847 filenames.push_back (filename);
854 boost::shared_ptr<ExportProfileManager::Warnings>
855 ExportProfileManager::get_warnings ()
857 boost::shared_ptr<Warnings> warnings (new Warnings ());
859 ChannelConfigStatePtr channel_config_state;
860 if (!channel_configs.empty ()) {
861 channel_config_state = channel_configs.front();
864 TimespanStatePtr timespan_state = timespans.front();
866 /*** Check "global" config ***/
868 TimespanListPtr timespans = timespan_state->timespans;
870 ExportChannelConfigPtr channel_config;
871 if (channel_config_state) {
872 channel_config = channel_config_state->config;
875 /* Check Timespans are not empty */
877 if (timespans->empty()) {
878 warnings->errors.push_back (_("No timespan has been selected!"));
881 if (channel_config_state == 0) {
882 warnings->errors.push_back (_("No channels have been selected!"));
884 /* Check channel config ports */
885 if (!channel_config->all_channels_have_ports ()) {
886 warnings->warnings.push_back (_("Some channels are empty"));
890 /*** Check files ***/
892 bool folder_ok = true;
894 if (channel_config_state) {
895 FormatStateList::const_iterator format_it;
896 FilenameStateList::const_iterator filename_it;
897 for (format_it = formats.begin(), filename_it = filenames.begin();
898 format_it != formats.end() && filename_it != filenames.end();
899 ++format_it, ++filename_it) {
900 check_config (warnings, timespan_state, channel_config_state, *format_it, *filename_it);
902 if (!Glib::file_test ((*filename_it)->filename->get_folder(), Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
910 warnings->errors.push_back (_("Destination folder does not exist."));
917 ExportProfileManager::check_config (boost::shared_ptr<Warnings> warnings,
918 TimespanStatePtr timespan_state,
919 ChannelConfigStatePtr channel_config_state,
920 FormatStatePtr format_state, FilenameStatePtr filename_state)
922 TimespanListPtr timespans = timespan_state->timespans;
923 ExportChannelConfigPtr channel_config = channel_config_state->config;
924 ExportFormatSpecPtr format = format_state->format;
925 ExportFilenamePtr filename = filename_state->filename;
927 /* Check format and maximum channel count */
928 if (!format || !format->type()) {
929 warnings->errors.push_back (_("No format selected!"));
930 } else if (!channel_config->get_n_chans()) {
931 warnings->errors.push_back (_("All channels are empty!"));
932 } else if (!check_format (format, channel_config->get_n_chans())) {
933 warnings->errors.push_back (_("One or more of the selected formats is not compatible with this system!"));
934 } else if (format->channel_limit() < channel_config->get_n_chans()) {
935 warnings->errors.push_back
936 (string_compose (_("%1 supports only %2 channels, but you have %3 channels in your channel configuration"),
937 format->format_name(),
938 format->channel_limit(),
939 channel_config->get_n_chans()));
942 if (!warnings->errors.empty()) { return; }
944 /* Check filenames */
946 // filename->include_timespan = (timespans->size() > 1); Disabled for now...
948 std::list<string> paths;
949 build_filenames(paths, filename, timespans, channel_config, format);
951 for (std::list<string>::const_iterator path_it = paths.begin(); path_it != paths.end(); ++path_it) {
953 string path = *path_it;
955 if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
956 warnings->conflicting_filenames.push_back (path);
959 if (format->with_toc()) {
960 string marker_file = handler->get_cd_marker_filename(path, CDMarkerTOC);
961 if (Glib::file_test (marker_file, Glib::FILE_TEST_EXISTS)) {
962 warnings->conflicting_filenames.push_back (marker_file);
966 if (format->with_cue()) {
967 string marker_file = handler->get_cd_marker_filename(path, CDMarkerCUE);
968 if (Glib::file_test (marker_file, Glib::FILE_TEST_EXISTS)) {
969 warnings->conflicting_filenames.push_back (marker_file);
976 ExportProfileManager::check_format (ExportFormatSpecPtr format, uint32_t channels)
978 switch (format->type()) {
979 case ExportFormatBase::T_Sndfile:
980 return check_sndfile_format (format, channels);
981 case ExportFormatBase::T_FFMPEG:
985 throw ExportFailed (X_("Invalid format given for ExportFileFactory::check!"));
990 ExportProfileManager::check_sndfile_format (ExportFormatSpecPtr format, unsigned int channels)
993 sf_info.channels = channels;
994 sf_info.samplerate = format->sample_rate ();
995 sf_info.format = format->format_id () | format->sample_format ();
997 return (sf_format_check (&sf_info) == SF_TRUE ? true : false);
1001 ExportProfileManager::build_filenames(std::list<std::string> & result, ExportFilenamePtr filename,
1002 TimespanListPtr timespans, ExportChannelConfigPtr channel_config,
1003 ExportFormatSpecPtr format)
1005 for (std::list<ExportTimespanPtr>::iterator timespan_it = timespans->begin();
1006 timespan_it != timespans->end(); ++timespan_it) {
1007 filename->set_timespan (*timespan_it);
1009 if (channel_config->get_split()) {
1010 filename->include_channel = true;
1012 for (uint32_t chan = 1; chan <= channel_config->get_n_chans(); ++chan) {
1013 filename->set_channel (chan);
1014 result.push_back(filename->get_path (format));
1018 filename->include_channel = false;
1019 result.push_back(filename->get_path (format));
1024 }; // namespace ARDOUR