This fixes a deadlock when closing the session.
Session::destroy() takes the engine-lock while removing
unhandled session-events. In [1], the event-queue held a last
reference to a Track, and releasing that object triggered
events (here ~IO) that required the lock.
---
[1]
#2 0x0041743a in Glib::Threads::Mutex::Lock::Lock at /home/ardour/linux-armhf/stack/include/glibmm-2.4/glibmm/threads.h:643
#3 0xb67433ba in ARDOUR::IO::~IO at ../libs/ardour/io.cc:105
#4 0xb6743612 in ARDOUR::IO::~IO at ../libs/ardour/io.cc:111
#5 0xb6758e66 in boost::checked_delete<ARDOUR::IO> at /home/ardour/linux-armhf/stack/include/boost/core/checked_delete.hpp:34
#6 0xb675912c in boost::detail::sp_counted_impl_p<ARDOUR::IO>::dispose at /home/ardour/linux-armhf/stack/include/boost/smart_ptr/detail/sp_counted_impl.hpp:92
#7 0x004178d8 in boost::detail::sp_counted_base::release at /home/ardour/linux-armhf/stack/include/boost/smart_ptr/detail/sp_counted_base_sync.hpp:129
#8 0x00417986 in boost::detail::shared_count::~shared_count at /home/ardour/linux-armhf/stack/include/boost/smart_ptr/detail/shared_count.hpp:426
#9 0xb662343a in boost::shared_ptr<ARDOUR::IO>::~shared_ptr at /home/ardour/linux-armhf/stack/include/boost/smart_ptr/shared_ptr.hpp:341
#10 0xb6a4af7a in ARDOUR::Route::~Route at ../libs/ardour/route.cc:282
#11 0xb6b9404c in ARDOUR::Track::~Track at ../libs/ardour/track.cc:71
#12 0xb697164a in ARDOUR::MidiTrack::~MidiTrack at ../libs/ardour/midi_track.cc:94
#13 0xb697177a in ARDOUR::MidiTrack::~MidiTrack at ../libs/ardour/midi_track.cc:96
#14 0xb6ac525a in boost::checked_delete<ARDOUR::MidiTrack> at /home/ardour/linux-armhf/stack/include/boost/core/checked_delete.hpp:34
#15 0xb6acde00 in boost::detail::sp_counted_impl_p<ARDOUR::MidiTrack>::dispose at /home/ardour/linux-armhf/stack/include/boost/smart_ptr/detail/sp_counted_impl.hpp:92
#16 0x004178d8 in boost::detail::sp_counted_base::release at /home/ardour/linux-armhf/stack/include/boost/smart_ptr/detail/sp_counted_base_sync.hpp:129
#17 0x00417986 in boost::detail::shared_count::~shared_count at /home/ardour/linux-armhf/stack/include/boost/smart_ptr/detail/shared_count.hpp:426
#18 0xb664dca6 in boost::shared_ptr<ARDOUR::Track>::~shared_ptr at /home/ardour/linux-armhf/stack/include/boost/smart_ptr/shared_ptr.hpp:341
#19 0xb6aaf67e in ARDOUR::SessionEvent::~SessionEvent at ../libs/ardour/ardour/session_event.h:42
#20 0xb6a91a88 in ARDOUR::Session::destroy at ../libs/ardour/session.cc:753
#21 0xb6a8fb20 in ARDOUR::Session::~Session at ../libs/ardour/session.cc:460
#22 0xb6a9075e in ARDOUR::Session::~Session at ../libs/ardour/session.cc:46
This fixes a crash with missing [MIDI] write-sources after
duplicating tracks [1]: Stealing write-source name fails, because
there is no write-source.
When duplicating tracks, reset_write_sources() is called before
any playlists are set [2]. So no new write-sources are created
because _playlists[DATA-TYPE] is empty.
During normal track creation write-sources are usually added
by the input-change handler [3]. However in this case the
state has been set, and since there is no change,
DiskWriter::configure_io does not call use_new_write_source()
NB. This also re-creates write-source when playlists are changed.
-=-
[1]
#3 0x00007f4420690102 in __GI___assert_fail at assert.c:101
#4 0x0000562bfa300dc9 in boost::shared_ptr<ARDOUR::SMFSource>::operator->() const at /usr/include/boost/smart_ptr/shared_ptr.hpp:734
#5 0x00007f442579ffa1 in ARDOUR::DiskWriter::steal_write_source_name[abi:cxx11]() at ../libs/ardour/disk_writer.cc:1290
#6 0x00007f4425e476b6 in ARDOUR::Track::steal_write_source_name[abi:cxx11]() at ../libs/ardour/track.cc:476
#7 0x00007f4425d060a2 in ARDOUR::Session::create_midi_source_by_stealing_name at ../libs/ardour/session.cc:4955
#8 0x0000562bf9ed39ab in MidiTimeAxisView::add_region at ../gtk2_ardour/midi_time_axis.cc:1650
#9 0x0000562bf9b05f2a in Drag::add_midi_region at ../gtk2_ardour/editor_drag.cc:568
-=-
[2]
#0 0x00007ffff7582e2f in ARDOUR::DiskWriter::reset_write_sources at ../libs/ardour/disk_writer.cc:946
#1 0x00007ffff757fce6 in ARDOUR::DiskWriter::set_state at ../libs/ardour/disk_writer.cc:333
#2 0x00007ffff7a81c93 in ARDOUR::Route::set_processor_state at ../libs/ardour/route.cc:3054
#3 0x00007ffff7a7f5d5 in ARDOUR::Route::set_state at ../libs/ardour/route.cc:2697
#4 0x00007ffff7c2aa1d in ARDOUR::Track::set_state at ../libs/ardour/track.cc:172
#5 0x00007ffff794f204 in ARDOUR::MidiTrack::set_state at ../libs/ardour/midi_track.cc:152
#6 0x00007ffff7b7e06b in ARDOUR::Session::XMLRouteFactory at ../libs/ardour/session_state.cc:1890
#7 0x00007ffff7addf7e in ARDOUR::Session::new_route_from_template at ../libs/ardour/session.cc:3048
#8 0x000055555621329a in DuplicateRouteDialog::on_response(int) at ../gtk2_ardour/duplicate_routes_dialog.cc:194
-=-
[3]
#0 0x00007ffff7583243 in ARDOUR::DiskWriter::use_new_write_source at ../libs/ardour/disk_writer.cc:996
#1 0x00007ffff75831c7 in ARDOUR::DiskWriter::reset_write_sources at ../libs/ardour/disk_writer.cc:989
#2 0x00007ffff75851ea in ARDOUR::DiskWriter::configure_io at ../libs/ardour/disk_writer.cc:1335
#3 0x00007ffff7a7b308 in ARDOUR::Route::configure_processors_unlocked at ../libs/ardour/route.cc:1912
#4 0x00007ffff7a79e4b in ARDOUR::Route::configure_processors at ../libs/ardour/route.cc:1719
#5 0x00007ffff7a86695 in ARDOUR::Route::input_change_handler at ../libs/ardour/route.cc:3632
Completing readout available() returns 0, until all
background threads have finished and joined.
This also improves performance by feeding suggested/required
amount of samples on every process() call.
These changes compile okay for me (using VS2019) although they wouldn't link to my older-built libraries. Hopefully he'll be okay if he builds everything with the same compiler.
There are two problem cases:
1) the drag "fake-located" the playhead, but a redraw happens before the locate itself finishes.
2) the transport emits Session::PositionChanged from Session::non_realtime_stop(), even though
this is occuring in the "middle" of the locate process (we stop first).
In the first case, the drag code sets _pending_locate_request, since we need this to be true even
before the queued SessionEvent for the locate has been processed. So to deal with this case
In the second case, we use Session::locate_initiated() to decide if we're in the middle of a locate.
The drag code expects coordinates in canvas coordinates, but we were not translating them at the editor level (canvas event handling
does do this, but cannot affect the situation if the event falls through to the editor)
This always leads to feedback situations. It may be acceptable
via the "allow feedback" option and accepting 1 cycle delay.
yet Aux-sends from the master bus are just bad practice,
and no found on any mixing desk.
Sends do not have any ports, so a unique name is not required.
Since 82541b33a4 custom aux names are kept when setting state.
Previously this "worked" because set_state() change the name
of the new aux-send to the name of the target-bus.