summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-27 17:57:45 +0100
committerDavid Robillard <d@drobilla.net>2020-11-27 21:42:51 +0100
commit4d18a805d49ee01901517c13720bb4a9597351f4 (patch)
tree968dd8fe10ec06ce826f625a080dd48bddf0708b
parentf80e8274555f0da157e0b8c1fcae975d66178ab7 (diff)
downloadpatchage-4d18a805d49ee01901517c13720bb4a9597351f4.tar.gz
patchage-4d18a805d49ee01901517c13720bb4a9597351f4.tar.bz2
patchage-4d18a805d49ee01901517c13720bb4a9597351f4.zip
Use std::mutex
-rw-r--r--src/AlsaDriver.cpp5
-rw-r--r--src/AlsaDriver.hpp3
-rw-r--r--src/JackDriver.cpp9
-rw-r--r--src/JackDriver.hpp5
4 files changed, 14 insertions, 8 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp
index 8666137..af7d5e4 100644
--- a/src/AlsaDriver.cpp
+++ b/src/AlsaDriver.cpp
@@ -541,7 +541,7 @@ AlsaDriver::_refresh_main()
while (snd_seq_event_input(_seq, &ev) > 0) {
assert(ev);
- Glib::Mutex::Lock lock(_events_mutex);
+ std::lock_guard<std::mutex> lock{_events_mutex};
switch (ev->type) {
case SND_SEQ_EVENT_PORT_SUBSCRIBED:
@@ -604,7 +604,8 @@ AlsaDriver::_refresh_main()
void
AlsaDriver::process_events(Patchage* app)
{
- Glib::Mutex::Lock lock(_events_mutex);
+ std::lock_guard<std::mutex> lock{_events_mutex};
+
while (!_events.empty()) {
PatchageEvent& ev = _events.front();
ev.execute(app);
diff --git a/src/AlsaDriver.hpp b/src/AlsaDriver.hpp
index 94dd101..45eb3db 100644
--- a/src/AlsaDriver.hpp
+++ b/src/AlsaDriver.hpp
@@ -24,6 +24,7 @@
#include <pthread.h>
#include <map>
+#include <mutex>
#include <queue>
#include <set>
#include <string>
@@ -83,7 +84,7 @@ private:
snd_seq_t* _seq;
pthread_t _refresh_thread;
- Glib::Mutex _events_mutex;
+ std::mutex _events_mutex;
std::queue<PatchageEvent> _events;
struct SeqAddrComparator
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index e916f80..dfe2a1c 100644
--- a/src/JackDriver.cpp
+++ b/src/JackDriver.cpp
@@ -100,7 +100,8 @@ JackDriver::attach(bool launch_daemon)
void
JackDriver::detach()
{
- Glib::Mutex::Lock lock(_shutdown_mutex);
+ std::lock_guard<std::mutex> lock{_shutdown_mutex};
+
if (_client) {
jack_deactivate(_client);
jack_client_close(_client);
@@ -277,7 +278,7 @@ JackDriver::refresh()
// Jack can take _client away from us at any time throughout here :/
// Shortest locks possible is the best solution I can figure out
- Glib::Mutex::Lock lock(_shutdown_mutex);
+ std::lock_guard<std::mutex> lock{_shutdown_mutex};
if (_client == nullptr) {
shutdown();
@@ -538,7 +539,9 @@ JackDriver::jack_shutdown_cb(void* jack_driver)
assert(jack_driver);
auto* me = reinterpret_cast<JackDriver*>(jack_driver);
me->_app->info_msg("Jack: Shutdown.");
- Glib::Mutex::Lock lock(me->_shutdown_mutex);
+
+ std::lock_guard<std::mutex> lock{me->_shutdown_mutex};
+
me->_client = nullptr;
me->_is_activated = false;
me->signal_detached.emit();
diff --git a/src/JackDriver.hpp b/src/JackDriver.hpp
index 5649950..6a404a7 100644
--- a/src/JackDriver.hpp
+++ b/src/JackDriver.hpp
@@ -1,5 +1,5 @@
/* This file is part of Patchage.
- * Copyright 2007-2014 David Robillard <http://drobilla.net>
+ * Copyright 2007-2020 David Robillard <d@drobilla.net>
*
* Patchage 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
@@ -23,6 +23,7 @@
#include <glibmm/thread.h>
#include <jack/jack.h>
+#include <mutex>
#include <string>
class Patchage;
@@ -96,7 +97,7 @@ private:
Queue<PatchageEvent> _events;
- Glib::Mutex _shutdown_mutex;
+ std::mutex _shutdown_mutex;
jack_position_t _last_pos;
jack_nframes_t _buffer_size;