diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/audioengine.h Ardour-6.6.0/libs/ardour/ardour/audioengine.h --- Ardour-6.6.0.orig/libs/ardour/ardour/audioengine.h 2021-04-21 23:33:55.626176390 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/audioengine.h 2021-04-21 23:33:10.190293826 -0700 @@ -39,6 +39,7 @@ #include "pbd/signals.h" #include "pbd/pthread_utils.h" #include "pbd/stacktrace.h" +#include "pbd/g_atomic_compat.h" #include "ardour/ardour.h" #include "ardour/data_type.h" @@ -128,7 +129,7 @@ class LIBARDOUR_API AudioEngine : public bool is_realtime() const; // for the user which hold state_lock to check if reset operation is pending - bool is_reset_requested() const { return g_atomic_int_get(const_cast(&_hw_reset_request_count)); } + bool is_reset_requested() const { return g_atomic_int_get (&_hw_reset_request_count); } int set_device_name (const std::string&); int set_sample_rate (float); @@ -298,19 +299,19 @@ class LIBARDOUR_API AudioEngine : public std::string _last_backend_error_string; Glib::Threads::Thread* _hw_reset_event_thread; - gint _hw_reset_request_count; + GATOMIC_QUAL gint _hw_reset_request_count; Glib::Threads::Cond _hw_reset_condition; Glib::Threads::Mutex _reset_request_lock; - gint _stop_hw_reset_processing; + GATOMIC_QUAL gint _stop_hw_reset_processing; Glib::Threads::Thread* _hw_devicelist_update_thread; - gint _hw_devicelist_update_count; + GATOMIC_QUAL gint _hw_devicelist_update_count; Glib::Threads::Cond _hw_devicelist_update_condition; Glib::Threads::Mutex _devicelist_update_lock; - gint _stop_hw_devicelist_processing; + GATOMIC_QUAL gint _stop_hw_devicelist_processing; uint32_t _start_cnt; uint32_t _init_countdown; - volatile gint _pending_playback_latency_callback; - volatile gint _pending_capture_latency_callback; + GATOMIC_QUAL gint _pending_playback_latency_callback; + GATOMIC_QUAL gint _pending_capture_latency_callback; void start_hw_event_processing(); void stop_hw_event_processing(); diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/audio_unit.h Ardour-6.6.0/libs/ardour/ardour/audio_unit.h --- Ardour-6.6.0.orig/libs/ardour/ardour/audio_unit.h 2021-04-21 23:33:55.627176410 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/audio_unit.h 2021-04-21 23:33:10.191293846 -0700 @@ -31,6 +31,7 @@ #include #include +#include "pbd/g_atomic_compat.h" #include "ardour/plugin.h" #include @@ -172,7 +173,7 @@ class LIBARDOUR_API AUPlugin : public AR int32_t output_channels; std::vector > io_configs; samplecnt_t _last_nframes; - mutable volatile guint _current_latency; + mutable GATOMIC_QUAL guint _current_latency; bool _requires_fixed_size_buffers; AudioBufferList* buffers; bool _has_midi_input; diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/auditioner.h Ardour-6.6.0/libs/ardour/ardour/auditioner.h --- Ardour-6.6.0.orig/libs/ardour/ardour/auditioner.h 2021-04-21 23:33:55.627176410 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/auditioner.h 2021-04-21 23:33:10.191293846 -0700 @@ -100,7 +100,7 @@ private: boost::shared_ptr the_region; boost::shared_ptr midi_region; samplepos_t current_sample; - mutable gint _auditioning; + mutable GATOMIC_QUAL gint _auditioning; Glib::Threads::Mutex lock; samplecnt_t length; sampleoffset_t _seek_sample; diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/automation_list.h Ardour-6.6.0/libs/ardour/ardour/automation_list.h --- Ardour-6.6.0.orig/libs/ardour/ardour/automation_list.h 2021-04-21 23:33:55.627176410 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/automation_list.h 2021-04-21 23:33:10.191293846 -0700 @@ -37,6 +37,7 @@ #include "pbd/xml++.h" #include "pbd/statefuldestructible.h" #include "pbd/properties.h" +#include "pbd/g_atomic_compat.h" #include "ardour/ardour.h" @@ -107,9 +108,10 @@ public: void start_touch (double when); void stop_touch (double when); - bool touching() const { return g_atomic_int_get (const_cast(&_touching)); } - bool writing() const { return _state == Write; } - bool touch_enabled() const { return _state & (Touch | Latch); } + + bool touching () const { return g_atomic_int_get (&_touching) != 0; } + bool writing () const { return _state == Write; } + bool touch_enabled () const { return _state & (Touch | Latch); } XMLNode& get_state (); int set_state (const XMLNode &, int version); @@ -133,8 +135,8 @@ private: void maybe_signal_changed (); - AutoState _state; - gint _touching; + AutoState _state; + GATOMIC_QUAL gint _touching; PBD::ScopedConnection _writepass_connection; diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/butler.h Ardour-6.6.0/libs/ardour/ardour/butler.h --- Ardour-6.6.0.orig/libs/ardour/ardour/butler.h 2021-04-21 23:33:55.627176410 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/butler.h 2021-04-21 23:33:10.192293865 -0700 @@ -30,12 +30,12 @@ #include "pbd/crossthread.h" #include "pbd/ringbuffer.h" #include "pbd/pool.h" +#include "pbd/g_atomic_compat.h" + #include "ardour/libardour_visibility.h" #include "ardour/types.h" #include "ardour/session_handle.h" - - namespace ARDOUR { /** @@ -79,15 +79,18 @@ class LIBARDOUR_API Butler : public Sess }; }; - pthread_t thread; - bool have_thread; - Glib::Threads::Mutex request_lock; - Glib::Threads::Cond paused; - bool should_run; - mutable gint should_do_transport_work; - samplecnt_t _audio_capture_buffer_size; - samplecnt_t _audio_playback_buffer_size; - uint32_t _midi_buffer_size; + pthread_t thread; + bool have_thread; + + Glib::Threads::Mutex request_lock; + Glib::Threads::Cond paused; + bool should_run; + mutable GATOMIC_QUAL gint should_do_transport_work; + + samplecnt_t _audio_capture_buffer_size; + samplecnt_t _audio_playback_buffer_size; + uint32_t _midi_buffer_size; + PBD::RingBuffer pool_trash; private: diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/circular_buffer.h Ardour-6.6.0/libs/ardour/ardour/circular_buffer.h --- Ardour-6.6.0.orig/libs/ardour/ardour/circular_buffer.h 2021-04-21 23:33:55.627176410 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/circular_buffer.h 2021-04-21 23:33:10.192293865 -0700 @@ -20,6 +20,7 @@ #define _ardour_circular_buffer_h_ #include "pbd/ringbuffer.h" +#include "pbd/g_atomic_compat.h" #include "ardour/libardour_visibility.h" #include "ardour/types.h" @@ -69,8 +70,9 @@ private: Event* _buf; guint _size; guint _size_mask; - gint _idx; - gint _ack; + + GATOMIC_QUAL gint _idx; + GATOMIC_QUAL gint _ack; }; } diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/disk_reader.h Ardour-6.6.0/libs/ardour/ardour/disk_reader.h --- Ardour-6.6.0.orig/libs/ardour/ardour/disk_reader.h 2021-04-21 23:33:55.628176429 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/disk_reader.h 2021-04-21 23:33:10.192293865 -0700 @@ -22,6 +22,8 @@ #include +#include "pbd/g_atomic_compat.h" + #include "evoral/Curve.h" #include "ardour/disk_io.h" @@ -196,11 +198,12 @@ private: samplepos_t overwrite_sample; sampleoffset_t overwrite_offset; samplepos_t new_file_sample; - mutable gint _pending_overwrite; bool run_must_resolve; IOChange input_change_pending; samplepos_t file_sample[DataType::num_types]; + mutable GATOMIC_QUAL gint _pending_overwrite; + DeclickAmp _declick_amp; sampleoffset_t _declick_offs; bool _declick_enabled; @@ -209,7 +212,8 @@ private: boost::optional _last_read_loop; static samplecnt_t _chunk_samples; - static gint _no_disk_output; + + static GATOMIC_QUAL gint _no_disk_output; static Declicker loop_declick_in; static Declicker loop_declick_out; diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/disk_writer.h Ardour-6.6.0/libs/ardour/ardour/disk_writer.h --- Ardour-6.6.0.orig/libs/ardour/ardour/disk_writer.h 2021-04-21 23:33:55.628176429 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/disk_writer.h 2021-04-21 23:33:10.193293885 -0700 @@ -23,6 +23,8 @@ #include #include +#include "pbd/g_atomic_compat.h" + #include "ardour/disk_io.h" #include "ardour/midi_buffer.h" @@ -89,8 +91,8 @@ public: std::list >& last_capture_sources () { return _last_capture_sources; } - bool record_enabled () const { return g_atomic_int_get (const_cast (&_record_enabled)); } - bool record_safe () const { return g_atomic_int_get (const_cast (&_record_safe)); } + bool record_enabled () const { return g_atomic_int_get (&_record_enabled); } + bool record_safe () const { return g_atomic_int_get (&_record_safe); } void set_record_enabled (bool yn); void set_record_safe (bool yn); @@ -173,8 +175,6 @@ private: CaptureInfos capture_info; mutable Glib::Threads::Mutex capture_info_lock; - gint _record_enabled; - gint _record_safe; samplepos_t _capture_start_sample; samplecnt_t _capture_captured; bool _was_recording; @@ -186,13 +186,16 @@ private: AlignStyle _alignment_style; std::string _write_source_name; NoteMode _note_mode; - volatile gint _samples_pending_write; - volatile gint _num_captured_loops; samplepos_t _accumulated_capture_offset; bool _transport_looped; samplepos_t _transport_loop_sample; + GATOMIC_QUAL gint _record_enabled; + GATOMIC_QUAL gint _record_safe; + GATOMIC_QUAL gint _samples_pending_write; + GATOMIC_QUAL gint _num_captured_loops; + boost::shared_ptr _midi_write_source; std::list > _last_capture_sources; diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/graph.h Ardour-6.6.0/libs/ardour/ardour/graph.h --- Ardour-6.6.0.orig/libs/ardour/ardour/graph.h 2021-04-21 23:33:55.628176429 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/graph.h 2021-04-21 23:33:10.193293885 -0700 @@ -32,6 +32,7 @@ #include "pbd/mpmc_queue.h" #include "pbd/semutils.h" +#include "pbd/g_atomic_compat.h" #include "ardour/audio_backend.h" #include "ardour/libardour_visibility.h" @@ -91,38 +92,38 @@ private: node_list_t _init_trigger_list[2]; PBD::MPMCQueue _trigger_queue; ///< nodes that can be processed - volatile guint _trigger_queue_size; ///< number of entries in trigger-queue + GATOMIC_QUAL guint _trigger_queue_size; ///< number of entries in trigger-queue /** Start worker threads */ PBD::Semaphore _execution_sem; /** The number of processing threads that are asleep */ - volatile guint _idle_thread_cnt; + GATOMIC_QUAL guint _idle_thread_cnt; /** Signalled to start a run of the graph for a process callback */ PBD::Semaphore _callback_start_sem; PBD::Semaphore _callback_done_sem; /** The number of unprocessed nodes that do not feed any other node; updated during processing */ - volatile guint _terminal_refcnt; + GATOMIC_QUAL guint _terminal_refcnt; /** The initial number of nodes that do not feed any other node (for each chain) */ guint _n_terminal_nodes[2]; bool _graph_empty; /* number of background worker threads >= 0 */ - volatile guint _n_workers; + GATOMIC_QUAL guint _n_workers; /* flag to terminate background threads */ - volatile gint _terminate; + GATOMIC_QUAL gint _terminate; /* chain swapping */ Glib::Threads::Cond _cleanup_cond; mutable Glib::Threads::Mutex _swap_mutex; - volatile int _current_chain; - volatile int _pending_chain; - volatile int _setup_chain; + GATOMIC_QUAL gint _current_chain; + GATOMIC_QUAL gint _pending_chain; + GATOMIC_QUAL gint _setup_chain; /* parameter caches */ pframes_t _process_nframes; diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/graphnode.h Ardour-6.6.0/libs/ardour/ardour/graphnode.h --- Ardour-6.6.0.orig/libs/ardour/ardour/graphnode.h 2021-04-21 23:33:55.628176429 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/graphnode.h 2021-04-21 23:33:10.193293885 -0700 @@ -27,6 +27,8 @@ #include +#include "pbd/g_atomic_compat.h" + namespace ARDOUR { class Graph; @@ -68,8 +70,7 @@ private: void process (); boost::shared_ptr _graph; - - gint _refcount; + GATOMIC_QUAL gint _refcount; }; } diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/meter.h Ardour-6.6.0/libs/ardour/ardour/meter.h --- Ardour-6.6.0.orig/libs/ardour/ardour/meter.h 2021-04-21 23:33:55.628176429 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/meter.h 2021-04-21 23:33:10.194293904 -0700 @@ -25,6 +25,7 @@ #include #include "pbd/fastlog.h" +#include "pbd/g_atomic_compat.h" #include "ardour/libardour_visibility.h" #include "ardour/processor.h" @@ -99,8 +100,8 @@ private: */ ChanCount current_meters; - volatile gint _reset_dpm; - volatile gint _reset_max; + GATOMIC_QUAL gint _reset_dpm; + GATOMIC_QUAL gint _reset_max; uint32_t _bufcnt; std::vector _peak_buffer; // internal, integrate diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/midi_channel_filter.h Ardour-6.6.0/libs/ardour/ardour/midi_channel_filter.h --- Ardour-6.6.0.orig/libs/ardour/ardour/midi_channel_filter.h 2021-04-21 23:33:55.629176449 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/midi_channel_filter.h 2021-04-21 23:33:10.194293904 -0700 @@ -23,8 +23,10 @@ #include -#include "ardour/types.h" #include "pbd/signals.h" +#include "pbd/g_atomic_compat.h" + +#include "ardour/types.h" namespace ARDOUR { @@ -71,24 +73,24 @@ public: /** Atomically get both the channel mode and mask. */ void get_mode_and_mask(ChannelMode* mode, uint16_t* mask) const { - const uint32_t mm = g_atomic_int_get(&_mode_mask); + const uint32_t mm = g_atomic_int_get (&_mode_mask); *mode = static_cast((mm & 0xFFFF0000) >> 16); *mask = (mm & 0x0000FFFF); } ChannelMode get_channel_mode() const { - return static_cast((g_atomic_int_get(&_mode_mask) & 0xFFFF0000) >> 16); + return static_cast((g_atomic_int_get (&_mode_mask) & 0xFFFF0000) >> 16); } uint16_t get_channel_mask() const { - return g_atomic_int_get(&_mode_mask) & 0x0000FFFF; + return g_atomic_int_get (&_mode_mask) & 0x0000FFFF; } PBD::Signal0 ChannelMaskChanged; PBD::Signal0 ChannelModeChanged; private: - uint32_t _mode_mask; ///< 16 bits mode, 16 bits mask + GATOMIC_QUAL uint32_t _mode_mask; ///< 16 bits mode, 16 bits mask }; } /* namespace ARDOUR */ diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/pannable.h Ardour-6.6.0/libs/ardour/ardour/pannable.h --- Ardour-6.6.0.orig/libs/ardour/ardour/pannable.h 2021-04-21 23:33:55.629176449 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/pannable.h 2021-04-21 23:33:10.194293904 -0700 @@ -66,7 +66,7 @@ public: void start_touch (double when); void stop_touch (double when); - bool touching() const { return g_atomic_int_get (const_cast(&_touching)); } + bool touching() const { return g_atomic_int_get (&_touching); } bool writing() const { return _auto_state == Write; } bool touch_enabled() const { return _auto_state & (Touch | Latch); } @@ -80,10 +80,11 @@ protected: boost::weak_ptr _panner; AutoState _auto_state; - gint _touching; bool _has_state; uint32_t _responding_to_control_auto_state_change; + GATOMIC_QUAL gint _touching; + void control_auto_state_changed (AutoState); private: diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/playlist.h Ardour-6.6.0/libs/ardour/ardour/playlist.h --- Ardour-6.6.0.orig/libs/ardour/ardour/playlist.h 2021-04-21 23:33:55.629176449 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/playlist.h 2021-04-21 23:33:10.195293923 -0700 @@ -45,6 +45,7 @@ #include "pbd/stateful.h" #include "pbd/statefuldestructible.h" #include "pbd/undo.h" +#include "pbd/g_atomic_compat.h" #include "evoral/Range.h" @@ -343,8 +344,8 @@ protected: PBD::ScopedConnectionList region_drop_references_connections; DataType _type; uint32_t _sort_id; - mutable gint block_notifications; - mutable gint ignore_state_changes; + mutable GATOMIC_QUAL gint block_notifications; + mutable GATOMIC_QUAL gint ignore_state_changes; std::set > pending_adds; std::set > pending_removes; RegionList pending_bounds; diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/plugin_insert.h Ardour-6.6.0/libs/ardour/ardour/plugin_insert.h --- Ardour-6.6.0.orig/libs/ardour/ardour/plugin_insert.h 2021-04-21 23:33:55.629176449 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/plugin_insert.h 2021-04-21 23:33:10.195293923 -0700 @@ -31,6 +31,7 @@ #include "pbd/stack_allocator.h" #include "pbd/timing.h" +#include "pbd/g_atomic_compat.h" #include "ardour/ardour.h" #include "ardour/libardour_visibility.h" @@ -441,10 +442,9 @@ private: void preset_load_set_value (uint32_t, float); - PBD::TimingStats _timing_stats; - volatile gint _stat_reset; - - volatile gint _flush; + PBD::TimingStats _timing_stats; + GATOMIC_QUAL gint _stat_reset; + GATOMIC_QUAL gint _flush; }; } // namespace ARDOUR diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/port_engine_shared.h Ardour-6.6.0/libs/ardour/ardour/port_engine_shared.h --- Ardour-6.6.0.orig/libs/ardour/ardour/port_engine_shared.h 2021-04-21 23:33:55.629176449 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/port_engine_shared.h 2021-04-21 23:33:10.196293943 -0700 @@ -184,7 +184,7 @@ protected: std::vector _port_connection_queue; pthread_mutex_t _port_callback_mutex; - gint _port_change_flag; /* atomic */ + GATOMIC_QUAL gint _port_change_flag; /* atomic */ void port_connect_callback (const std::string& a, const std::string& b, bool conn) { pthread_mutex_lock (&_port_callback_mutex); diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/port_manager.h Ardour-6.6.0/libs/ardour/ardour/port_manager.h --- Ardour-6.6.0.orig/libs/ardour/ardour/port_manager.h 2021-04-21 23:33:55.630176468 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/port_manager.h 2021-04-21 23:33:10.196293943 -0700 @@ -32,6 +32,7 @@ #include "pbd/natsort.h" #include "pbd/rcu.h" #include "pbd/ringbuffer.h" +#include "pbd/g_atomic_compat.h" #include "ardour/chan_count.h" #include "ardour/midiport_manager.h" @@ -362,7 +363,7 @@ private: SerializedRCUManager _audio_input_ports; SerializedRCUManager _midi_input_ports; - volatile gint _reset_meters; + GATOMIC_QUAL gint _reset_meters; }; } // namespace ARDOUR diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/presentation_info.h Ardour-6.6.0/libs/ardour/ardour/presentation_info.h --- Ardour-6.6.0.orig/libs/ardour/ardour/presentation_info.h 2021-04-21 23:33:55.630176468 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/presentation_info.h 2021-04-21 23:33:10.196293943 -0700 @@ -29,6 +29,7 @@ #include "pbd/signals.h" #include "pbd/stateful.h" #include "pbd/properties.h" +#include "pbd/g_atomic_compat.h" #include "ardour/libardour_visibility.h" @@ -274,7 +275,7 @@ class LIBARDOUR_API PresentationInfo : p static PBD::PropertyChange _pending_static_changes; static Glib::Threads::Mutex static_signal_lock; - static int _change_signal_suspended; + static GATOMIC_QUAL gint _change_signal_suspended; static int selection_counter; }; diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/route.h Ardour-6.6.0/libs/ardour/ardour/route.h --- Ardour-6.6.0.orig/libs/ardour/ardour/route.h 2021-04-21 23:33:55.630176468 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/route.h 2021-04-21 23:33:10.197293962 -0700 @@ -41,6 +41,7 @@ #include "pbd/stateful.h" #include "pbd/controllable.h" #include "pbd/destructible.h" +#include "pbd/g_atomic_compat.h" #include "ardour/ardour.h" #include "ardour/gain_control.h" @@ -646,10 +647,10 @@ protected: EmitRtProcessorChange = 0x04 }; - ProcessorList _pending_processor_order; - gint _pending_process_reorder; // atomic - gint _pending_listen_change; // atomic - gint _pending_signals; // atomic + ProcessorList _pending_processor_order; + GATOMIC_QUAL gint _pending_process_reorder; // atomic + GATOMIC_QUAL gint _pending_listen_change; // atomic + GATOMIC_QUAL gint _pending_signals; // atomic MeterPoint _meter_point; MeterPoint _pending_meter_point; diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/rt_tasklist.h Ardour-6.6.0/libs/ardour/ardour/rt_tasklist.h --- Ardour-6.6.0.orig/libs/ardour/ardour/rt_tasklist.h 2021-04-21 23:33:55.630176468 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/rt_tasklist.h 2021-04-21 23:33:10.197293962 -0700 @@ -23,6 +23,7 @@ #include #include "pbd/semutils.h" +#include "pbd/g_atomic_compat.h" #include "ardour/libardour_visibility.h" #include "ardour/types.h" @@ -44,7 +45,7 @@ public: void process (TaskList const&); private: - gint _threads_active; + GATOMIC_QUAL gint _threads_active; std::vector _threads; void reset_thread_list (); diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/selection.h Ardour-6.6.0/libs/ardour/ardour/selection.h --- Ardour-6.6.0.orig/libs/ardour/ardour/selection.h 2021-04-21 23:33:55.630176468 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/selection.h 2021-04-21 23:33:10.197293962 -0700 @@ -91,8 +91,9 @@ class LIBARDOUR_API CoreSelection : publ private: mutable Glib::Threads::RWLock _lock; + GATOMIC_QUAL gint _selection_order; + Session& session; - int selection_order; struct SelectedStripable { SelectedStripable (boost::shared_ptr, boost::shared_ptr, int); diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/session.h Ardour-6.6.0/libs/ardour/ardour/session.h --- Ardour-6.6.0.orig/libs/ardour/ardour/session.h 2021-04-21 23:33:55.631176488 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/session.h 2021-04-21 23:33:10.198293982 -0700 @@ -62,6 +62,7 @@ #include "pbd/statefuldestructible.h" #include "pbd/signals.h" #include "pbd/undo.h" +#include "pbd/g_atomic_compat.h" #include "lua/luastate.h" @@ -1334,7 +1335,6 @@ private: typedef void (Session::*process_function_type)(pframes_t); AudioEngine& _engine; - mutable gint processing_prohibited; process_function_type process_function; process_function_type last_process_function; bool _bounce_processing_active; @@ -1342,10 +1342,9 @@ private: samplecnt_t _base_sample_rate; // sample-rate of the session at creation time, "native" SR samplecnt_t _nominal_sample_rate; // overridden by audioengine setting samplecnt_t _current_sample_rate; // this includes video pullup offset - mutable gint _record_status; samplepos_t _transport_sample; - gint _seek_counter; - gint _butler_seek_counter; + GATOMIC_QUAL gint _seek_counter; + GATOMIC_QUAL gint _butler_seek_counter; Location* _session_range_location; ///< session range, or 0 if there is nothing in the session yet bool _session_range_is_free; bool _silent; @@ -1379,6 +1378,9 @@ private: std::string _missing_file_replacement; + mutable GATOMIC_QUAL gint _processing_prohibited; + mutable GATOMIC_QUAL gint _record_status; + void add_monitor_section (); void remove_monitor_section (); @@ -1401,9 +1403,9 @@ private: samplecnt_t calc_preroll_subcycle (samplecnt_t) const; - void block_processing() { g_atomic_int_set (&processing_prohibited, 1); } - void unblock_processing() { g_atomic_int_set (&processing_prohibited, 0); } - bool processing_blocked() const { return g_atomic_int_get (&processing_prohibited); } + void block_processing() { g_atomic_int_set (&_processing_prohibited, 1); } + void unblock_processing() { g_atomic_int_set (&_processing_prohibited, 0); } + bool processing_blocked() const { return g_atomic_int_get (&_processing_prohibited); } static const samplecnt_t bounce_chunk_size; @@ -1506,9 +1508,9 @@ private: StateOfTheState _state_of_the_state; friend class StateProtector; - gint _suspend_save; /* atomic */ - volatile bool _save_queued; - volatile bool _save_queued_pending; + GATOMIC_QUAL gint _suspend_save; + volatile bool _save_queued; + volatile bool _save_queued_pending; Glib::Threads::Mutex save_state_lock; Glib::Threads::Mutex save_source_lock; @@ -1547,8 +1549,8 @@ private: static const PostTransportWork ProcessCannotProceedMask = PostTransportWork (PostTransportAudition); - gint _post_transport_work; /* accessed only atomic ops */ - PostTransportWork post_transport_work() const { return (PostTransportWork) g_atomic_int_get (const_cast(&_post_transport_work)); } + GATOMIC_QUAL gint _post_transport_work; /* accessed only atomic ops */ + PostTransportWork post_transport_work() const { return (PostTransportWork) g_atomic_int_get (&_post_transport_work); } void set_post_transport_work (PostTransportWork ptw) { g_atomic_int_set (&_post_transport_work, (gint) ptw); } void add_post_transport_work (PostTransportWork ptw); @@ -1665,9 +1667,9 @@ private: Glib::Threads::Mutex _update_latency_lock; typedef std::queue AutoConnectQueue; - Glib::Threads::Mutex _auto_connect_queue_lock; - AutoConnectQueue _auto_connect_queue; - guint _latency_recompute_pending; + Glib::Threads::Mutex _auto_connect_queue_lock; + AutoConnectQueue _auto_connect_queue; + GATOMIC_QUAL guint _latency_recompute_pending; void get_physical_ports (std::vector& inputs, std::vector& outputs, DataType type, MidiPortFlags include = MidiPortFlags (0), @@ -1788,8 +1790,8 @@ private: OnlyLoop, }; - volatile gint _punch_or_loop; // enum PunchLoopLock - gint current_usecs_per_track; + GATOMIC_QUAL gint _punch_or_loop; // enum PunchLoopLock + GATOMIC_QUAL gint _current_usecs_per_track; bool punch_active () const; void unset_punch (); @@ -1995,8 +1997,8 @@ private: std::string get_best_session_directory_for_new_audio (); - mutable gint _playback_load; - mutable gint _capture_load; + mutable GATOMIC_QUAL gint _playback_load; + mutable GATOMIC_QUAL gint _capture_load; /* I/O bundles */ @@ -2118,8 +2120,8 @@ private: mutable bool have_looped; ///< Used in \ref audible_sample void update_route_record_state (); - gint _have_rec_enabled_track; - gint _have_rec_disabled_track; + GATOMIC_QUAL gint _have_rec_enabled_track; + GATOMIC_QUAL gint _have_rec_disabled_track; static int ask_about_playlist_deletion (boost::shared_ptr); @@ -2166,7 +2168,7 @@ private: uint32_t _step_editors; /** true if timecode transmission by the transport is suspended, otherwise false */ - mutable gint _suspend_timecode_transmission; + mutable GATOMIC_QUAL gint _suspend_timecode_transmission; void update_locations_after_tempo_map_change (const Locations::LocationList &); @@ -2186,9 +2188,9 @@ private: void ensure_route_presentation_info_gap (PresentationInfo::order_t, uint32_t gap_size); - friend class ProcessorChangeBlocker; - gint _ignore_route_processor_changes; /* atomic */ - gint _ignored_a_processor_change; + friend class ProcessorChangeBlocker; + GATOMIC_QUAL gint _ignore_route_processor_changes; + GATOMIC_QUAL gint _ignored_a_processor_change; MidiClockTicker* midi_clock; @@ -2236,7 +2238,7 @@ private: std::string unnamed_file_name () const; - gint _update_pretty_names; + GATOMIC_QUAL gint _update_pretty_names; }; diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/source.h Ardour-6.6.0/libs/ardour/ardour/source.h --- Ardour-6.6.0.orig/libs/ardour/ardour/source.h 2021-04-21 23:33:55.631176488 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/source.h 2021-04-21 23:33:10.199294001 -0700 @@ -31,7 +31,9 @@ #include #include #include + #include "pbd/statefuldestructible.h" +#include "pbd/g_atomic_compat.h" #include "ardour/ardour.h" #include "ardour/session_object.h" @@ -121,7 +123,7 @@ public: virtual void inc_use_count (); virtual void dec_use_count (); - int use_count() const { return g_atomic_int_get (const_cast(&_use_count)); } + int use_count() const { return g_atomic_int_get (&_use_count); } bool used() const { return use_count() > 0; } uint32_t level() const { return _level; } @@ -135,20 +137,21 @@ public: static PBD::Signal1 > SourcePropertyChanged; protected: - DataType _type; - Flag _flags; - time_t _timestamp; - std::string _take_id; - samplepos_t _natural_position; - samplepos_t _have_natural_position; - bool _analysed; - mutable Glib::Threads::Mutex _lock; - mutable Glib::Threads::Mutex _analysis_lock; - gint _use_count; /* atomic */ - uint32_t _level; /* how deeply nested is this source w.r.t a disk file */ - std::string _ancestor_name; - std::string _captured_for; - XrunPositions _xruns; + DataType _type; + Flag _flags; + time_t _timestamp; + std::string _take_id; + samplepos_t _natural_position; + samplepos_t _have_natural_position; + bool _analysed; + GATOMIC_QUAL gint _use_count; /* atomic */ + uint32_t _level; /* how deeply nested is this source w.r.t a disk file */ + std::string _ancestor_name; + std::string _captured_for; + XrunPositions _xruns; + + mutable Glib::Threads::Mutex _lock; + mutable Glib::Threads::Mutex _analysis_lock; private: void fix_writable_flags (); diff -urpN Ardour-6.6.0.orig/libs/ardour/ardour/vst3_host.h Ardour-6.6.0/libs/ardour/ardour/vst3_host.h --- Ardour-6.6.0.orig/libs/ardour/ardour/vst3_host.h 2021-04-21 23:33:55.631176488 -0700 +++ Ardour-6.6.0/libs/ardour/ardour/vst3_host.h 2021-04-21 23:33:10.199294001 -0700 @@ -28,6 +28,7 @@ #include +#include "pbd/g_atomic_compat.h" #include "ardour/libardour_visibility.h" #include "vst3/vst3.h" @@ -151,7 +152,7 @@ public: uint32 PLUGIN_API release () SMTG_OVERRIDE; private: - gint _cnt; // atomic + GATOMIC_QUAL gint _cnt; // atomic }; class LIBARDOUR_API HostAttributeList : public Vst::IAttributeList, public RefObject diff -urpN Ardour-6.6.0.orig/libs/ardour/audioengine.cc Ardour-6.6.0/libs/ardour/audioengine.cc --- Ardour-6.6.0.orig/libs/ardour/audioengine.cc 2021-04-21 23:33:55.632176507 -0700 +++ Ardour-6.6.0/libs/ardour/audioengine.cc 2021-04-21 23:33:10.199294001 -0700 @@ -73,7 +73,7 @@ using namespace PBD; AudioEngine* AudioEngine::_instance = 0; -static gint audioengine_thread_cnt = 1; +static GATOMIC_QUAL gint audioengine_thread_cnt = 1; #ifdef SILENCE_AFTER #define SILENCE_AFTER_SECONDS 600 @@ -99,15 +99,9 @@ AudioEngine::AudioEngine () , _in_destructor (false) , _last_backend_error_string(AudioBackend::get_error_string(AudioBackend::NoError)) , _hw_reset_event_thread(0) - , _hw_reset_request_count(0) - , _stop_hw_reset_processing(0) , _hw_devicelist_update_thread(0) - , _hw_devicelist_update_count(0) - , _stop_hw_devicelist_processing(0) , _start_cnt (0) , _init_countdown (0) - , _pending_playback_latency_callback (0) - , _pending_capture_latency_callback (0) #ifdef SILENCE_AFTER_SECONDS , _silence_countdown (0) , _silence_hit_cnt (0) @@ -116,6 +110,13 @@ AudioEngine::AudioEngine () reset_silence_countdown (); start_hw_event_processing(); discover_backends (); + + g_atomic_int_set (&_hw_reset_request_count, 0); + g_atomic_int_set (&_pending_playback_latency_callback, 0); + g_atomic_int_set (&_pending_capture_latency_callback, 0); + g_atomic_int_set (&_hw_devicelist_update_count, 0); + g_atomic_int_set (&_stop_hw_reset_processing, 0); + g_atomic_int_set (&_stop_hw_devicelist_processing, 0); } AudioEngine::~AudioEngine () @@ -639,7 +640,7 @@ AudioEngine::do_reset_backend() Glib::Threads::Mutex::Lock guard (_reset_request_lock); - while (!_stop_hw_reset_processing) { + while (!g_atomic_int_get (&_stop_hw_reset_processing)) { if (g_atomic_int_get (&_hw_reset_request_count) != 0 && _backend) { @@ -724,14 +725,14 @@ void AudioEngine::start_hw_event_processing() { if (_hw_reset_event_thread == 0) { - g_atomic_int_set(&_hw_reset_request_count, 0); - g_atomic_int_set(&_stop_hw_reset_processing, 0); + g_atomic_int_set (&_hw_reset_request_count, 0); + g_atomic_int_set (&_stop_hw_reset_processing, 0); _hw_reset_event_thread = Glib::Threads::Thread::create (boost::bind (&AudioEngine::do_reset_backend, this)); } if (_hw_devicelist_update_thread == 0) { - g_atomic_int_set(&_hw_devicelist_update_count, 0); - g_atomic_int_set(&_stop_hw_devicelist_processing, 0); + g_atomic_int_set (&_hw_devicelist_update_count, 0); + g_atomic_int_set (&_stop_hw_devicelist_processing, 0); _hw_devicelist_update_thread = Glib::Threads::Thread::create (boost::bind (&AudioEngine::do_devicelist_update, this)); } } @@ -741,16 +742,16 @@ void AudioEngine::stop_hw_event_processing() { if (_hw_reset_event_thread) { - g_atomic_int_set(&_stop_hw_reset_processing, 1); - g_atomic_int_set(&_hw_reset_request_count, 0); + g_atomic_int_set (&_stop_hw_reset_processing, 1); + g_atomic_int_set (&_hw_reset_request_count, 0); _hw_reset_condition.signal (); _hw_reset_event_thread->join (); _hw_reset_event_thread = 0; } if (_hw_devicelist_update_thread) { - g_atomic_int_set(&_stop_hw_devicelist_processing, 1); - g_atomic_int_set(&_hw_devicelist_update_count, 0); + g_atomic_int_set (&_stop_hw_devicelist_processing, 1); + g_atomic_int_set (&_hw_devicelist_update_count, 0); _hw_devicelist_update_condition.signal (); _hw_devicelist_update_thread->join (); _hw_devicelist_update_thread = 0; diff -urpN Ardour-6.6.0.orig/libs/ardour/audio_unit.cc Ardour-6.6.0/libs/ardour/audio_unit.cc --- Ardour-6.6.0.orig/libs/ardour/audio_unit.cc 2021-04-21 23:33:55.632176507 -0700 +++ Ardour-6.6.0/libs/ardour/audio_unit.cc 2021-04-21 23:33:10.200294021 -0700 @@ -435,7 +435,6 @@ AUPlugin::AUPlugin (AudioEngine& engine, , unit (new CAAudioUnit) , initialized (false) , _last_nframes (0) - , _current_latency (UINT_MAX) , _requires_fixed_size_buffers (false) , buffers (0) , variable_inputs (false) @@ -477,7 +476,6 @@ AUPlugin::AUPlugin (const AUPlugin& othe , unit (new CAAudioUnit) , initialized (false) , _last_nframes (0) - , _current_latency (UINT_MAX) , _requires_fixed_size_buffers (false) , buffers (0) , variable_inputs (false) @@ -571,6 +569,8 @@ AUPlugin::discover_factory_presets () void AUPlugin::init () { + g_atomic_int_set (&_current_latency, UINT_MAX); + OSErr err; CFStringRef itemName; diff -urpN Ardour-6.6.0.orig/libs/ardour/auditioner.cc Ardour-6.6.0/libs/ardour/auditioner.cc --- Ardour-6.6.0.orig/libs/ardour/auditioner.cc 2021-04-21 23:33:55.632176507 -0700 +++ Ardour-6.6.0/libs/ardour/auditioner.cc 2021-04-21 23:33:10.201294040 -0700 @@ -51,7 +51,6 @@ using namespace PBD; Auditioner::Auditioner (Session& s) : Track (s, "auditioner", PresentationInfo::Auditioner) , current_sample (0) - , _auditioning (0) , length (0) , _seek_sample (-1) , _seeking (false) @@ -61,6 +60,7 @@ Auditioner::Auditioner (Session& s) , _queue_panic (false) , _import_position (0) { + g_atomic_int_set (&_auditioning, 0); } int diff -urpN Ardour-6.6.0.orig/libs/ardour/butler.cc Ardour-6.6.0/libs/ardour/butler.cc --- Ardour-6.6.0.orig/libs/ardour/butler.cc 2021-04-21 23:33:55.633176526 -0700 +++ Ardour-6.6.0/libs/ardour/butler.cc 2021-04-21 23:33:10.201294040 -0700 @@ -56,11 +56,11 @@ Butler::Butler(Session& s) , pool_trash(16) , _xthread (true) { - g_atomic_int_set(&should_do_transport_work, 0); + g_atomic_int_set (&should_do_transport_work, 0); SessionEvent::pool->set_trash (&pool_trash); - /* catch future changes to parameters */ - Config->ParameterChanged.connect_same_thread (*this, boost::bind (&Butler::config_changed, this, _1)); + /* catch future changes to parameters */ + Config->ParameterChanged.connect_same_thread (*this, boost::bind (&Butler::config_changed, this, _1)); } Butler::~Butler() @@ -466,7 +466,7 @@ Butler::wait_until_finished () bool Butler::transport_work_requested () const { - return g_atomic_int_get(&should_do_transport_work); + return g_atomic_int_get (&should_do_transport_work); } void diff -urpN Ardour-6.6.0.orig/libs/ardour/disk_reader.cc Ardour-6.6.0/libs/ardour/disk_reader.cc --- Ardour-6.6.0.orig/libs/ardour/disk_reader.cc 2021-04-21 23:33:55.633176526 -0700 +++ Ardour-6.6.0/libs/ardour/disk_reader.cc 2021-04-21 23:33:10.201294040 -0700 @@ -52,7 +52,7 @@ PBD::Signal0 DiskReader::Underr Sample* DiskReader::_sum_buffer = 0; Sample* DiskReader::_mixdown_buffer = 0; gain_t* DiskReader::_gain_buffer = 0; -gint DiskReader::_no_disk_output (0); +GATOMIC_QUAL gint DiskReader::_no_disk_output (0); DiskReader::Declicker DiskReader::loop_declick_in; DiskReader::Declicker DiskReader::loop_declick_out; samplecnt_t DiskReader::loop_fade_length (0); @@ -275,6 +275,7 @@ DiskReader::run (BufferSet& bufs, sample sampleoffset_t disk_samples_to_consume; MonitorState ms = _track.monitoring_state (); const bool midi_only = (c->empty() || !_playlists[DataType::AUDIO]); + bool no_disk_output = g_atomic_int_get (&_no_disk_output) != 0; if (_active) { if (!_pending_active) { @@ -358,10 +359,10 @@ DiskReader::run (BufferSet& bufs, sample _declick_offs = 0; } - if (!result_required || ((ms & MonitoringDisk) == 0) || still_locating || _no_disk_output) { + if (!result_required || ((ms & MonitoringDisk) == 0) || still_locating || no_disk_output) { /* no need for actual disk data, just advance read pointer */ - if (!still_locating || _no_disk_output) { + if (!still_locating || no_disk_output) { for (ChannelList::iterator chan = c->begin (); chan != c->end (); ++chan) { assert ((*chan)->rbuf); (*chan)->rbuf->increment_read_ptr (disk_samples_to_consume); @@ -370,7 +371,7 @@ DiskReader::run (BufferSet& bufs, sample /* if monitoring disk but locating put silence in the buffers */ - if ((_no_disk_output || still_locating) && (ms == MonitoringDisk)) { + if ((no_disk_output || still_locating) && (ms == MonitoringDisk)) { bufs.silence (nframes, 0); } @@ -473,7 +474,7 @@ midi: run_must_resolve = false; } - if (!_no_disk_output && !declick_in_progress () && (ms & MonitoringDisk) && !still_locating && no_playlist_modification_pending && speed) { + if (!no_disk_output && !declick_in_progress () && (ms & MonitoringDisk) && !still_locating && no_playlist_modification_pending && speed) { get_midi_playback (dst, start_sample, end_sample, ms, scratch_bufs, speed, disk_samples_to_consume); } } @@ -1468,7 +1469,7 @@ DiskReader::get_midi_playback (MidiBuffe target = &dst; } - if (!_no_disk_output) { + if (!g_atomic_int_get (&_no_disk_output)) { const samplecnt_t nframes = abs (end_sample - start_sample); if (ms & MonitoringDisk) { diff -urpN Ardour-6.6.0.orig/libs/ardour/disk_writer.cc Ardour-6.6.0/libs/ardour/disk_writer.cc --- Ardour-6.6.0.orig/libs/ardour/disk_writer.cc 2021-04-21 23:33:55.633176526 -0700 +++ Ardour-6.6.0/libs/ardour/disk_writer.cc 2021-04-21 23:33:10.202294059 -0700 @@ -48,8 +48,6 @@ PBD::Signal0 DiskWriter::Overrun; DiskWriter::DiskWriter (Session& s, Track& t, string const & str, DiskIOProcessor::Flag f) : DiskIOProcessor (s, t, X_("recorder:") + str, f) - , _record_enabled (0) - , _record_safe (0) , _capture_start_sample (0) , _capture_captured (0) , _was_recording (false) @@ -59,8 +57,6 @@ DiskWriter::DiskWriter (Session& s, Trac , _last_possibly_recording (0) , _alignment_style (ExistingMaterial) , _note_mode (Sustained) - , _samples_pending_write (0) - , _num_captured_loops (0) , _accumulated_capture_offset (0) , _transport_looped (false) , _transport_loop_sample (0) @@ -68,6 +64,11 @@ DiskWriter::DiskWriter (Session& s, Trac { DiskIOProcessor::init (); _xruns.reserve (128); + + g_atomic_int_set (&_record_enabled, 0); + g_atomic_int_set (&_record_safe, 0); + g_atomic_int_set (&_samples_pending_write, 0); + g_atomic_int_set (&_num_captured_loops, 0); } DiskWriter::~DiskWriter () @@ -323,7 +324,7 @@ DiskWriter::state () { XMLNode& node (DiskIOProcessor::state ()); node.set_property (X_("type"), X_("diskwriter")); - node.set_property (X_("record-safe"), (_record_safe ? X_("yes" : "no"))); + node.set_property (X_("record-safe"), record_safe ()); return node; } @@ -334,9 +335,9 @@ DiskWriter::set_state (const XMLNode& no return -1; } - if (!node.get_property (X_("record-safe"), _record_safe)) { - _record_safe = false; - } + int rec_safe = 0; + node.get_property (X_("record-safe"), rec_safe); + g_atomic_int_set (&_record_safe, rec_safe); reset_write_sources (false, true); @@ -476,8 +477,8 @@ DiskWriter::run (BufferSet& bufs, sample _midi_write_source->mark_write_starting_now (_capture_start_sample, _capture_captured, loop_length); } - g_atomic_int_set (const_cast (&_samples_pending_write), 0); - g_atomic_int_set (const_cast (&_num_captured_loops), 0); + g_atomic_int_set (&_samples_pending_write, 0); + g_atomic_int_set (&_num_captured_loops, 0); _was_recording = true; @@ -581,7 +582,7 @@ DiskWriter::run (BufferSet& bufs, sample reconstruct their actual time; future clever MIDI looping should probably be implemented in the source instead of here. */ - const samplecnt_t loop_offset = _num_captured_loops * loop_length; + const samplecnt_t loop_offset = g_atomic_int_get (&_num_captured_loops) * loop_length; const samplepos_t event_time = start_sample + loop_offset - _accumulated_capture_offset + ev.time(); if (event_time < 0 || event_time < _first_recordable_sample) { /* Event out of range, skip */ @@ -607,7 +608,7 @@ DiskWriter::run (BufferSet& bufs, sample } } - g_atomic_int_add (const_cast(&_samples_pending_write), nframes); + g_atomic_int_add (&_samples_pending_write, nframes); if (buf.size() != 0) { Glib::Threads::Mutex::Lock lm (_gui_feed_buffer_mutex, Glib::Threads::TRY_LOCK); @@ -693,7 +694,7 @@ DiskWriter::finish_capture (boost::share samplepos_t loop_end = 0; samplepos_t loop_length = 0; get_location_times (_loop_location, &loop_start, &loop_end, &loop_length); - ci->loop_offset = _num_captured_loops * loop_length; + ci->loop_offset = g_atomic_int_get (&_num_captured_loops) * loop_length; } else { ci->loop_offset = 0; } @@ -931,7 +932,7 @@ DiskWriter::do_flush (RunContext ctxt, b if (_midi_write_source && _midi_buf) { - const samplecnt_t total = g_atomic_int_get(const_cast (&_samples_pending_write)); + const samplecnt_t total = g_atomic_int_get(&_samples_pending_write); if (total == 0 || _midi_buf->read_space() == 0 || @@ -967,7 +968,7 @@ DiskWriter::do_flush (RunContext ctxt, b error << string_compose(_("MidiDiskstream %1: cannot write to disk"), id()) << endmsg; return -1; } - g_atomic_int_add(const_cast (&_samples_pending_write), -to_write); + g_atomic_int_add(&_samples_pending_write, -to_write); } } @@ -1286,7 +1287,7 @@ DiskWriter::loop (samplepos_t transport_ the Source and/or entirely after the capture is finished. */ if (_was_recording) { - g_atomic_int_add(const_cast (&_num_captured_loops), 1); + g_atomic_int_add (&_num_captured_loops, 1); } } diff -urpN Ardour-6.6.0.orig/libs/ardour/graph.cc Ardour-6.6.0/libs/ardour/graph.cc --- Ardour-6.6.0.orig/libs/ardour/graph.cc 2021-04-21 23:33:55.633176526 -0700 +++ Ardour-6.6.0/libs/ardour/graph.cc 2021-04-21 23:33:10.202294059 -0700 @@ -420,7 +420,7 @@ Graph::run_one () while (!to_run) { /* Wait for work, fall asleep */ g_atomic_int_inc (&_idle_thread_cnt); - assert (g_atomic_uint_get (&_idle_thread_cnt) <= _n_workers); + assert (g_atomic_uint_get (&_idle_thread_cnt) <= g_atomic_uint_get (&_n_workers)); DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 goes to sleep\n", pthread_name ())); _execution_sem.wait (); diff -urpN Ardour-6.6.0.orig/libs/ardour/graphnode.cc Ardour-6.6.0/libs/ardour/graphnode.cc --- Ardour-6.6.0.orig/libs/ardour/graphnode.cc 2021-04-21 23:33:55.633176526 -0700 +++ Ardour-6.6.0/libs/ardour/graphnode.cc 2021-04-21 23:33:10.203294079 -0700 @@ -27,6 +27,7 @@ using namespace ARDOUR; GraphNode::GraphNode (boost::shared_ptr graph) : _graph (graph) { + g_atomic_int_set (&_refcount, 0); } GraphNode::~GraphNode () diff -urpN Ardour-6.6.0.orig/libs/ardour/meter.cc Ardour-6.6.0/libs/ardour/meter.cc --- Ardour-6.6.0.orig/libs/ardour/meter.cc 2021-04-21 23:33:55.634176546 -0700 +++ Ardour-6.6.0/libs/ardour/meter.cc 2021-04-21 23:33:10.203294079 -0700 @@ -51,10 +51,11 @@ PeakMeter::PeakMeter (Session& s, const _pending_active = true; _meter_type = MeterPeak; - _reset_dpm = 1; - _reset_max = 1; _bufcnt = 0; _combined_peak = 0; + + g_atomic_int_set (&_reset_dpm, 1); + g_atomic_int_set (&_reset_max, 1); } PeakMeter::~PeakMeter () diff -urpN Ardour-6.6.0.orig/libs/ardour/midi_channel_filter.cc Ardour-6.6.0/libs/ardour/midi_channel_filter.cc --- Ardour-6.6.0.orig/libs/ardour/midi_channel_filter.cc 2021-04-21 23:33:55.634176546 -0700 +++ Ardour-6.6.0/libs/ardour/midi_channel_filter.cc 2021-04-21 23:33:10.203294079 -0700 @@ -24,8 +24,9 @@ namespace ARDOUR { MidiChannelFilter::MidiChannelFilter() - : _mode_mask(0x0000FFFF) -{} +{ + g_atomic_int_set (&_mode_mask, 0x0000FFFF); +} void MidiChannelFilter::filter(BufferSet& bufs) @@ -114,7 +115,7 @@ MidiChannelFilter::set_channel_mode(Chan if (old_mode != mode || old_mask != mask) { mask = force_mask(mode, mask); - g_atomic_int_set(&_mode_mask, (uint32_t(mode) << 16) | uint32_t(mask)); + g_atomic_int_set (&_mode_mask, (uint32_t(mode) << 16) | uint32_t(mask)); ChannelModeChanged(); return true; } @@ -131,7 +132,7 @@ MidiChannelFilter::set_channel_mask(uint if (old_mask != mask) { mask = force_mask(mode, mask); - g_atomic_int_set(&_mode_mask, (uint32_t(mode) << 16) | uint32_t(mask)); + g_atomic_int_set (&_mode_mask, (uint32_t(mode) << 16) | uint32_t(mask)); ChannelMaskChanged(); return true; } diff -urpN Ardour-6.6.0.orig/libs/ardour/plugin_insert.cc Ardour-6.6.0/libs/ardour/plugin_insert.cc --- Ardour-6.6.0.orig/libs/ardour/plugin_insert.cc 2021-04-21 23:33:55.634176546 -0700 +++ Ardour-6.6.0/libs/ardour/plugin_insert.cc 2021-04-21 23:33:10.204294098 -0700 @@ -90,11 +90,11 @@ PluginInsert::PluginInsert (Session& s, , _latency_changed (false) , _bypass_port (UINT32_MAX) , _inverted_bypass_enable (false) - , _stat_reset (0) - , _flush (0) { - /* the first is the master */ + g_atomic_int_set (&_stat_reset, 0); + g_atomic_int_set (&_flush, 0); + /* the first is the master */ if (plug) { add_plugin (plug); create_automatable_parameters (); diff -urpN Ardour-6.6.0.orig/libs/ardour/port_engine_shared.cc Ardour-6.6.0/libs/ardour/port_engine_shared.cc --- Ardour-6.6.0.orig/libs/ardour/port_engine_shared.cc 2021-04-21 23:33:55.634176546 -0700 +++ Ardour-6.6.0/libs/ardour/port_engine_shared.cc 2021-04-21 23:33:10.205294118 -0700 @@ -190,10 +190,10 @@ BackendPort::update_connected_latency (b PortEngineSharedImpl::PortEngineSharedImpl (PortManager& mgr, std::string const & str) : _instance_name (str) - , _port_change_flag (0) , _portmap (new PortMap) , _ports (new PortIndex) { + g_atomic_int_set (&_port_change_flag, 0); pthread_mutex_init (&_port_callback_mutex, 0); } diff -urpN Ardour-6.6.0.orig/libs/ardour/port_manager.cc Ardour-6.6.0/libs/ardour/port_manager.cc --- Ardour-6.6.0.orig/libs/ardour/port_manager.cc 2021-04-21 23:33:55.635176565 -0700 +++ Ardour-6.6.0/libs/ardour/port_manager.cc 2021-04-21 23:33:10.205294118 -0700 @@ -144,8 +144,8 @@ PortManager::PortManager () , _midi_info_dirty (true) , _audio_input_ports (new AudioInputPorts) , _midi_input_ports (new MIDIInputPorts) - , _reset_meters (0) { + g_atomic_int_set (&_reset_meters, 1); load_port_info (); } diff -urpN Ardour-6.6.0.orig/libs/ardour/presentation_info.cc Ardour-6.6.0/libs/ardour/presentation_info.cc --- Ardour-6.6.0.orig/libs/ardour/presentation_info.cc 2021-04-21 23:33:55.635176565 -0700 +++ Ardour-6.6.0/libs/ardour/presentation_info.cc 2021-04-21 23:33:10.205294118 -0700 @@ -48,7 +48,7 @@ string PresentationInfo::state_node_name PBD::Signal1 PresentationInfo::Change; Glib::Threads::Mutex PresentationInfo::static_signal_lock; -int PresentationInfo::_change_signal_suspended = 0; +GATOMIC_QUAL gint PresentationInfo::_change_signal_suspended = 0; PBD::PropertyChange PresentationInfo::_pending_static_changes; int PresentationInfo::selection_counter= 0; @@ -71,7 +71,7 @@ PresentationInfo::unsuspend_change_signa { Glib::Threads::Mutex::Lock lm (static_signal_lock); - if (g_atomic_int_get (const_cast (&_change_signal_suspended)) == 1) { + if (g_atomic_int_get (&_change_signal_suspended) == 1) { /* atomically grab currently pending flags */ @@ -93,7 +93,7 @@ PresentationInfo::unsuspend_change_signa } } - g_atomic_int_add (const_cast(&_change_signal_suspended), -1); + g_atomic_int_add (&_change_signal_suspended, -1); } void diff -urpN Ardour-6.6.0.orig/libs/ardour/route.cc Ardour-6.6.0/libs/ardour/route.cc --- Ardour-6.6.0.orig/libs/ardour/route.cc 2021-04-21 23:33:55.635176565 -0700 +++ Ardour-6.6.0/libs/ardour/route.cc 2021-04-21 23:33:10.206294137 -0700 @@ -114,9 +114,6 @@ Route::Route (Session& sess, string name , _active (true) , _signal_latency (0) , _disk_io_point (DiskIOPreFader) - , _pending_process_reorder (0) - , _pending_listen_change (0) - , _pending_signals (0) , _meter_point (MeterPostFader) , _pending_meter_point (MeterPostFader) , _denormal_protection (false) @@ -136,6 +133,10 @@ Route::Route (Session& sess, string name , _patch_selector_dialog (0) { processor_max_streams.reset(); + + g_atomic_int_set (&_pending_process_reorder, 0); + g_atomic_int_set (&_pending_listen_change, 0); + g_atomic_int_set (&_pending_signals, 0); } boost::weak_ptr diff -urpN Ardour-6.6.0.orig/libs/ardour/rt_tasklist.cc Ardour-6.6.0/libs/ardour/rt_tasklist.cc --- Ardour-6.6.0.orig/libs/ardour/rt_tasklist.cc 2021-04-21 23:33:55.636176585 -0700 +++ Ardour-6.6.0/libs/ardour/rt_tasklist.cc 2021-04-21 23:33:10.207294157 -0700 @@ -30,10 +30,10 @@ using namespace ARDOUR; RTTaskList::RTTaskList () - : _threads_active (0) - , _task_run_sem ("rt_task_run", 0) + : _task_run_sem ("rt_task_run", 0) , _task_end_sem ("rt_task_done", 0) { + g_atomic_int_set (&_threads_active, 0); reset_thread_list (); } diff -urpN Ardour-6.6.0.orig/libs/ardour/selection.cc Ardour-6.6.0/libs/ardour/selection.cc --- Ardour-6.6.0.orig/libs/ardour/selection.cc 2021-04-21 23:33:55.636176585 -0700 +++ Ardour-6.6.0/libs/ardour/selection.cc 2021-04-21 23:33:10.207294157 -0700 @@ -45,8 +45,8 @@ CoreSelection::send_selection_change () CoreSelection::CoreSelection (Session& s) : session (s) - , selection_order (0) { + g_atomic_int_set (&_selection_order, 0); } CoreSelection::~CoreSelection () @@ -246,7 +246,7 @@ CoreSelection::set (StripableList& sl) for (StripableList::iterator s = sl.begin(); s != sl.end(); ++s) { - SelectedStripable ss (*s, no_control, g_atomic_int_add (&selection_order, 1)); + SelectedStripable ss (*s, no_control, g_atomic_int_add (&_selection_order, 1)); if (_stripables.insert (ss).second) { DEBUG_TRACE (DEBUG::Selection, string_compose ("set:added %1 to s/c selection\n", (*s)->name())); @@ -293,7 +293,7 @@ CoreSelection::add (boost::shared_ptrname(), c)); @@ -355,7 +355,7 @@ CoreSelection::set (boost::shared_ptr(&_have_rec_enabled_track)) == 1; + return g_atomic_int_get (&_have_rec_enabled_track) == 1; } bool Session::have_rec_disabled_track () const { - return g_atomic_int_get (const_cast(&_have_rec_disabled_track)) == 1; + return g_atomic_int_get (&_have_rec_disabled_track) == 1; } /** Update the state of our rec-enabled tracks flag */ @@ -7150,7 +7152,6 @@ Session::auto_connect_thread_run () } } - if (_midi_ports && g_atomic_int_get (&_update_pretty_names)) { boost::shared_ptr ap = boost::dynamic_pointer_cast (vkbd_output_port ()); if (ap->pretty_name () != _("Virtual Keyboard")) { diff -urpN Ardour-6.6.0.orig/libs/ardour/session_process.cc Ardour-6.6.0/libs/ardour/session_process.cc --- Ardour-6.6.0.orig/libs/ardour/session_process.cc 2021-04-21 23:33:55.637176604 -0700 +++ Ardour-6.6.0/libs/ardour/session_process.cc 2021-04-21 23:33:10.209294195 -0700 @@ -1357,7 +1357,7 @@ Session::plan_master_strategy (pframes_t * session (so far). */ - locate_target += wlp + lrintf (ntracks() * sample_rate() * (1.5 * (current_usecs_per_track / 1000000.0))); + locate_target += wlp + lrintf (ntracks() * sample_rate() * (1.5 * (g_atomic_int_get (&_current_usecs_per_track) / 1000000.0))); DEBUG_TRACE (DEBUG::Slave, string_compose ("After locate-to-catch-master, still too far off (%1). Locate again to %2\n", delta, locate_target)); @@ -1415,7 +1415,7 @@ Session::plan_master_strategy (pframes_t samplepos_t locate_target = master_transport_sample; - locate_target += wlp + lrintf (ntracks() * sample_rate() * (1.5 * (current_usecs_per_track / 1000000.0))); + locate_target += wlp + lrintf (ntracks() * sample_rate() * (1.5 * (g_atomic_int_get (&_current_usecs_per_track) / 1000000.0))); DEBUG_TRACE (DEBUG::Slave, string_compose ("request locate to master position %1\n", locate_target)); diff -urpN Ardour-6.6.0.orig/libs/ardour/session_state.cc Ardour-6.6.0/libs/ardour/session_state.cc --- Ardour-6.6.0.orig/libs/ardour/session_state.cc 2021-04-21 23:33:55.638176623 -0700 +++ Ardour-6.6.0/libs/ardour/session_state.cc 2021-04-21 23:33:10.210294215 -0700 @@ -178,7 +178,7 @@ Session::pre_engine_init (string fullpat */ timerclear (&last_mmc_step); - g_atomic_int_set (&processing_prohibited, 0); + g_atomic_int_set (&_processing_prohibited, 0); g_atomic_int_set (&_record_status, Disabled); g_atomic_int_set (&_playback_load, 100); g_atomic_int_set (&_capture_load, 100); diff -urpN Ardour-6.6.0.orig/libs/ardour/session_transport.cc Ardour-6.6.0/libs/ardour/session_transport.cc --- Ardour-6.6.0.orig/libs/ardour/session_transport.cc 2021-04-21 23:33:55.638176623 -0700 +++ Ardour-6.6.0/libs/ardour/session_transport.cc 2021-04-21 23:33:10.211294234 -0700 @@ -1323,8 +1323,8 @@ Session::non_realtime_locate () #ifndef NDEBUG std::cerr << "locate to " << tf << " took " << (end - start) << " usecs for " << nt << " tracks = " << usecs_per_track << " per track\n"; #endif - if (usecs_per_track > g_atomic_int_get (¤t_usecs_per_track)) { - g_atomic_int_set (¤t_usecs_per_track, usecs_per_track); + if (usecs_per_track > g_atomic_int_get (&_current_usecs_per_track)) { + g_atomic_int_set (&_current_usecs_per_track, usecs_per_track); } } diff -urpN Ardour-6.6.0.orig/libs/ardour/source.cc Ardour-6.6.0/libs/ardour/source.cc --- Ardour-6.6.0.orig/libs/ardour/source.cc 2021-04-21 23:33:55.639176643 -0700 +++ Ardour-6.6.0/libs/ardour/source.cc 2021-04-21 23:33:10.211294234 -0700 @@ -67,11 +67,12 @@ Source::Source (Session& s, DataType typ , _flags(flags) , _natural_position(0) , _have_natural_position (false) - , _use_count (0) , _level (0) { + g_atomic_int_set (&_use_count, 0); _analysed = false; _timestamp = 0; + fix_writable_flags (); } @@ -81,11 +82,11 @@ Source::Source (Session& s, const XMLNod , _flags (Flag (Writable|CanRename)) , _natural_position(0) , _have_natural_position (false) - , _use_count (0) , _level (0) { - _timestamp = 0; + g_atomic_int_set (&_use_count, 0); _analysed = false; + _timestamp = 0; if (set_state (node, Stateful::loading_state_version) || _type == DataType::NIL) { throw failed_constructor(); diff -urpN Ardour-6.6.0.orig/libs/audiographer/audiographer/general/threader.h Ardour-6.6.0/libs/audiographer/audiographer/general/threader.h --- Ardour-6.6.0.orig/libs/audiographer/audiographer/general/threader.h 2021-04-21 23:33:55.639176643 -0700 +++ Ardour-6.6.0/libs/audiographer/audiographer/general/threader.h 2021-04-21 23:33:10.211294234 -0700 @@ -10,6 +10,8 @@ #include #include +#include "pbd/g_atomic_compat.h" + #include "audiographer/visibility.h" #include "audiographer/source.h" #include "audiographer/sink.h" @@ -47,9 +49,10 @@ class /*LIBAUDIOGRAPHER_API*/ Threader : */ Threader (Glib::ThreadPool & thread_pool, long wait_timeout_milliseconds = 500) : thread_pool (thread_pool) - , readers (0) , wait_timeout (wait_timeout_milliseconds) - { } + { + g_atomic_int_set (&readers, 0); + } virtual ~Threader () {} @@ -117,13 +120,14 @@ class /*LIBAUDIOGRAPHER_API*/ Threader : OutputVec outputs; - Glib::ThreadPool & thread_pool; - Glib::Threads::Mutex wait_mutex; - Glib::Threads::Cond wait_cond; - gint readers; - long wait_timeout; + Glib::ThreadPool& thread_pool; + Glib::Threads::Mutex wait_mutex; + Glib::Threads::Cond wait_cond; + + GATOMIC_QUAL gint readers; + long wait_timeout; - Glib::Threads::Mutex exception_mutex; + Glib::Threads::Mutex exception_mutex; boost::shared_ptr exception; }; diff -urpN Ardour-6.6.0.orig/libs/backends/alsa/alsa_slave.cc Ardour-6.6.0/libs/backends/alsa/alsa_slave.cc --- Ardour-6.6.0.orig/libs/backends/alsa/alsa_slave.cc 2021-04-21 23:33:55.639176643 -0700 +++ Ardour-6.6.0/libs/backends/alsa/alsa_slave.cc 2021-04-21 23:33:10.212294254 -0700 @@ -45,7 +45,6 @@ AlsaAudioSlave::AlsaAudioSlave ( , _samples_since_dll_reset (0) , _ratio (1.0) , _slave_speed (1.0) - , _draining (1) , _rb_capture (4 * /* AlsaAudioBackend::_max_buffer_size */ 8192 * _pcmi.ncapt ()) , _rb_playback (4 * /* AlsaAudioBackend::_max_buffer_size */ 8192 * _pcmi.nplay ()) , _samples_per_period (master_samples_per_period) @@ -53,6 +52,8 @@ AlsaAudioSlave::AlsaAudioSlave ( , _play_buff (0) , _src_buff (0) { + g_atomic_int_set (&_draining, 1); + if (0 != _pcmi.state()) { return; } @@ -266,7 +267,7 @@ AlsaAudioSlave::process_thread () _rb_capture.increment_write_idx (spp * nchn); #endif } else { - g_atomic_int_set(&_draining, 1); + g_atomic_int_set (&_draining, 1); } _pcmi.capt_done (spp); @@ -341,7 +342,7 @@ AlsaAudioSlave::process_thread () if (xrun && (_pcmi.capt_xrun() > 0 || _pcmi.play_xrun() > 0)) { reset_dll = true; _samples_since_dll_reset = 0; - g_atomic_int_set(&_draining, 1); + g_atomic_int_set (&_draining, 1); } } @@ -372,7 +373,7 @@ AlsaAudioSlave::cycle_start (double tme, } if (drain) { - g_atomic_int_set(&_draining, 1); + g_atomic_int_set (&_draining, 1); return; } @@ -501,11 +502,11 @@ AlsaAudioSlave::cycle_end () #ifndef NDEBUG std::cerr << "ALSA Slave: Playback Ringbuffer Overflow\n"; // XXX DEBUG #endif - g_atomic_int_set(&_draining, 1); + g_atomic_int_set (&_draining, 1); return; } if (drain_done) { - g_atomic_int_set(&_draining, 0); + g_atomic_int_set (&_draining, 0); } } @@ -513,7 +514,7 @@ void AlsaAudioSlave::freewheel (bool onoff) { if (onoff) { - g_atomic_int_set(&_draining, 1); + g_atomic_int_set (&_draining, 1); } } diff -urpN Ardour-6.6.0.orig/libs/backends/alsa/alsa_slave.h Ardour-6.6.0/libs/backends/alsa/alsa_slave.h --- Ardour-6.6.0.orig/libs/backends/alsa/alsa_slave.h 2021-04-21 23:33:55.639176643 -0700 +++ Ardour-6.6.0/libs/backends/alsa/alsa_slave.h 2021-04-21 23:33:10.212294254 -0700 @@ -22,6 +22,8 @@ #include #include "pbd/ringbuffer.h" +#include "pbd/g_atomic_compat.h" + #include "zita-resampler/vresampler.h" #include "zita-alsa-pcmi.h" @@ -81,7 +83,8 @@ private: double _play_latency; volatile double _slave_speed; - volatile gint _draining; + + GATOMIC_QUAL gint _draining; PBD::RingBuffer _rb_capture; PBD::RingBuffer _rb_playback; diff -urpN Ardour-6.6.0.orig/libs/evoral/Event.cc Ardour-6.6.0/libs/evoral/Event.cc --- Ardour-6.6.0.orig/libs/evoral/Event.cc 2021-04-21 23:33:55.639176643 -0700 +++ Ardour-6.6.0/libs/evoral/Event.cc 2021-04-21 23:33:10.213294273 -0700 @@ -21,12 +21,13 @@ #include +#include "pbd/g_atomic_compat.h" #include "temporal/beats.h" #include "evoral/Event.h" namespace Evoral { -static event_id_t _event_id_counter = 0; +static GATOMIC_QUAL event_id_t _event_id_counter = 0; event_id_t event_id_counter() diff -urpN Ardour-6.6.0.orig/libs/pbd/pbd/atomic_counter.h Ardour-6.6.0/libs/pbd/pbd/atomic_counter.h --- Ardour-6.6.0.orig/libs/pbd/pbd/atomic_counter.h 2021-04-21 23:33:55.639176643 -0700 +++ Ardour-6.6.0/libs/pbd/pbd/atomic_counter.h 2021-04-21 23:33:10.213294273 -0700 @@ -20,10 +20,11 @@ #ifndef PBD_ATOMIC_COUNTER_H #define PBD_ATOMIC_COUNTER_H -#include +#include "pbd/g_atomic_compat.h" namespace PBD { +#include class atomic_counter { /** @@ -35,13 +36,13 @@ class atomic_counter public: atomic_counter (gint value = 0) - : - m_value(value) - { } + { + g_atomic_int_set (&m_value, value); + } gint get() const { - return g_atomic_int_get (const_cast(&m_value)); + return g_atomic_int_get (&m_value); } void set (gint new_value) @@ -88,10 +89,7 @@ public: } private: - - // Has to be mutable when using the apple version of gcc. - gint m_value; - + mutable GATOMIC_QUAL gint m_value; }; } // namespace PBD diff -urpN Ardour-6.6.0.orig/libs/pbd/pbd/g_atomic_compat.h Ardour-6.6.0/libs/pbd/pbd/g_atomic_compat.h --- Ardour-6.6.0.orig/libs/pbd/pbd/g_atomic_compat.h 1969-12-31 16:00:00.000000000 -0800 +++ Ardour-6.6.0/libs/pbd/pbd/g_atomic_compat.h 2021-04-21 23:33:10.225294506 -0700 @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2021 Robin Gareus + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _PBD_G_ATOMIC_COMPAT_H_ +#define _PBD_G_ATOMIC_COMPAT_H_ + +/* requires for gint, guint, gpointer */ +#include + +/* This is to for g_atomic_* compatibility with glib >= 2.68 and gcc-11 + * + * "While atomic has a volatile qualifier, this is a historical artifact and the pointer passed to it should not be volatile." + * (https://developer.gnome.org/glib/2.68/glib-Atomic-Operations.html) + * + * Older versions of glib and older compilers still expect a volatile qualifier and print + * "cast from type 'volatile long int*' to type 'long int*' casts away qualifiers [-Wcast-qual]" + */ +#if defined HAVE_GLIB_2_68 && (defined(__cplusplus) && __cplusplus >= 201103L) +# define GATOMIC_QUAL +#else +# define GATOMIC_QUAL volatile +#endif + +#endif diff -urpN Ardour-6.6.0.orig/libs/pbd/pbd/mpmc_queue.h Ardour-6.6.0/libs/pbd/pbd/mpmc_queue.h --- Ardour-6.6.0.orig/libs/pbd/pbd/mpmc_queue.h 2021-04-21 23:33:55.639176643 -0700 +++ Ardour-6.6.0/libs/pbd/pbd/mpmc_queue.h 2021-04-21 23:33:10.214294292 -0700 @@ -23,6 +23,8 @@ #include #include +#include "pbd/g_atomic_compat.h" + namespace PBD { /** Lock free multiple producer, multiple consumer queue @@ -131,15 +133,15 @@ public: private: struct cell_t { - volatile guint _sequence; - T _data; + GATOMIC_QUAL guint _sequence; + T _data; }; cell_t* _buffer; size_t _buffer_mask; - volatile gint _enqueue_pos; - volatile gint _dequeue_pos; + GATOMIC_QUAL gint _enqueue_pos; + GATOMIC_QUAL gint _dequeue_pos; }; } /* end namespace */ diff -urpN Ardour-6.6.0.orig/libs/pbd/pbd/playback_buffer.h Ardour-6.6.0/libs/pbd/pbd/playback_buffer.h --- Ardour-6.6.0.orig/libs/pbd/pbd/playback_buffer.h 2021-04-21 23:33:55.640176662 -0700 +++ Ardour-6.6.0/libs/pbd/pbd/playback_buffer.h 2021-04-21 23:33:10.214294292 -0700 @@ -26,6 +26,7 @@ #include "pbd/libpbd_visibility.h" #include "pbd/spinlock.h" +#include "pbd/g_atomic_compat.h" namespace PBD { @@ -73,9 +74,9 @@ public: /* called from rt (reader) thread for new buffers */ void align_to (PlaybackBuffer const& other) { Glib::Threads::Mutex::Lock lm (_reset_lock); - write_idx = other.write_idx; - read_idx = other.read_idx; - reserved = other.reserved; + g_atomic_int_set (&read_idx, g_atomic_int_get (&other.read_idx)); + g_atomic_int_set (&write_idx, g_atomic_int_get (&other.write_idx)); + g_atomic_int_set (&reserved, g_atomic_int_get (&other.reserved)); memset (buf, 0, size * sizeof (T)); } @@ -190,9 +191,9 @@ public: } } - guint read_ptr() const { return read_idx; } - guint write_ptr() const { return write_idx; } - guint reserved_size() const { return reserved; } + guint read_ptr() const { return g_atomic_int_get (&read_idx); } + guint write_ptr() const { return g_atomic_int_get (&write_idx); } + guint reserved_size() const { return g_atomic_int_get (&reserved); } guint reservation_size() const { return reservation; } private: @@ -201,9 +202,9 @@ private: guint size; guint size_mask; - mutable gint write_idx; - mutable gint read_idx; - mutable gint reserved; + mutable GATOMIC_QUAL gint write_idx; + mutable GATOMIC_QUAL gint read_idx; + mutable GATOMIC_QUAL gint reserved; /* spinlock will be used to update write_idx and reserved in sync */ spinlock_t _reservation_lock; diff -urpN Ardour-6.6.0.orig/libs/pbd/pbd/rcu.h Ardour-6.6.0/libs/pbd/pbd/rcu.h --- Ardour-6.6.0.orig/libs/pbd/pbd/rcu.h 2021-04-21 23:33:55.640176662 -0700 +++ Ardour-6.6.0/libs/pbd/pbd/rcu.h 2021-04-21 23:33:10.214294292 -0700 @@ -27,6 +27,7 @@ #include #include "pbd/libpbd_visibility.h" +#include "pbd/g_atomic_compat.h" /** @file rcu.h * Define a set of classes to implement Read-Copy-Update. We do not attempt to define RCU here - use google. @@ -52,8 +53,8 @@ class /*LIBPBD_API*/ RCUManager { public: RCUManager (T* new_rcu_value) - : _active_reads (0) { + g_atomic_int_set (&_active_reads, 0); x.rcu_value = new boost::shared_ptr (new_rcu_value); } @@ -99,8 +100,8 @@ protected: * evaluate to the same address. */ union { - boost::shared_ptr* rcu_value; - mutable volatile gpointer gptr; + boost::shared_ptr* rcu_value; + mutable GATOMIC_QUAL gpointer gptr; } x; inline bool active_read () const { @@ -108,7 +109,7 @@ protected: } private: - mutable volatile gint _active_reads; + mutable GATOMIC_QUAL gint _active_reads; }; /** Serialized RCUManager implements the RCUManager interface. It is based on the diff -urpN Ardour-6.6.0.orig/libs/pbd/pbd/ringbuffer.h Ardour-6.6.0/libs/pbd/pbd/ringbuffer.h --- Ardour-6.6.0.orig/libs/pbd/pbd/ringbuffer.h 2021-04-21 23:33:55.640176662 -0700 +++ Ardour-6.6.0/libs/pbd/pbd/ringbuffer.h 2021-04-21 23:33:10.215294312 -0700 @@ -24,9 +24,9 @@ #define ringbuffer_h #include -#include #include "pbd/libpbd_visibility.h" +#include "pbd/g_atomic_compat.h" namespace PBD { @@ -122,9 +122,9 @@ public: protected: T *buf; guint size; - mutable gint write_idx; - mutable gint read_idx; guint size_mask; + mutable GATOMIC_QUAL gint write_idx; + mutable GATOMIC_QUAL gint read_idx; private: RingBuffer (RingBuffer const&); @@ -139,7 +139,7 @@ RingBuffer::read (T *dest, guint cnt) guint n1, n2; guint priv_read_idx; - priv_read_idx=g_atomic_int_get(&read_idx); + priv_read_idx = g_atomic_int_get (&read_idx); if ((free_cnt = read_space ()) == 0) { return 0; @@ -165,7 +165,7 @@ RingBuffer::read (T *dest, guint cnt) priv_read_idx = n2; } - g_atomic_int_set(&read_idx, priv_read_idx); + g_atomic_int_set (&read_idx, priv_read_idx); return to_read; } @@ -179,7 +179,7 @@ RingBuffer::write (T const *src, guin guint n1, n2; guint priv_write_idx; - priv_write_idx=g_atomic_int_get(&write_idx); + priv_write_idx = g_atomic_int_get (&write_idx); if ((free_cnt = write_space ()) == 0) { return 0; @@ -205,7 +205,7 @@ RingBuffer::write (T const *src, guin priv_write_idx = n2; } - g_atomic_int_set(&write_idx, priv_write_idx); + g_atomic_int_set (&write_idx, priv_write_idx); return to_write; } diff -urpN Ardour-6.6.0.orig/libs/pbd/pbd/ringbufferNPT.h Ardour-6.6.0/libs/pbd/pbd/ringbufferNPT.h --- Ardour-6.6.0.orig/libs/pbd/pbd/ringbufferNPT.h 2021-04-21 23:33:55.640176662 -0700 +++ Ardour-6.6.0/libs/pbd/pbd/ringbufferNPT.h 2021-04-21 23:33:10.215294312 -0700 @@ -27,6 +27,7 @@ #include #include "pbd/libpbd_visibility.h" +#include "pbd/g_atomic_compat.h" namespace PBD { @@ -118,8 +119,8 @@ class /*LIBPBD_API*/ RingBufferNPT protected: T *buf; size_t size; - mutable gint write_ptr; - mutable gint read_ptr; + mutable GATOMIC_QUAL gint write_ptr; + mutable GATOMIC_QUAL gint read_ptr; private: RingBufferNPT (RingBufferNPT const&); @@ -134,7 +135,7 @@ RingBufferNPT::read (T *dest, size_t size_t n1, n2; size_t priv_read_ptr; - priv_read_ptr=g_atomic_int_get(&read_ptr); + priv_read_ptr = g_atomic_int_get (&read_ptr); if ((free_cnt = read_space ()) == 0) { return 0; @@ -160,7 +161,7 @@ RingBufferNPT::read (T *dest, size_t priv_read_ptr = n2; } - g_atomic_int_set(&read_ptr, priv_read_ptr); + g_atomic_int_set (&read_ptr, priv_read_ptr); return to_read; } @@ -173,7 +174,7 @@ RingBufferNPT::write (const T *src, s size_t n1, n2; size_t priv_write_ptr; - priv_write_ptr=g_atomic_int_get(&write_ptr); + priv_write_ptr = g_atomic_int_get (&write_ptr); if ((free_cnt = write_space ()) == 0) { return 0; @@ -199,7 +200,7 @@ RingBufferNPT::write (const T *src, s priv_write_ptr = n2; } - g_atomic_int_set(&write_ptr, priv_write_ptr); + g_atomic_int_set (&write_ptr, priv_write_ptr); return to_write; } diff -urpN Ardour-6.6.0.orig/libs/pbd/pbd/stateful.h Ardour-6.6.0/libs/pbd/pbd/stateful.h --- Ardour-6.6.0.orig/libs/pbd/pbd/stateful.h 2021-04-21 23:33:55.640176662 -0700 +++ Ardour-6.6.0/libs/pbd/pbd/stateful.h 2021-04-21 23:33:10.215294312 -0700 @@ -32,6 +32,7 @@ #include "pbd/xml++.h" #include "pbd/property_basics.h" #include "pbd/signals.h" +#include "pbd/g_atomic_compat.h" class XMLNode; @@ -104,7 +105,7 @@ class LIBPBD_API Stateful { virtual void suspend_property_changes (); virtual void resume_property_changes (); - bool property_changes_suspended() const { return g_atomic_int_get (const_cast(&_stateful_frozen)) > 0; } + bool property_changes_suspended() const { return g_atomic_int_get (&_stateful_frozen) > 0; } protected: @@ -139,8 +140,9 @@ class LIBPBD_API Stateful { private: friend struct ForceIDRegeneration; static Glib::Threads::Private _regenerate_xml_or_string_ids; - PBD::ID _id; - gint _stateful_frozen; + + PBD::ID _id; + GATOMIC_QUAL gint _stateful_frozen; static void set_regenerate_xml_and_string_ids_in_this_thread (bool yn); }; diff -urpN Ardour-6.6.0.orig/libs/pbd/stateful.cc Ardour-6.6.0/libs/pbd/stateful.cc --- Ardour-6.6.0.orig/libs/pbd/stateful.cc 2021-04-21 23:33:55.640176662 -0700 +++ Ardour-6.6.0/libs/pbd/stateful.cc 2021-04-21 23:33:10.216294331 -0700 @@ -54,8 +54,8 @@ Stateful::Stateful () : _extra_xml (0) , _instant_xml (0) , _properties (new OwnedPropertyList) - , _stateful_frozen (0) { + g_atomic_int_set (&_stateful_frozen, 0); } Stateful::~Stateful () diff -urpN Ardour-6.6.0.orig/libs/waveview/waveview/wave_view_private.h Ardour-6.6.0/libs/waveview/waveview/wave_view_private.h --- Ardour-6.6.0.orig/libs/waveview/waveview/wave_view_private.h 2021-04-21 23:33:55.640176662 -0700 +++ Ardour-6.6.0/libs/waveview/waveview/wave_view_private.h 2021-04-21 23:33:10.216294331 -0700 @@ -202,8 +202,8 @@ public: WaveViewDrawRequest (); ~WaveViewDrawRequest (); - bool stopped() const { return (bool) g_atomic_int_get (const_cast(&stop)); } - void cancel() { g_atomic_int_set (&stop, 1); } + bool stopped() const { return (bool) g_atomic_int_get (&_stop); } + void cancel() { g_atomic_int_set (&_stop, 1); } bool finished() { return image->finished(); } boost::shared_ptr image; @@ -213,7 +213,7 @@ public: } private: - gint stop; /* intended for atomic access */ + GATOMIC_QUAL gint _stop; /* intended for atomic access */ }; class WaveViewCache; @@ -320,7 +320,7 @@ private: private: Glib::Threads::Thread* _thread; - gint _quit; + GATOMIC_QUAL gint _quit; }; class WaveViewThreads { diff -urpN Ardour-6.6.0.orig/libs/waveview/wave_view_private.cc Ardour-6.6.0/libs/waveview/wave_view_private.cc --- Ardour-6.6.0.orig/libs/waveview/wave_view_private.cc 2021-04-21 23:33:55.640176662 -0700 +++ Ardour-6.6.0/libs/waveview/wave_view_private.cc 2021-04-21 23:33:10.217294351 -0700 @@ -254,9 +254,9 @@ WaveViewCache::set_image_cache_threshold /*-------------------------------------------------*/ -WaveViewDrawRequest::WaveViewDrawRequest () : stop (0) +WaveViewDrawRequest::WaveViewDrawRequest () { - + g_atomic_int_set (&_stop, 0); } WaveViewDrawRequest::~WaveViewDrawRequest () @@ -407,8 +407,8 @@ WaveViewThreads::stop_threads () WaveViewDrawingThread::WaveViewDrawingThread () : _thread(0) - , _quit(0) { + g_atomic_int_set (&_quit, 0); start (); } diff -urpN Ardour-6.6.0.orig/wscript Ardour-6.6.0/wscript --- Ardour-6.6.0.orig/wscript 2021-04-21 23:33:42.796927189 -0700 +++ Ardour-6.6.0/wscript 2021-04-21 23:33:10.265295283 -0700 @@ -1148,6 +1148,7 @@ def configure(conf): conf.env.append_value('LDFLAGS', '-L/usr/X11R6/lib') autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB', atleast_version='2.28', mandatory=True) + autowaf.check_pkg(conf, 'glib-2.0', uselib_store='GLIB_2_68', atleast_version='2.68', mandatory=False) autowaf.check_pkg(conf, 'gthread-2.0', uselib_store='GTHREAD', atleast_version='2.2', mandatory=True) autowaf.check_pkg(conf, 'glibmm-2.4', uselib_store='GLIBMM', atleast_version='2.32.0', mandatory=True) autowaf.check_pkg(conf, 'sndfile', uselib_store='SNDFILE', atleast_version='1.0.18', mandatory=True)