Replace Glib::Threads with PBD::Thread (1/2)

This commit is contained in:
Robin Gareus 2022-02-28 22:34:11 +01:00
parent a8559c8741
commit 24bbf403b9
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
12 changed files with 20 additions and 29 deletions

View File

@ -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

View File

@ -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;

View File

@ -22,9 +22,9 @@
#include <set>
#include <boost/shared_ptr.hpp>
#include <glibmm/threads.h>
#include <sigc++/signal.h>
#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;

View File

@ -23,11 +23,10 @@
#ifndef MIDI_PATCH_MANAGER_H_
#define MIDI_PATCH_MANAGER_H_
#include <glibmm/threads.h>
#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 ();
};

View File

@ -23,8 +23,7 @@
#include <stdint.h>
#include <glibmm/threads.h>
#include "pbd/pthread_utils.h"
#include "pbd/ringbuffer.h"
#include "pbd/semutils.h"
@ -110,7 +109,7 @@ private:
PBD::RingBuffer<uint8_t>* _responses;
uint8_t* _response;
PBD::Semaphore _sem;
Glib::Threads::Thread* _thread;
PBD::Thread* _thread;
bool _exit;
bool _synchronous;
};

View File

@ -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));
}
}

View File

@ -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));
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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

View File

@ -21,6 +21,7 @@
#include <deque>
#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 {