X-Git-Url: https://code.delx.au/pulseaudio/blobdiff_plain/06211b7c8fd329137ae9003818543912a87d9898..33a88fbfdee773b1473cb5339540d79809363bdc:/src/pulsecore/thread-win32.c diff --git a/src/pulsecore/thread-win32.c b/src/pulsecore/thread-win32.c index 46d273b4..7d458b97 100644 --- a/src/pulsecore/thread-win32.c +++ b/src/pulsecore/thread-win32.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /*** This file is part of PulseAudio. @@ -7,7 +5,7 @@ PulseAudio is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation; either version 2 of the License, + by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. PulseAudio is distributed in the hope that it will be useful, but @@ -53,9 +51,8 @@ struct pa_tls_monitor { }; static pa_tls *thread_tls; -static pa_once_t thread_tls_once = PA_ONCE_INIT; +static pa_once thread_tls_once = PA_ONCE_INIT; static pa_tls *monitor_tls; -static pa_once_t monitor_tls_once = PA_ONCE_INIT; static void thread_tls_once_func(void) { thread_tls = pa_tls_new(NULL); @@ -66,7 +63,7 @@ static DWORD WINAPI internal_thread_func(LPVOID param) { pa_thread *t = param; assert(t); - pa_once(&thread_tls_once, thread_tls_once_func); + pa_run_once(&thread_tls_once, thread_tls_once_func); pa_tls_set(thread_tls, t); t->thread_func(t->userdata); @@ -74,8 +71,9 @@ static DWORD WINAPI internal_thread_func(LPVOID param) { return 0; } -pa_thread* pa_thread_new(pa_thread_func_t thread_func, void *userdata) { +pa_thread* pa_thread_new(const char *name, pa_thread_func_t thread_func, void *userdata) { pa_thread *t; + DWORD thread_id; assert(thread_func); @@ -83,7 +81,7 @@ pa_thread* pa_thread_new(pa_thread_func_t thread_func, void *userdata) { t->thread_func = thread_func; t->userdata = userdata; - t->thread = CreateThread(NULL, 0, internal_thread_func, t, 0, NULL); + t->thread = CreateThread(NULL, 0, internal_thread_func, t, 0, &thread_id); if (!t->thread) { pa_xfree(t); @@ -122,7 +120,7 @@ int pa_thread_join(pa_thread *t) { } pa_thread* pa_thread_self(void) { - pa_once(&thread_tls_once, thread_tls_once_func); + pa_run_once(&thread_tls_once, thread_tls_once_func); return pa_tls_get(thread_tls); } @@ -130,12 +128,6 @@ void pa_thread_yield(void) { Sleep(0); } -static void monitor_tls_once_func(void) { - monitor_tls = pa_tls_new(NULL); - assert(monitor_tls); - pa_tls_set(monitor_tls, NULL); -} - static DWORD WINAPI monitor_thread_func(LPVOID param) { struct pa_tls_monitor *m = param; assert(m); @@ -191,7 +183,11 @@ void *pa_tls_set(pa_tls *t, void *userdata) { if (t->free_func) { struct pa_tls_monitor *m; - pa_once(&monitor_tls_once, monitor_tls_once_func); + PA_ONCE_BEGIN { + monitor_tls = pa_tls_new(NULL); + assert(monitor_tls); + pa_tls_set(monitor_tls, NULL); + } PA_ONCE_END; m = pa_tls_get(monitor_tls); if (!m) {