From 1a49d7d42b86227e244fbf284036c67781e1cf8d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 22 Dec 2020 03:29:07 +0100 Subject: [PATCH] Fix invisible multicahannel waveform at rec-stop AudioRegionView() c'tor calls create_waves() early on before the _height is set [1]. Now one following can happen: 1. All peak-files are present. create_waves() directly calls create_one_wave() for each channel. They are initialized with zero height. But all channels are present so waves[] is populated and a later call to set_height() corrects this 2. All peak-files are still missing. create_waves() schedules callbacks via PeaksReady -> peaks_ready_handler() Those callbacks arrive after set_height() was called and the waveforms are displayed correctly. 3. Only some peak-files are present. This can happen at rec-stop when the region is created. create_waves() directly calls create_one_wave() for available peaks, and schedules peaks_ready_handler() for the remainder. The directly created waves have zero-height. Since not all waves are ready, they are stored in tmp_waves. waves[] remains unpopulated. The set_height() call only ever changed the height of wave[], which resulted in hidden waveforms, until a user manually changed the height of the track. [1] the height is set from ``` #1 AudioStreamView::create_region_view(boost::shared_ptr, bool, bool) #2 AudioStreamView::add_region_view_internal(boost::shared_ptr, bool, bool) #3 StreamView::add_region_view(boost::weak_ptr) ... ## PBD::Signal1 Playlist::RegionAdded() ``` --- gtk2_ardour/audio_region_view.cc | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/gtk2_ardour/audio_region_view.cc b/gtk2_ardour/audio_region_view.cc index f34dec89ff..31e7a9bcb5 100644 --- a/gtk2_ardour/audio_region_view.cc +++ b/gtk2_ardour/audio_region_view.cc @@ -558,30 +558,40 @@ AudioRegionView::set_height (gdouble height) RegionView::set_height (height); pending_peak_data->set_y1 (height); - uint32_t wcnt = waves.size(); + RouteTimeAxisView& atv (*(dynamic_cast(&trackview))); // ick + uint32_t nchans = atv.track()->n_channels().n_audio(); - if (wcnt > 0) { + if (!tmp_waves.empty () || !waves.empty ()) { gdouble ht; if (!UIConfiguration::instance().get_show_name_highlight() || (height < NAME_HIGHLIGHT_THRESH)) { - ht = height / (double) wcnt; + ht = height / (double) nchans; } else { - ht = (height - NAME_HIGHLIGHT_SIZE) / (double) wcnt; + ht = (height - NAME_HIGHLIGHT_SIZE) / (double) nchans; } + uint32_t wcnt = waves.size(); for (uint32_t n = 0; n < wcnt; ++n) { - gdouble yoff = floor (ht * n); - waves[n]->set_height (ht); waves[n]->set_y_position (yoff); } + + wcnt = tmp_waves.size(); + for (uint32_t n = 0; n < wcnt; ++n) { + if (!tmp_waves[n]) { + continue; + } + gdouble yoff = floor (ht * n); + tmp_waves[n]->set_height (ht); + tmp_waves[n]->set_y_position (yoff); + } } if (gain_line) { - if ((height/wcnt) < NAME_HIGHLIGHT_THRESH) { + if ((height / nchans) < NAME_HIGHLIGHT_THRESH) { gain_line->hide (); } else { update_envelope_visibility (); @@ -1207,17 +1217,17 @@ AudioRegionView::create_waves () if (wait_for_data) { if (audio_region()->audio_source(n)->peaks_ready (boost::bind (&AudioRegionView::peaks_ready_handler, this, n), &_data_ready_connections[n], gui_context())) { - // cerr << "\tData is ready\n"; + // cerr << "\tData is ready for channel " << n << "\n"; create_one_wave (n, true); } else { - // cerr << "\tdata is not ready\n"; + // cerr << "\tdata is not ready for channel " << n << "\n"; // we'll get a PeaksReady signal from the source in the future // and will call create_one_wave(n) then. pending_peak_data->show (); } } else { - // cerr << "\tdon't delay, display today!\n"; + // cerr << "\tdon't delay, display channel " << n << " today!\n"; create_one_wave (n, true); } @@ -1305,7 +1315,7 @@ AudioRegionView::create_one_wave (uint32_t which, bool /*direct*/) } } - if (n == nwaves && waves.empty()) { + if (n == nwaves) { /* all waves are ready */ tmp_waves.resize(nwaves);