From 94538022488fd264dc78dfb855c43ff368bf97dd Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 11 Aug 2022 18:54:10 +0200 Subject: [PATCH] Fix "when refilling, cannot write" disk-reader bug This happened initially during session load. The GUI thread performed a direct refill (blocking wait) `Session::post_engine_init() -> Track::seek() -> DiskReader::seek() -> DiskReader::do_refill_with_alloc()` while concurrently the butler thread does the same: ``` Session::butler_transport_work() -> Track::non_realtime_locate() -> Route::non_realtime_locate() -> DiskIOProcessor::non_realtime_locate() -> DiskReader::seek() -> DiskReader::do_refill_with_alloc() -> DiskReader::refill_audio() ``` We do not want the GUI to wait, so now we just request a locate and let refill happen in the background. --- libs/ardour/session_state.cc | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index ef46dafe6a..4abe8125ef 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -401,17 +401,10 @@ Session::post_engine_init () set_clean (); - /* Now, finally, we can fill the playback buffers */ + /* Now, finally, we can [ask the butler to] fill the playback buffers */ BootMessage (_("Filling playback buffers")); - - boost::shared_ptr rl = routes.reader(); - for (RouteList::iterator r = rl->begin(); r != rl->end(); ++r) { - boost::shared_ptr trk = boost::dynamic_pointer_cast (*r); - if (trk && !trk->is_private_route()) { - trk->seek (_transport_sample, true); - } - } + request_locate (transport_sample(), true); reset_xrun_count (); return 0;