From e5e8b7a96555efc2f49b96a17363bc7f337f7c51 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 22 Dec 2020 03:02:54 +0100 Subject: [PATCH] Close peakfile before emitting PeaksReady signal The file has to be flushed to disk before it can be used. This fixes an edge case only. Since PeaksReady() is a cross-thread signal that calls AudioRegionView::peaks_ready_handler in the GUI thread, the function [almost] always completed, before the GUI was woken up to schedule a WaveView render request (which uses the peak-file). --- libs/ardour/audiosource.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index d72975e46e..b5bd48c12c 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -349,7 +349,7 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, samplecnt_t npeaks, samplepos #if 0 // DEBUG ONLY /* Bypass peak-file cache, compute peaks using raw data from source */ - DEBUG_TRACE (DEBUG::Peaks, string_compose ("RP: npeaks = %1 start = %2 cnt = %3 spp = %4\n", npeaks, start, cnt, samples_per_visual_peak)); + DEBUG_TRACE (DEBUG::Peaks, string_compose ("RP: npeaks = %1 start = %2 cnt = %3 spp = %4 pf = %5\n", npeaks, start, cnt, samples_per_visual_peak, _peakpath)); { samplecnt_t scm = ceil (samples_per_visual_peak); samplecnt_t peak = 0; @@ -452,8 +452,8 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, samplecnt_t npeaks, samplepos scale = npeaks/expected_peaks; - DEBUG_TRACE (DEBUG::Peaks, string_compose (" ======>RP: npeaks = %1 start = %2 cnt = %3 len = %4 samples_per_visual_peak = %5 expected was %6 ... scale = %7 PD ptr = %8\n" - , npeaks, start, cnt, _length, samples_per_visual_peak, expected_peaks, scale, peaks)); + DEBUG_TRACE (DEBUG::Peaks, string_compose (" ======>RP: npeaks = %1 start = %2 cnt = %3 len = %4 samples_per_visual_peak = %5 expected was %6 ... scale = %7 PD ptr = %8 pf = %9\n" + , npeaks, start, cnt, _length, samples_per_visual_peak, expected_peaks, scale, peaks, _peakpath)); /* fix for near-end-of-file conditions */ @@ -878,14 +878,14 @@ AudioSource::done_with_peakfile_writes (bool done) compute_and_write_peaks (0, 0, 0, true, false, _FPP); } + close (_peakfile_fd); + _peakfile_fd = -1; + if (done) { Glib::Threads::Mutex::Lock lm (_peaks_ready_lock); _peaks_built = true; PeaksReady (); /* EMIT SIGNAL */ } - - close (_peakfile_fd); - _peakfile_fd = -1; } /** @param first_sample Offset from the source start of the first sample to