diff options
author | GZharun <grygoriiz@wavesglobal.com> | 2015-01-15 13:47:06 +0200 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-06-29 14:18:11 -0400 |
commit | ae8c494c026a6ce221d5f2cd28fc2df9d44e0893 (patch) | |
tree | 729d83bb0168bad27454918132377a5066e87a6f /libs/ardour/export_graph_builder.cc | |
parent | f9aeb659ee2416ddf365f7e1652c3db6f0a4e427 (diff) |
[Summary] Added export cleanup
[Reviewed by] Andriy Mishyn
Diffstat (limited to 'libs/ardour/export_graph_builder.cc')
-rw-r--r-- | libs/ardour/export_graph_builder.cc | 115 |
1 files changed, 112 insertions, 3 deletions
diff --git a/libs/ardour/export_graph_builder.cc b/libs/ardour/export_graph_builder.cc index 5e8c052b63..a217db6a2c 100644 --- a/libs/ardour/export_graph_builder.cc +++ b/libs/ardour/export_graph_builder.cc @@ -113,6 +113,17 @@ ExportGraphBuilder::reset () } void +ExportGraphBuilder::cleanup (bool remove_out_files/*=false*/) +{ + ChannelConfigList::iterator iter = channel_configs.begin(); + + while (iter != channel_configs.end() ) { + iter->remove_children(remove_out_files); + iter = channel_configs.erase(iter); + } +} + +void ExportGraphBuilder::set_current_timespan (boost::shared_ptr<ExportTimespan> span) { timespan = span; @@ -175,7 +186,7 @@ ExportGraphBuilder::add_split_config (FileSpec const & config) // No duplicate channel config found, create new one channel_configs.push_back (new ChannelConfig (*this, config, channels)); } - + /* Encoder */ template <> @@ -210,6 +221,33 @@ ExportGraphBuilder::Encoder::add_child (FileSpec const & new_config) { filenames.push_back (new_config.filename); } + +void +ExportGraphBuilder::Encoder::destroy_writer (bool delete_out_file) +{ + if (delete_out_file ) { + + if (float_writer) { + float_writer->close (); + } + + if (int_writer) { + int_writer->close (); + } + + if (short_writer) { + short_writer->close (); + } + + if (std::remove(writer_filename.c_str() ) != 0) { + std::cout << "Encoder::destroy_writer () : Error removing file: " << strerror(errno) << std::endl; + } + } + + float_writer.reset (); + int_writer.reset (); + short_writer.reset (); +} bool ExportGraphBuilder::Encoder::operator== (FileSpec const & other_config) const @@ -231,9 +269,9 @@ ExportGraphBuilder::Encoder::init_writer (boost::shared_ptr<AudioGrapher::Sndfil unsigned channels = config.channel_config->get_n_chans(); int format = get_real_format (config); config.filename->set_channel_config(config.channel_config); - string filename = config.filename->get_path (config.format); + writer_filename = config.filename->get_path (config.format); - writer.reset (new AudioGrapher::SndfileWriter<T> (filename, format, channels, config.format->sample_rate(), config.broadcast_info)); + writer.reset (new AudioGrapher::SndfileWriter<T> (writer_filename, format, channels, config.format->sample_rate(), config.broadcast_info)); writer->FileWritten.connect_same_thread (copy_files_connection, boost::bind (&ExportGraphBuilder::Encoder::copy_files, this, _1)); } @@ -306,6 +344,20 @@ ExportGraphBuilder::SFC::add_child (FileSpec const & new_config) } } +void +ExportGraphBuilder::SFC::remove_children (bool remove_out_files) +{ + boost::ptr_list<Encoder>::iterator iter = children.begin (); + + while (iter != children.end() ) { + + if (remove_out_files) { + iter->destroy_writer(remove_out_files); + } + iter = children.erase (iter); + } +} + bool ExportGraphBuilder::SFC::operator== (FileSpec const & other_config) const { @@ -365,6 +417,17 @@ ExportGraphBuilder::Normalizer::add_child (FileSpec const & new_config) threader->add_output (children.back().sink()); } +void +ExportGraphBuilder::Normalizer::remove_children (bool remove_out_files) +{ + boost::ptr_list<SFC>::iterator iter = children.begin (); + + while (iter != children.end() ) { + iter->remove_children (remove_out_files); + iter = children.erase (iter); + } +} + bool ExportGraphBuilder::Normalizer::operator== (FileSpec const & other_config) const { @@ -424,6 +487,27 @@ ExportGraphBuilder::SRC::add_child (FileSpec const & new_config) add_child_to_list (new_config, children); } } + +void +ExportGraphBuilder::SRC::remove_children (bool remove_out_files) +{ + boost::ptr_list<SFC>::iterator sfc_iter = children.begin(); + + while (sfc_iter != children.end() ) { + converter->remove_output (sfc_iter->sink() ); + sfc_iter->remove_children (remove_out_files); + sfc_iter = children.erase (sfc_iter); + } + + boost::ptr_list<Normalizer>::iterator norm_iter = normalized_children.begin(); + + while (norm_iter != normalized_children.end() ) { + converter->remove_output (norm_iter->sink() ); + norm_iter->remove_children (remove_out_files); + norm_iter = normalized_children.erase (norm_iter); + } + +} template<typename T> void @@ -486,6 +570,18 @@ ExportGraphBuilder::SilenceHandler::add_child (FileSpec const & new_config) children.push_back (new SRC (parent, new_config, max_frames_in)); silence_trimmer->add_output (children.back().sink()); } + +void +ExportGraphBuilder::SilenceHandler::remove_children (bool remove_out_files) +{ + boost::ptr_list<SRC>::iterator iter = children.begin(); + + while (iter != children.end() ) { + silence_trimmer->remove_output (iter->sink() ); + iter->remove_children (remove_out_files); + iter = children.erase (iter); + } +} bool ExportGraphBuilder::SilenceHandler::operator== (FileSpec const & other_config) const @@ -551,6 +647,19 @@ ExportGraphBuilder::ChannelConfig::add_child (FileSpec const & new_config) children.push_back (new SilenceHandler (parent, new_config, max_frames_out)); chunker->add_output (children.back().sink ()); } + +void +ExportGraphBuilder::ChannelConfig::remove_children (bool remove_out_files) +{ + boost::ptr_list<SilenceHandler>::iterator iter = children.begin(); + + while(iter != children.end() ) { + + chunker->remove_output (iter->sink ()); + iter->remove_children (remove_out_files); + iter = children.erase(iter); + } +} bool ExportGraphBuilder::ChannelConfig::operator== (FileSpec const & other_config) const |