From c0a843a905a094659bbf95fd9a9602edcce60f54 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 29 Jan 2016 01:12:32 +0100 Subject: [PATCH] fix device-list update concurrency issue. It may happen that during push_state_to_backend() a device is reconfigured in a way that triggers a "Device Changed" callback before the engine is started. This callback can trigger a change to the configuration that will be used when the engine is actually started. This has been seen on OSX in conjunction with Aggregate Devices (even if the aggregate is not used, but the device which is used is also part of an aggregate) example: HW changed callback arrives, device-list is re-populated, *A*irplay" is at the top of the list, Airplay supports only 44.1K, Samplerate changes... later save also writes this new rate to the file. --- gtk2_ardour/engine_dialog.cc | 5 +++++ gtk2_ardour/engine_dialog.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 4df00e4ce5..6abae66dda 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -96,6 +96,7 @@ EngineControl::EngineControl () , lm_running (false) , midi_back_button (_("Back to settings")) , ignore_changes (0) + , ignore_device_changes (0) , _desired_sample_rate (0) , started_at_least_once (false) , queue_device_changed (false) @@ -2220,6 +2221,7 @@ EngineControl::push_state_to_backend (bool start) { DEBUG_ECONTROL ("push_state_to_backend"); boost::shared_ptr backend = ARDOUR::AudioEngine::instance()->current_backend(); + PBD::Unwinder protect_ignore_device_changes (ignore_device_changes, ignore_device_changes + 1); if (!backend) { return 0; @@ -3041,6 +3043,9 @@ EngineControl::engine_stopped () void EngineControl::device_list_changed () { + if (ignore_device_changes) { + return; + } PBD::Unwinder protect_ignore_changes (ignore_changes, ignore_changes + 1); // ?? list_devices (); midi_option_changed(); diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index d5c54d088e..71c95cc209 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -120,7 +120,8 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList { Gtk::CheckButton aj_button; - uint32_t ignore_changes; + uint32_t ignore_changes; // state save/load + uint32_t ignore_device_changes; // AudioEngine::DeviceListChanged uint32_t _desired_sample_rate; bool started_at_least_once; bool queue_device_changed;