unsigned get_normalize_cycle_count() const;
void reset ();
+ void cleanup (bool remove_out_files = false);
void set_current_timespan (boost::shared_ptr<ExportTimespan> span);
void add_config (FileSpec const & config);
private:
void add_split_config (FileSpec const & config);
-
+
class Encoder {
public:
template <typename T> boost::shared_ptr<AudioGrapher::Sink<T> > init (FileSpec const & new_config);
void add_child (FileSpec const & new_config);
+ void remove_children ();
+ void destroy_writer (bool delete_out_file);
bool operator== (FileSpec const & other_config) const;
static int get_real_format (FileSpec const & config);
std::list<ExportFilenamePtr> filenames;
PBD::ScopedConnection copy_files_connection;
+ std::string writer_filename;
+
// Only one of these should be available at a time
FloatWriterPtr float_writer;
IntWriterPtr int_writer;
SFC (ExportGraphBuilder &, FileSpec const & new_config, framecnt_t max_frames);
FloatSinkPtr sink ();
void add_child (FileSpec const & new_config);
+ void remove_children (bool remove_out_files);
bool operator== (FileSpec const & other_config) const;
private:
Normalizer (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames);
FloatSinkPtr sink ();
void add_child (FileSpec const & new_config);
+ void remove_children (bool remove_out_files);
bool operator== (FileSpec const & other_config) const;
unsigned get_normalize_cycle_count() const;
SRC (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames);
FloatSinkPtr sink ();
void add_child (FileSpec const & new_config);
+ void remove_children (bool remove_out_files);
+
bool operator== (FileSpec const & other_config) const;
private:
SilenceHandler (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames);
FloatSinkPtr sink ();
void add_child (FileSpec const & new_config);
+ void remove_children (bool remove_out_files);
bool operator== (FileSpec const & other_config) const;
private:
public:
ChannelConfig (ExportGraphBuilder & parent, FileSpec const & new_config, ChannelMap & channel_map);
void add_child (FileSpec const & new_config);
+ void remove_children (bool remove_out_files);
bool operator== (FileSpec const & other_config) const;
private:
normalizers.clear ();
}
+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)
{
// No duplicate channel config found, create new one
channel_configs.push_back (new ChannelConfig (*this, config, channels));
}
-
+
/* Encoder */
template <>
{
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
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));
}
}
}
+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
{
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
{
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
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
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