From 24bbf403b9c4aa26439547a9f6870abaa7b3fbfc Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 28 Feb 2022 22:34:11 +0100 Subject: [PATCH] Replace Glib::Threads with PBD::Thread (1/2) --- libs/ardour/analyser.cc | 9 +-------- libs/ardour/ardour/audioengine.h | 4 ++-- libs/ardour/ardour/automation_watch.h | 4 ++-- libs/ardour/ardour/midi_patch_manager.h | 5 ++--- libs/ardour/ardour/worker.h | 5 ++--- libs/ardour/audioengine.cc | 4 ++-- libs/ardour/automation_watch.cc | 6 +++--- libs/ardour/midi_patch_manager.cc | 2 +- libs/ardour/source_factory.cc | 2 +- libs/ardour/worker.cc | 3 +-- libs/waveview/wave_view_private.cc | 2 +- libs/waveview/waveview/wave_view_private.h | 3 ++- 12 files changed, 20 insertions(+), 29 deletions(-) diff --git a/libs/ardour/analyser.cc b/libs/ardour/analyser.cc index 07d0e77d55..272d93e702 100644 --- a/libs/ardour/analyser.cc +++ b/libs/ardour/analyser.cc @@ -51,17 +51,10 @@ Analyser::~Analyser () { } -static void -analyser_work () -{ - pthread_set_name ("Analyzer"); - Analyser::work (); -} - void Analyser::init () { - Glib::Threads::Thread::create (sigc::ptr_fun (analyser_work)); + PBD::Thread::create (sigc::ptr_fun (&Analyser::work), "Analyzer"); } void diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index dbc4d2c810..d696238e5a 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -299,12 +299,12 @@ class LIBARDOUR_API AudioEngine : public PortManager, public SessionHandlePtr std::string _last_backend_error_string; - Glib::Threads::Thread* _hw_reset_event_thread; + PBD::Thread* _hw_reset_event_thread; GATOMIC_QUAL gint _hw_reset_request_count; Glib::Threads::Cond _hw_reset_condition; Glib::Threads::Mutex _reset_request_lock; GATOMIC_QUAL gint _stop_hw_reset_processing; - Glib::Threads::Thread* _hw_devicelist_update_thread; + PBD::Thread* _hw_devicelist_update_thread; GATOMIC_QUAL gint _hw_devicelist_update_count; Glib::Threads::Cond _hw_devicelist_update_condition; Glib::Threads::Mutex _devicelist_update_lock; diff --git a/libs/ardour/ardour/automation_watch.h b/libs/ardour/ardour/automation_watch.h index 2d04e6dc0c..9be38b9d54 100644 --- a/libs/ardour/ardour/automation_watch.h +++ b/libs/ardour/ardour/automation_watch.h @@ -22,9 +22,9 @@ #include #include -#include #include +#include "pbd/pthread_utils.h" #include "pbd/signals.h" #include "ardour/session_handle.h" @@ -54,7 +54,7 @@ private: ~AutomationWatch(); static AutomationWatch* _instance; - Glib::Threads::Thread* _thread; + PBD::Thread* _thread; samplepos_t _last_time; bool _run_thread; AutomationWatches automation_watches; diff --git a/libs/ardour/ardour/midi_patch_manager.h b/libs/ardour/ardour/midi_patch_manager.h index cb4f492bc4..05b5b34bd6 100644 --- a/libs/ardour/ardour/midi_patch_manager.h +++ b/libs/ardour/ardour/midi_patch_manager.h @@ -23,11 +23,10 @@ #ifndef MIDI_PATCH_MANAGER_H_ #define MIDI_PATCH_MANAGER_H_ -#include - #include "midi++/midnam_patch.h" #include "pbd/event_loop.h" +#include "pbd/pthread_utils.h" #include "pbd/signals.h" #include "pbd/search_path.h" @@ -173,7 +172,7 @@ private: Glib::Threads::Mutex _lock; bool no_patch_changed_messages; bool stop_thread; - Glib::Threads::Thread* _midnam_load_thread; + PBD::Thread* _midnam_load_thread; void load_midnams (); }; diff --git a/libs/ardour/ardour/worker.h b/libs/ardour/ardour/worker.h index d456a2cd98..80cd1d374c 100644 --- a/libs/ardour/ardour/worker.h +++ b/libs/ardour/ardour/worker.h @@ -23,8 +23,7 @@ #include -#include - +#include "pbd/pthread_utils.h" #include "pbd/ringbuffer.h" #include "pbd/semutils.h" @@ -110,7 +109,7 @@ private: PBD::RingBuffer* _responses; uint8_t* _response; PBD::Semaphore _sem; - Glib::Threads::Thread* _thread; + PBD::Thread* _thread; bool _exit; bool _synchronous; }; diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 4af731b669..5d10357583 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -752,13 +752,13 @@ 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); - _hw_reset_event_thread = Glib::Threads::Thread::create (boost::bind (&AudioEngine::do_reset_backend, this)); + _hw_reset_event_thread = PBD::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); - _hw_devicelist_update_thread = Glib::Threads::Thread::create (boost::bind (&AudioEngine::do_devicelist_update, this)); + _hw_devicelist_update_thread = PBD::Thread::create (boost::bind (&AudioEngine::do_devicelist_update, this)); } } diff --git a/libs/ardour/automation_watch.cc b/libs/ardour/automation_watch.cc index 7ef36c6c7a..0f3f1199cf 100644 --- a/libs/ardour/automation_watch.cc +++ b/libs/ardour/automation_watch.cc @@ -199,10 +199,10 @@ AutomationWatch::timer () void AutomationWatch::thread () { - pbd_set_thread_priority (pthread_self(), PBD_SCHED_FIFO, AudioEngine::instance()->client_real_time_priority() - 2); + pbd_set_thread_priority (pthread_self(), PBD_SCHED_FIFO, AudioEngine::instance()->client_real_time_priority() - 2); // XXX pthread_set_name ("AutomationWatch"); while (_run_thread) { - Glib::usleep ((gulong) floor (Config->get_automation_interval_msecs() * 1000)); + Glib::usleep ((gulong) floor (Config->get_automation_interval_msecs() * 1000)); // TODO use pthread_cond_timedwait on _run_thread timer (); } } @@ -222,7 +222,7 @@ AutomationWatch::set_session (Session* s) if (_session) { _run_thread = true; - _thread = Glib::Threads::Thread::create (boost::bind (&AutomationWatch::thread, this)); + _thread = PBD::Thread::create (boost::bind (&AutomationWatch::thread, this)); _session->TransportStateChange.connect_same_thread (transport_connection, boost::bind (&AutomationWatch::transport_state_change, this)); } diff --git a/libs/ardour/midi_patch_manager.cc b/libs/ardour/midi_patch_manager.cc index d1b3fcc15d..ce4d3c6a35 100644 --- a/libs/ardour/midi_patch_manager.cc +++ b/libs/ardour/midi_patch_manager.cc @@ -291,7 +291,7 @@ MidiPatchManager::load_midnams () void MidiPatchManager::load_midnams_in_thread () { - _midnam_load_thread = Glib::Threads::Thread::create (sigc::mem_fun (*this, &MidiPatchManager::load_midnams)); + _midnam_load_thread = PBD::Thread::create (boost::bind (&MidiPatchManager::load_midnams, this)); } void diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 28e6bddf41..481ce21c4f 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -105,7 +105,7 @@ void SourceFactory::init () { for (int n = 0; n < 2; ++n) { - Glib::Threads::Thread::create (sigc::ptr_fun (::peak_thread_work)); + PBD::Thread::create (&peak_thread_work); } } diff --git a/libs/ardour/worker.cc b/libs/ardour/worker.cc index 1360b77b74..1fc385c958 100644 --- a/libs/ardour/worker.cc +++ b/libs/ardour/worker.cc @@ -41,8 +41,7 @@ Worker::Worker(Workee* workee, uint32_t ring_size, bool threaded) , _synchronous(!threaded) { if (threaded) { - _thread = Glib::Threads::Thread::create( - sigc::mem_fun(*this, &Worker::run)); + _thread = PBD::Thread::create (boost::bind (&Worker::run, this)); } } diff --git a/libs/waveview/wave_view_private.cc b/libs/waveview/wave_view_private.cc index 0c49b2ca93..bc8f64b0aa 100644 --- a/libs/waveview/wave_view_private.cc +++ b/libs/waveview/wave_view_private.cc @@ -405,7 +405,7 @@ WaveViewDrawingThread::start () { assert (!_thread); - _thread = Glib::Threads::Thread::create (sigc::ptr_fun (&WaveViewThreads::thread_proc)); + _thread = PBD::Thread::create (&WaveViewThreads::thread_proc); } void diff --git a/libs/waveview/waveview/wave_view_private.h b/libs/waveview/waveview/wave_view_private.h index 7ea806ead5..92f0f9283b 100644 --- a/libs/waveview/waveview/wave_view_private.h +++ b/libs/waveview/waveview/wave_view_private.h @@ -21,6 +21,7 @@ #include +#include "pbd/pthread_utils.h" #include "waveview/wave_view.h" namespace ARDOUR { @@ -298,7 +299,7 @@ private: void run (); private: - Glib::Threads::Thread* _thread; + PBD::Thread* _thread; }; class WaveViewThreads {