From b98884a54cc3f49919d2fb888ad6febb741c27ec Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 27 Mar 2025 17:21:36 +0100 Subject: [PATCH] Cancel audio peak analysis when destroying AudioRegionEditor This speeds up selection changes when the Region Properties are show in the bottom attachment and long regions are selected. The RegionEditor is destroyed when selection changes and has/had to wait for the peak analysis thread to complete. --- gtk2_ardour/audio_region_editor.cc | 4 +++- gtk2_ardour/audio_region_editor.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc index d8272f2f8e..4684fa37f9 100644 --- a/gtk2_ardour/audio_region_editor.cc +++ b/gtk2_ardour/audio_region_editor.cc @@ -146,7 +146,9 @@ AudioRegionEditor::AudioRegionEditor (Session* s, AudioRegionView* arv) AudioRegionEditor::~AudioRegionEditor () { void* v; + _peak_amplitude_connection.disconnect (); _peak_channel.deliver ('t'); + Progress::cancel (); pthread_join (_peak_amplitude_thread_handle, &v); } @@ -235,7 +237,7 @@ AudioRegionEditor::peak_amplitude_thread () Temporal::TempoMap::fetch (); /* compute peak amplitude and signal the fact */ - PeakAmplitudeFound (accurate_coefficient_to_dB (_audio_region->maximum_amplitude ())); /* EMIT SIGNAL */ + PeakAmplitudeFound (accurate_coefficient_to_dB (_audio_region->maximum_amplitude (this))); /* EMIT SIGNAL */ } } diff --git a/gtk2_ardour/audio_region_editor.h b/gtk2_ardour/audio_region_editor.h index baca03f5b9..a97133d855 100644 --- a/gtk2_ardour/audio_region_editor.h +++ b/gtk2_ardour/audio_region_editor.h @@ -39,6 +39,7 @@ #include "widgets/ardour_dropdown.h" #include "pbd/crossthread.h" +#include "pbd/progress.h" #include "pbd/signals.h" #include "ardour_dialog.h" @@ -52,7 +53,7 @@ namespace ARDOUR { class AudioRegionView; -class AudioRegionEditor : public RegionEditor +class AudioRegionEditor : public RegionEditor, protected PBD::Progress { public: AudioRegionEditor (ARDOUR::Session*, AudioRegionView*); @@ -101,6 +102,8 @@ private: PBD::Signal PeakAmplitudeFound; + void set_overall_progress (float) {} + pthread_t _peak_amplitude_thread_handle; PBD::ScopedConnection _peak_amplitude_connection; CrossThreadChannel _peak_channel;