From 83bd2ee752f0b2b5d623112de5fe16f2a32fffae Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 5 May 2024 21:53:18 -0600 Subject: [PATCH] libardour infrastructure to suspend track-reordering side effects during a drag --- libs/ardour/ardour/session.h | 15 ++++++++++++++- libs/ardour/session.cc | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f365182340..849d8149e3 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -402,7 +402,7 @@ public: } RecordState record_status() const { - return _record_status.load(); + return _record_status.load(); } bool actively_recording () const { @@ -1416,6 +1416,17 @@ public: bool virtual_soundcheck() const; PBD::Signal1 VirtualSoundCheckChanged; + struct LivetraxAutoConnectSuspender { + LivetraxAutoConnectSuspender (Session& s) : session (s) { session.suspend_livetrax_auto_connect (); } + ~LivetraxAutoConnectSuspender () { session.unsuspend_livetrax_auto_connect (); } + + Session& session; + }; + + void suspend_livetrax_auto_connect (); + void unsuspend_livetrax_auto_connect (); + void update_track_numbers () { reassign_track_numbers (); } + protected: friend class AudioEngine; void set_block_size (pframes_t nframes); @@ -2431,6 +2442,8 @@ private: void set_virtual_soundcheck (bool); bool _virtual_soundcheck; + + std::atomic _no_livetrax_auto_connect; }; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 0379100f5a..955c9ca173 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -351,6 +351,7 @@ Session::Session (AudioEngine &eng, , tb_with_filled_slots (0) , _no_file_format_reset (0) , _virtual_soundcheck (false) + , _no_livetrax_auto_connect (0) { _suspend_save.store (0); _playback_load.store (0); @@ -7757,9 +7758,27 @@ Session::cut_copy_section (timepos_t const& start_, timepos_t const& end_, timep commit_reversible_command (); } +void +Session::suspend_livetrax_auto_connect () +{ + _no_livetrax_auto_connect++; +} + +void +Session::unsuspend_livetrax_auto_connect () +{ + if (_no_livetrax_auto_connect) { + _no_livetrax_auto_connect--; + } +} + void Session::livetrax_auto_connect_route (std::shared_ptr route) { + if (_no_livetrax_auto_connect) { + return; + } + ChanCount ignored; auto_connect_route (route, true, true, ignored, ignored, ignored, ignored); }