diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-12-19 15:33:54 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-12-19 15:33:54 +0000 |
commit | 53be243f6aadb4c5722816ea7c88c335095d56b4 (patch) | |
tree | 89e185430c8dbd15dccfe828bb5d29a24ba21285 /libs/ardour/session.cc | |
parent | 3d1eb9a6e5250bfc2f4d0138c004a82d6186beab (diff) |
Session::_ac_thread_active should be used with atomics to create memory barriers, even though lock ordering is likely correct now
Diffstat (limited to 'libs/ardour/session.cc')
-rw-r--r-- | libs/ardour/session.cc | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index b9d78494a3..d7393d747e 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -252,7 +252,7 @@ Session::Session (AudioEngine &eng, , _ignore_skips_updates (false) , _rt_thread_active (false) , _rt_emit_pending (false) - , _ac_thread_active (false) + , _ac_thread_active (0) , _latency_recompute_pending (0) , step_speed (0) , outbound_mtc_timecode_frame (0) @@ -6995,7 +6995,7 @@ Session::auto_connect (const AutoConnectRequest& ar) void Session::auto_connect_thread_start () { - if (_ac_thread_active) { + if (g_atomic_int_get (&_ac_thread_active)) { return; } @@ -7003,19 +7003,18 @@ Session::auto_connect_thread_start () _auto_connect_queue.pop (); } - _ac_thread_active = true; + g_atomic_int_set (&_ac_thread_active, 1); if (pthread_create (&_auto_connect_thread, NULL, auto_connect_thread, this)) { - _ac_thread_active = false; + g_atomic_int_set (&_ac_thread_active, 0); } } void Session::auto_connect_thread_terminate () { - if (!_ac_thread_active) { + if (!g_atomic_int_get (&_ac_thread_active)) { return; } - _ac_thread_active = false; { Glib::Threads::Mutex::Lock lx (_auto_connect_queue_lock); @@ -7029,6 +7028,7 @@ Session::auto_connect_thread_terminate () */ pthread_mutex_lock (&_auto_connect_mutex); + g_atomic_int_set (&_ac_thread_active, 0); pthread_cond_signal (&_auto_connect_cond); pthread_mutex_unlock (&_auto_connect_mutex); @@ -7052,7 +7052,7 @@ Session::auto_connect_thread_run () SessionEvent::create_per_thread_pool (X_("autoconnect"), 1024); PBD::notify_event_loops_about_thread_creation (pthread_self(), X_("autoconnect"), 1024); pthread_mutex_lock (&_auto_connect_mutex); - while (_ac_thread_active) { + while (g_atomic_int_get (&_ac_thread_active)) { if (!_auto_connect_queue.empty ()) { // Why would we need the process lock ?? |