From bf8c25677172c0e425bfcfae507289054c995ed5 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 12 Dec 2019 12:09:15 -0700 Subject: [PATCH] reduce another race condition risk overwrite_queued == true is equivalent to _pending_overwrite != 0 --- libs/ardour/ardour/disk_reader.h | 1 - libs/ardour/disk_reader.cc | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/libs/ardour/ardour/disk_reader.h b/libs/ardour/ardour/disk_reader.h index fd437e57ea..725fa4b2ce 100644 --- a/libs/ardour/ardour/disk_reader.h +++ b/libs/ardour/ardour/disk_reader.h @@ -184,7 +184,6 @@ private: sampleoffset_t overwrite_offset; samplepos_t new_file_sample; mutable gint _pending_overwrite; - bool overwrite_queued; bool run_must_resolve; IOChange input_change_pending; samplepos_t file_sample[DataType::num_types]; diff --git a/libs/ardour/disk_reader.cc b/libs/ardour/disk_reader.cc index e3cd75f5a1..b085029e54 100644 --- a/libs/ardour/disk_reader.cc +++ b/libs/ardour/disk_reader.cc @@ -60,7 +60,6 @@ samplecnt_t DiskReader::loop_fade_length (0); DiskReader::DiskReader (Session& s, string const & str, DiskIOProcessor::Flag f) : DiskIOProcessor (s, str, f) , overwrite_sample (0) - , overwrite_queued (false) , run_must_resolve (false) , _declick_amp (s.nominal_sample_rate ()) , _declick_offs (0) @@ -233,10 +232,7 @@ DiskReader::adjust_buffering () void DiskReader::playlist_modified () { - if (!overwrite_queued) { - _session.request_overwrite_buffer (_track, PlaylistModified); - overwrite_queued = true; - } + _session.request_overwrite_buffer (_track, PlaylistModified); } int @@ -257,9 +253,8 @@ DiskReader::use_playlist (DataType dt, boost::shared_ptr playlist) take care of the buffer refill. */ - if (!overwrite_queued && (prior_playlist || _session.loading())) { + if ((g_atomic_int_get (&_pending_overwrite) & PlaylistChanged) || prior_playlist) { _session.request_overwrite_buffer (_track, PlaylistChanged); - overwrite_queued = true; } return 0; @@ -639,7 +634,6 @@ DiskReader::overwrite_existing_buffers () } } - overwrite_queued = false; g_atomic_int_set (&_pending_overwrite, 0); return ret;