aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/backends/qsa.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-26 21:19:20 -0800
committerChris Robinson <[email protected]>2018-11-26 21:39:31 -0800
commitb108d0acfd062756da69074242e24ea7b2856b8a (patch)
tree40a573fbefeb77310f375ace284bc847b4014973 /Alc/backends/qsa.cpp
parent7860a11ae2723d744eb35eae9bbbc6f9a55e9caa (diff)
Remove the last remaining uses of althrd_t
Diffstat (limited to 'Alc/backends/qsa.cpp')
-rw-r--r--Alc/backends/qsa.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp
index b40b5b6b..3d09a744 100644
--- a/Alc/backends/qsa.cpp
+++ b/Alc/backends/qsa.cpp
@@ -28,6 +28,7 @@
#include <errno.h>
#include <memory.h>
+#include <thread>
#include <memory>
#include <algorithm>
@@ -53,7 +54,7 @@ struct qsa_data {
ALsizei size{0};
std::atomic<ALenum> mKillNow{AL_TRUE};
- althrd_t thread;
+ std::thread mThread;
};
struct DevMap {
@@ -592,21 +593,26 @@ static ALCboolean qsa_start_playback(PlaybackWrapper *self)
{
qsa_data *data = self->ExtraData.get();
- data->mKillNow.store(AL_FALSE, std::memory_order_release);
- if(althrd_create(&data->thread, qsa_proc_playback, self) != althrd_success)
- return ALC_FALSE;
-
- return ALC_TRUE;
+ try {
+ data->mKillNow.store(AL_FALSE, std::memory_order_release);
+ data->mThread = std::thread(qsa_proc_playback, self);
+ return ALC_TRUE;
+ }
+ catch(std::exception& e) {
+ ERR("Could not create playback thread: %s\n", e.what());
+ }
+ catch(...) {
+ }
+ return ALC_FALSE;
}
static void qsa_stop_playback(PlaybackWrapper *self)
{
qsa_data *data = self->ExtraData.get();
- int res;
- if(data->mKillNow.exchange(AL_TRUE, std::memory_order_acq_rel))
+ if(data->mKillNow.exchange(AL_TRUE, std::memory_order_acq_rel) || !data->mThread.joinable())
return;
- althrd_join(data->thread, &res);
+ data->mThread.join();
}