From b279c42158645e4108295564f036919699534bc4 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 28 Mar 2020 02:32:15 +0100 Subject: Create write sources for template/dup tracks - #7940 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::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 --- libs/ardour/ardour/disk_writer.h | 2 ++ libs/ardour/disk_writer.cc | 13 +++++++++++++ 2 files changed, 15 insertions(+) (limited to 'libs') diff --git a/libs/ardour/ardour/disk_writer.h b/libs/ardour/ardour/disk_writer.h index 1d5820dbf5..31a64cd0e8 100644 --- a/libs/ardour/ardour/disk_writer.h +++ b/libs/ardour/ardour/disk_writer.h @@ -141,6 +141,8 @@ protected: virtual XMLNode& state (); + int use_playlist (DataType, boost::shared_ptr); + int do_flush (RunContext context, bool force = false); private: diff --git a/libs/ardour/disk_writer.cc b/libs/ardour/disk_writer.cc index 51b91b5617..ae29fb2d10 100644 --- a/libs/ardour/disk_writer.cc +++ b/libs/ardour/disk_writer.cc @@ -1337,3 +1337,16 @@ DiskWriter::configure_io (ChanCount in, ChanCount out) return true; } + +int +DiskWriter::use_playlist (DataType dt, boost::shared_ptr playlist) +{ + bool reset_ws = _playlists[dt] != playlist; + + if (DiskIOProcessor::use_playlist (dt, playlist)) { + return -1; + } + if (reset_ws) { + reset_write_sources (false, true); + } +} -- cgit v1.2.3