From db1a6720c28a332b98a15a9ff357fdc22e909748 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 14 Apr 2022 16:32:06 +0200 Subject: [PATCH] Fix Region Export (clip library bounce) Region::read_at fails if the region is not in a playlist. It also applies fades and and region transparency which are not relevant here. --- libs/ardour/audioregion.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index e92cbcafe5..d9269af61e 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -35,6 +35,7 @@ #include #include +#include "pbd/gstdio_compat.h" #include "pbd/basename.h" #include "pbd/xml++.h" #include "pbd/enumwriter.h" @@ -2051,9 +2052,8 @@ bool AudioRegion::do_export (std::string const& path) const { const uint32_t n_chn = n_channels (); - const samplepos_t chunk_size = 8192; + const samplecnt_t chunk_size = 8192; Sample buf[chunk_size]; - gain_t gain_buffer[chunk_size]; const int format = SF_FORMAT_FLAC | SF_FORMAT_PCM_24; // TODO preference or option @@ -2072,15 +2072,16 @@ AudioRegion::do_export (std::string const& path) const interleaver.init (n_channels (), chunk_size); interleaver.add_output (sfw); - samplepos_t to_read = length_samples (); - samplepos_t pos = position_sample (); + samplecnt_t to_read = length_samples (); + samplepos_t pos = position_sample (); + samplecnt_t lsamples = _length.val().samples(); while (to_read) { - samplepos_t this_time = min (to_read, chunk_size); + samplecnt_t this_time = min (to_read, chunk_size); for (uint32_t chn = 0; chn < n_chn; ++chn) { - if (read_at (buf, buf, gain_buffer, pos, this_time, chn) != this_time) { - break; + if (read_from_sources (_sources, lsamples, buf, pos, this_time, chn) != this_time) { + goto errout; } AudioGrapher::ConstProcessContext context (buf, this_time, 1); @@ -2094,8 +2095,14 @@ AudioRegion::do_export (std::string const& path) const pos += this_time; } +errout: /* Drop references, close file */ interleaver.clear_outputs (); sfw.reset (); + + if (to_read != 0) { + ::g_unlink (path.c_str()); + } + return to_read == 0; }