aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-11-17 06:07:04 -0800
committerChris Robinson <[email protected]>2018-11-17 06:07:04 -0800
commit7b537c795bd174b4b02418a37b377b4da5cfe266 (patch)
treeb0e7485d4ae66518194bd03128f56ffda1c199ec
parent1fae8c16a8c0634ffa44b4a2e25f3be4899ea7e2 (diff)
Don't pass the current thread to althrd_setname
-rw-r--r--Alc/alc.cpp2
-rw-r--r--Alc/backends/alsa.cpp4
-rw-r--r--Alc/backends/dsound.cpp2
-rw-r--r--Alc/backends/jack.cpp2
-rw-r--r--Alc/backends/null.cpp2
-rw-r--r--Alc/backends/opensl.cpp2
-rw-r--r--Alc/backends/oss.cpp4
-rw-r--r--Alc/backends/pulseaudio.cpp2
-rw-r--r--Alc/backends/qsa.cpp2
-rw-r--r--Alc/backends/sndio.cpp4
-rw-r--r--Alc/backends/solaris.cpp2
-rw-r--r--Alc/backends/wasapi.cpp4
-rw-r--r--Alc/backends/wave.cpp2
-rw-r--r--Alc/backends/winmm.cpp4
-rw-r--r--common/threads.cpp25
-rw-r--r--common/threads.h26
16 files changed, 26 insertions, 63 deletions
diff --git a/Alc/alc.cpp b/Alc/alc.cpp
index 65023fe1..c719eaa9 100644
--- a/Alc/alc.cpp
+++ b/Alc/alc.cpp
@@ -1248,8 +1248,6 @@ static void alc_deinit_safe(void)
if(LogFile != stderr)
fclose(LogFile);
LogFile = nullptr;
-
- althrd_deinit();
}
static void alc_deinit(void)
diff --git a/Alc/backends/alsa.cpp b/Alc/backends/alsa.cpp
index ee42842b..d02d5d20 100644
--- a/Alc/backends/alsa.cpp
+++ b/Alc/backends/alsa.cpp
@@ -472,7 +472,7 @@ int ALCplaybackAlsa_mixerProc(ALCplaybackAlsa *self)
ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice};
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
snd_pcm_uframes_t update_size{device->UpdateSize};
snd_pcm_uframes_t num_updates{device->NumUpdates};
@@ -559,7 +559,7 @@ int ALCplaybackAlsa_mixerNoMMapProc(ALCplaybackAlsa *self)
ALCdevice *device{STATIC_CAST(ALCbackend, self)->mDevice};
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
snd_pcm_uframes_t update_size{device->UpdateSize};
snd_pcm_uframes_t num_updates{device->NumUpdates};
diff --git a/Alc/backends/dsound.cpp b/Alc/backends/dsound.cpp
index 34d7dc23..a52bb17c 100644
--- a/Alc/backends/dsound.cpp
+++ b/Alc/backends/dsound.cpp
@@ -249,7 +249,7 @@ FORCE_ALIGN int ALCdsoundPlayback_mixerProc(ALCdsoundPlayback *self)
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
IDirectSoundBuffer *const Buffer{self->Buffer};
diff --git a/Alc/backends/jack.cpp b/Alc/backends/jack.cpp
index ac57ffd5..97254582 100644
--- a/Alc/backends/jack.cpp
+++ b/Alc/backends/jack.cpp
@@ -306,7 +306,7 @@ static int ALCjackPlayback_mixerProc(void *arg)
ll_ringbuffer_data_t data[2];
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
ALCjackPlayback_lock(self);
while(!ATOMIC_LOAD(&self->killNow, almemory_order_acquire) &&
diff --git a/Alc/backends/null.cpp b/Alc/backends/null.cpp
index c9ba8de7..7c27e22c 100644
--- a/Alc/backends/null.cpp
+++ b/Alc/backends/null.cpp
@@ -89,7 +89,7 @@ int ALCnullBackend_mixerProc(ALCnullBackend *self)
const milliseconds restTime{device->UpdateSize*1000/device->Frequency / 2};
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
ALint64 done{0};
auto start = std::chrono::steady_clock::now();
diff --git a/Alc/backends/opensl.cpp b/Alc/backends/opensl.cpp
index e8a575c8..1c85c9d5 100644
--- a/Alc/backends/opensl.cpp
+++ b/Alc/backends/opensl.cpp
@@ -244,7 +244,7 @@ static int ALCopenslPlayback_mixerProc(void *arg)
SLresult result;
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
result = VCALL(self->mBufferQueueObj,GetInterface)(SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
&bufferQueue);
diff --git a/Alc/backends/oss.cpp b/Alc/backends/oss.cpp
index cf95bcfe..ebe4b15a 100644
--- a/Alc/backends/oss.cpp
+++ b/Alc/backends/oss.cpp
@@ -296,7 +296,7 @@ int ALCplaybackOSS_mixerProc(ALCplaybackOSS *self)
int sret;
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder);
@@ -558,7 +558,7 @@ int ALCcaptureOSS_recordProc(ALCcaptureOSS *self)
int sret;
SetRTPriority();
- althrd_setname(althrd_current(), RECORD_THREAD_NAME);
+ althrd_setname(RECORD_THREAD_NAME);
frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder);
diff --git a/Alc/backends/pulseaudio.cpp b/Alc/backends/pulseaudio.cpp
index 38623783..df2eb656 100644
--- a/Alc/backends/pulseaudio.cpp
+++ b/Alc/backends/pulseaudio.cpp
@@ -866,7 +866,7 @@ int PulsePlayback_mixerProc(PulsePlayback *self)
ALCdevice *device{STATIC_CAST(ALCbackend,self)->mDevice};
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
unique_palock palock{self->loop};
size_t frame_size{pa_frame_size(&self->spec)};
diff --git a/Alc/backends/qsa.cpp b/Alc/backends/qsa.cpp
index da4e6b64..f710f080 100644
--- a/Alc/backends/qsa.cpp
+++ b/Alc/backends/qsa.cpp
@@ -198,7 +198,7 @@ FORCE_ALIGN static int qsa_proc_playback(void *ptr)
int sret;
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
/* Increase default 10 priority to 11 to avoid jerky sound */
SchedGet(0, 0, &param);
diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp
index 691bdcde..654c2975 100644
--- a/Alc/backends/sndio.cpp
+++ b/Alc/backends/sndio.cpp
@@ -98,7 +98,7 @@ static int SndioPlayback_mixerProc(void *ptr)
size_t wrote;
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder);
@@ -340,7 +340,7 @@ static int SndioCapture_recordProc(void* ptr)
ALsizei frameSize;
SetRTPriority();
- althrd_setname(althrd_current(), RECORD_THREAD_NAME);
+ althrd_setname(RECORD_THREAD_NAME);
frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder);
diff --git a/Alc/backends/solaris.cpp b/Alc/backends/solaris.cpp
index 029ef1a5..008f3446 100644
--- a/Alc/backends/solaris.cpp
+++ b/Alc/backends/solaris.cpp
@@ -115,7 +115,7 @@ static int ALCsolarisBackend_mixerProc(void *ptr)
int sret;
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder);
diff --git a/Alc/backends/wasapi.cpp b/Alc/backends/wasapi.cpp
index 4ebd6f25..7f52bafe 100644
--- a/Alc/backends/wasapi.cpp
+++ b/Alc/backends/wasapi.cpp
@@ -580,7 +580,7 @@ FORCE_ALIGN int ALCwasapiPlayback_mixerProc(ALCwasapiPlayback *self)
}
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
ALuint update_size{device->UpdateSize};
UINT32 buffer_len{update_size * device->NumUpdates};
@@ -1251,7 +1251,7 @@ FORCE_ALIGN int ALCwasapiCapture_recordProc(ALCwasapiCapture *self)
return 1;
}
- althrd_setname(althrd_current(), RECORD_THREAD_NAME);
+ althrd_setname(RECORD_THREAD_NAME);
std::vector<float> samples;
while(!self->mKillNow.load(std::memory_order_relaxed))
diff --git a/Alc/backends/wave.cpp b/Alc/backends/wave.cpp
index fb00ef32..58e0efd5 100644
--- a/Alc/backends/wave.cpp
+++ b/Alc/backends/wave.cpp
@@ -133,7 +133,7 @@ int ALCwaveBackend_mixerProc(ALCwaveBackend *self)
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
const milliseconds restTime{device->UpdateSize*1000/device->Frequency / 2};
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
ALsizei frameSize{FrameSizeFromDevFmt(device->FmtChans, device->FmtType, device->AmbiOrder)};
diff --git a/Alc/backends/winmm.cpp b/Alc/backends/winmm.cpp
index 0fb85f66..1d0a8ecc 100644
--- a/Alc/backends/winmm.cpp
+++ b/Alc/backends/winmm.cpp
@@ -202,7 +202,7 @@ FORCE_ALIGN int ALCwinmmPlayback_mixerProc(ALCwinmmPlayback *self)
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
SetRTPriority();
- althrd_setname(althrd_current(), MIXER_THREAD_NAME);
+ althrd_setname(MIXER_THREAD_NAME);
ALCwinmmPlayback_lock(self);
while(!self->killNow.load(std::memory_order_acquire) &&
@@ -484,7 +484,7 @@ int ALCwinmmCapture_captureProc(ALCwinmmCapture *self)
{
ALCdevice *device = STATIC_CAST(ALCbackend, self)->mDevice;
- althrd_setname(althrd_current(), RECORD_THREAD_NAME);
+ althrd_setname(RECORD_THREAD_NAME);
ALCwinmmCapture_lock(self);
while(!self->killNow.load(std::memory_order_acquire) &&
diff --git a/common/threads.cpp b/common/threads.cpp
index 48f62274..7d44c012 100644
--- a/common/threads.cpp
+++ b/common/threads.cpp
@@ -60,7 +60,7 @@
static ThrSafeMap<DWORD,HANDLE> ThrdIdHandle{};
-void althrd_setname(althrd_t thr, const char *name)
+void althrd_setname(const char *name)
{
#if defined(_MSC_VER)
#define MS_VC_EXCEPTION 0x406D1388
@@ -74,7 +74,7 @@ void althrd_setname(althrd_t thr, const char *name)
#pragma pack(pop)
info.dwType = 0x1000;
info.szName = name;
- info.dwThreadID = thr;
+ info.dwThreadID = -1;
info.dwFlags = 0;
__try {
@@ -84,7 +84,6 @@ void althrd_setname(althrd_t thr, const char *name)
}
#undef MS_VC_EXCEPTION
#else
- (void)thr;
(void)name;
#endif
}
@@ -207,11 +206,6 @@ int alsem_trywait(alsem_t *sem)
return althrd_error;
}
-
-void althrd_deinit(void)
-{
-}
-
#else
#include <sys/time.h>
@@ -222,21 +216,19 @@ void althrd_deinit(void)
#endif
-void althrd_setname(althrd_t thr, const char *name)
+void althrd_setname(const char *name)
{
#if defined(HAVE_PTHREAD_SETNAME_NP)
#if defined(PTHREAD_SETNAME_NP_ONE_PARAM)
- if(althrd_equal(thr, althrd_current()))
- pthread_setname_np(name);
+ pthread_setname_np(name);
#elif defined(PTHREAD_SETNAME_NP_THREE_PARAMS)
- pthread_setname_np(thr, "%s", (void*)name);
+ pthread_setname_np(pthread_self(), "%s", (void*)name);
#else
- pthread_setname_np(thr, name);
+ pthread_setname_np(pthread_self(), name);
#endif
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
- pthread_set_name_np(thr, name);
+ pthread_set_name_np(pthread_self(), name);
#else
- (void)thr;
(void)name;
#endif
}
@@ -436,7 +428,4 @@ int alsem_trywait(alsem_t *sem)
#endif /* __APPLE__ */
-void althrd_deinit(void)
-{ }
-
#endif
diff --git a/common/threads.h b/common/threads.h
index 9abb22f2..0b53c38f 100644
--- a/common/threads.h
+++ b/common/threads.h
@@ -42,18 +42,6 @@ typedef CRITICAL_SECTION almtx_t;
typedef HANDLE alsem_t;
-void althrd_deinit(void);
-
-inline althrd_t althrd_current(void)
-{
- return GetCurrentThreadId();
-}
-
-inline int althrd_equal(althrd_t thr0, althrd_t thr1)
-{
- return thr0 == thr1;
-}
-
inline void althrd_yield(void)
{
SwitchToThread();
@@ -94,18 +82,6 @@ typedef sem_t alsem_t;
#endif /* __APPLE__ */
-void althrd_deinit(void);
-
-inline althrd_t althrd_current(void)
-{
- return pthread_self();
-}
-
-inline int althrd_equal(althrd_t thr0, althrd_t thr1)
-{
- return pthread_equal(thr0, thr1);
-}
-
inline void althrd_yield(void)
{
sched_yield();
@@ -132,7 +108,7 @@ inline int almtx_unlock(almtx_t *mtx)
int althrd_create(althrd_t *thr, althrd_start_t func, void *arg);
int althrd_detach(althrd_t thr);
int althrd_join(althrd_t thr, int *res);
-void althrd_setname(althrd_t thr, const char *name);
+void althrd_setname(const char *name);
int almtx_init(almtx_t *mtx, int type);
void almtx_destroy(almtx_t *mtx);