summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-04-17 20:41:32 -0700
committerChris Robinson <[email protected]>2014-04-17 20:41:32 -0700
commit36df67f546c3162e06964ca6a2466023647c7485 (patch)
tree8a7ed509289f839cf0149025a7284ba07aadaba4 /Alc
parent528c8c5e774b28b74393b5517d8bee268f1d9624 (diff)
Rename SetThreadName to althrd_setname
Diffstat (limited to 'Alc')
-rw-r--r--Alc/backends/alsa.c4
-rw-r--r--Alc/backends/dsound.c2
-rw-r--r--Alc/backends/mmdevapi.c2
-rw-r--r--Alc/backends/null.c2
-rw-r--r--Alc/backends/oss.c4
-rw-r--r--Alc/backends/pulseaudio.c2
-rw-r--r--Alc/backends/qsa.c2
-rw-r--r--Alc/backends/sndio.c2
-rw-r--r--Alc/backends/solaris.c2
-rw-r--r--Alc/backends/wave.c2
-rw-r--r--Alc/backends/winmm.c4
-rw-r--r--Alc/threads.c18
12 files changed, 24 insertions, 22 deletions
diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c
index 56cbb9ca..70801aa8 100644
--- a/Alc/backends/alsa.c
+++ b/Alc/backends/alsa.c
@@ -430,7 +430,7 @@ static int ALCplaybackAlsa_mixerProc(void *ptr)
int err;
SetRTPriority();
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
update_size = device->UpdateSize;
num_updates = device->NumUpdates;
@@ -520,7 +520,7 @@ static int ALCplaybackAlsa_mixerNoMMapProc(void *ptr)
int err;
SetRTPriority();
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
update_size = device->UpdateSize;
num_updates = device->NumUpdates;
diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c
index ac97e54d..b09208ae 100644
--- a/Alc/backends/dsound.c
+++ b/Alc/backends/dsound.c
@@ -196,7 +196,7 @@ FORCE_ALIGN static int DSoundPlaybackProc(void *ptr)
HRESULT err;
SetRTPriority();
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
memset(&DSBCaps, 0, sizeof(DSBCaps));
DSBCaps.dwSize = sizeof(DSBCaps);
diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c
index 75d80749..54ac6dd6 100644
--- a/Alc/backends/mmdevapi.c
+++ b/Alc/backends/mmdevapi.c
@@ -232,7 +232,7 @@ FORCE_ALIGN static int MMDevApiProc(void *ptr)
}
SetRTPriority();
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
update_size = device->UpdateSize;
buffer_len = update_size * device->NumUpdates;
diff --git a/Alc/backends/null.c b/Alc/backends/null.c
index a96ab701..2c13a80f 100644
--- a/Alc/backends/null.c
+++ b/Alc/backends/null.c
@@ -78,7 +78,7 @@ static int ALCnullBackend_mixerProc(void *ptr)
device->Frequency / 2);
SetRTPriority();
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
done = 0;
if(altimespec_get(&start, AL_TIME_UTC) != AL_TIME_UTC)
diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c
index 2a4e4dd3..93e026e9 100644
--- a/Alc/backends/oss.c
+++ b/Alc/backends/oss.c
@@ -107,7 +107,7 @@ static int ALCplaybackOSS_mixerProc(void *ptr)
ssize_t wrote;
SetRTPriority();
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
@@ -345,7 +345,7 @@ static int ALCcaptureOSS_recordProc(void *ptr)
int amt;
SetRTPriority();
- SetThreadName("alsoft-record");
+ althrd_setname(althrd_current(), "alsoft-record");
frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c
index 8bc147a8..97068885 100644
--- a/Alc/backends/pulseaudio.c
+++ b/Alc/backends/pulseaudio.c
@@ -761,7 +761,7 @@ static int ALCpulsePlayback_mixerProc(void *ptr)
ssize_t len;
SetRTPriority();
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
pa_threaded_mainloop_lock(self->loop);
frame_size = pa_frame_size(&self->spec);
diff --git a/Alc/backends/qsa.c b/Alc/backends/qsa.c
index b77a66ad..9258e4e5 100644
--- a/Alc/backends/qsa.c
+++ b/Alc/backends/qsa.c
@@ -183,7 +183,7 @@ FORCE_ALIGN static int qsa_proc_playback(void* ptr)
struct timeval timeout;
SetRTPriority();
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
/* Increase default 10 priority to 11 to avoid jerky sound */
SchedGet(0, 0, &param);
diff --git a/Alc/backends/sndio.c b/Alc/backends/sndio.c
index cdc052c8..7152b2d6 100644
--- a/Alc/backends/sndio.c
+++ b/Alc/backends/sndio.c
@@ -59,7 +59,7 @@ static int sndio_proc(void *ptr)
size_t wrote;
SetRTPriority();
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
diff --git a/Alc/backends/solaris.c b/Alc/backends/solaris.c
index 7a8c23d2..20d861d2 100644
--- a/Alc/backends/solaris.c
+++ b/Alc/backends/solaris.c
@@ -62,7 +62,7 @@ static int SolarisProc(void *ptr)
int wrote;
SetRTPriority();
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
frameSize = FrameSizeFromDevFmt(Device->FmtChans, Device->FmtType);
diff --git a/Alc/backends/wave.c b/Alc/backends/wave.c
index 343a3cb5..421ca5d7 100644
--- a/Alc/backends/wave.c
+++ b/Alc/backends/wave.c
@@ -96,7 +96,7 @@ static int WaveProc(void *ptr)
const long restTime = (long)((ALuint64)device->UpdateSize * 1000000000 /
device->Frequency / 2);
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType);
diff --git a/Alc/backends/winmm.c b/Alc/backends/winmm.c
index acffd2f3..e5b18372 100644
--- a/Alc/backends/winmm.c
+++ b/Alc/backends/winmm.c
@@ -192,7 +192,7 @@ FORCE_ALIGN static DWORD WINAPI PlaybackThreadProc(LPVOID param)
FrameSize = FrameSizeFromDevFmt(Device->FmtChans, Device->FmtType);
SetRTPriority();
- SetThreadName(MIXER_THREAD_NAME);
+ althrd_setname(althrd_current(), MIXER_THREAD_NAME);
while(GetMessage(&msg, NULL, 0, 0))
{
@@ -255,7 +255,7 @@ static DWORD WINAPI CaptureThreadProc(LPVOID param)
MSG msg;
FrameSize = FrameSizeFromDevFmt(Device->FmtChans, Device->FmtType);
- SetThreadName("alsoft-record");
+ althrd_setname(althrd_current(), "alsoft-record");
while(GetMessage(&msg, NULL, 0, 0))
{
diff --git a/Alc/threads.c b/Alc/threads.c
index e1d071ac..29e177ea 100644
--- a/Alc/threads.c
+++ b/Alc/threads.c
@@ -29,6 +29,7 @@
#include "alThunk.h"
+extern inline althrd_t althrd_current(void);
extern inline int althrd_equal(althrd_t thr0, althrd_t thr1);
extern inline void althrd_exit(int res);
extern inline void althrd_yield(void);
@@ -50,7 +51,7 @@ extern inline int altss_set(altss_t tss_id, void *val);
#include <mmsystem.h>
-void SetThreadName(const char *name)
+void althrd_setname(althrd_t thr, const char *name)
{
#if defined(_MSC_VER)
#define MS_VC_EXCEPTION 0x406D1388
@@ -64,7 +65,7 @@ void SetThreadName(const char *name)
#pragma pack(pop)
info.dwType = 0x1000;
info.szName = name;
- info.dwThreadID = -1;
+ info.dwThreadID = ((thr == GetCurrentThread()) ? -1 : GetThreadId(thr));
info.dwFlags = 0;
__try {
@@ -74,7 +75,7 @@ void SetThreadName(const char *name)
}
#undef MS_VC_EXCEPTION
#else
- TRACE("Can't set thread %04lx name to \"%s\"\n", GetCurrentThreadId(), name);
+ TRACE("Can't set thread %04lx name to \"%s\"\n", GetThreadId(thr), name);
#endif
}
@@ -282,21 +283,22 @@ int altimespec_get(struct timespec *ts, int base)
#endif
-extern inline althrd_t althrd_current(void);
extern inline int althrd_sleep(const struct timespec *ts, struct timespec *rem);
-void SetThreadName(const char *name)
+void althrd_setname(althrd_t thr, const char *name)
{
#if defined(HAVE_PTHREAD_SETNAME_NP)
#if defined(__GNUC__)
- if(pthread_setname_np(pthread_self(), name) != 0)
+ if(pthread_setname_np(thr, name) != 0)
#elif defined(__APPLE__)
- if(pthread_setname_np(name) != 0)
+ if(!althrd_equal(thr, althrd_current())
+ WARN("Can't set thread name \"%s\" on non-current thread");
+ else if(pthread_setname_np(name) != 0)
#endif
WARN("Failed to set thread name to \"%s\": %s\n", name, strerror(errno));
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
- pthread_set_name_np(pthread_self(), name);
+ pthread_set_name_np(thr, name);
#else
TRACE("Can't set thread name to \"%s\"\n", name);
#endif