diff options
author | Robin Gareus <robin@gareus.org> | 2016-07-15 17:03:07 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-07-16 02:14:13 +0200 |
commit | 77687519b69f39aaa2354f4c9945958fc1c630fe (patch) | |
tree | 36ed0f367bc81cccaba0ed01d837c56ff2fea072 /libs/ardour/export_graph_builder.cc | |
parent | 6626723880e6d464bf8d59178120d191a8423c93 (diff) |
Refactor TmpFile into an abstract base class
This allows a TmpFile pointer to be either a Sync or Async (Threaded)
writer. As result we must be able to handle both RT and non RT processing.
Still, post-processing (normalization and encoding) should always
happen faster than realtime (freewheeling).
Since jack does not allow a client to change to freewheeling from within
the process-callback, the async-writer disk-thread FileFlushed is used
to initiate post-processing.
Diffstat (limited to 'libs/ardour/export_graph_builder.cc')
-rw-r--r-- | libs/ardour/export_graph_builder.cc | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libs/ardour/export_graph_builder.cc b/libs/ardour/export_graph_builder.cc index 2e9972b47d..9065aea130 100644 --- a/libs/ardour/export_graph_builder.cc +++ b/libs/ardour/export_graph_builder.cc @@ -37,6 +37,7 @@ #include "audiographer/general/threader.h" #include "audiographer/sndfile/tmp_file.h" #include "audiographer/sndfile/tmp_file_rt.h" +#include "audiographer/sndfile/tmp_file_sync.h" #include "audiographer/sndfile/sndfile_writer.h" #include "ardour/audioengine.h" @@ -434,8 +435,10 @@ ExportGraphBuilder::Normalizer::Normalizer (ExportGraphBuilder & parent, FileSpe normalizer->add_output (threader); int format = ExportFormatBase::F_RAW | ExportFormatBase::SF_Float; - tmp_file.reset (new TmpFile<float> (&tmpfile_path_buf[0], format, channels, config.format->sample_rate())); + tmp_file.reset (new TmpFileSync<float> (&tmpfile_path_buf[0], format, channels, config.format->sample_rate())); tmp_file->FileWritten.connect_same_thread (post_processing_connection, + boost::bind (&Normalizer::prepare_post_processing, this)); + tmp_file->FileFlushed.connect_same_thread (post_processing_connection, boost::bind (&Normalizer::start_post_processing, this)); add_child (new_config); @@ -509,8 +512,9 @@ ExportGraphBuilder::Normalizer::process() } void -ExportGraphBuilder::Normalizer::start_post_processing() +ExportGraphBuilder::Normalizer::prepare_post_processing() { + // called in sync rt-context float gain; if (use_loudness) { gain = normalizer->set_peak (loudness_reader->get_peak (config.format->normalize_lufs (), config.format->normalize_dbtp ())); @@ -520,11 +524,20 @@ ExportGraphBuilder::Normalizer::start_post_processing() for (boost::ptr_list<SFC>::iterator i = children.begin(); i != children.end(); ++i) { (*i).set_peak (gain); } - tmp_file->seek (0, SEEK_SET); tmp_file->add_output (normalizer); parent.normalizers.push_back (this); } +void +ExportGraphBuilder::Normalizer::start_post_processing() +{ + // called in disk-thread (when exporting in realtime) + tmp_file->seek (0, SEEK_SET); + if (!AudioEngine::instance()->freewheeling ()) { + AudioEngine::instance()->freewheel (true); + } +} + /* SRC */ ExportGraphBuilder::SRC::SRC (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames) |