mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
Fix up build structure for platform dependent modules. Also add implementation
on Win32 for pa_once(). git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1395 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
a85b3e2dd4
commit
772645922a
3 changed files with 96 additions and 56 deletions
|
|
@ -70,6 +70,18 @@ AM_LDFLAGS+=-Wl,--export-all-symbols
|
|||
WINSOCK_LIBS=-lwsock32 -lws2_32 -lwininet
|
||||
endif
|
||||
|
||||
if OS_IS_WIN32
|
||||
PA_THREAD_OBJS = \
|
||||
pulsecore/once-win32.c pulsecore/once.h \
|
||||
pulsecore/mutex-win32.c pulsecore/mutex.h \
|
||||
pulsecore/thread-win32.c pulsecore/thread.h
|
||||
else
|
||||
PA_THREAD_OBJS = \
|
||||
pulsecore/once-posix.c pulsecore/once.h \
|
||||
pulsecore/mutex-posix.c pulsecore/mutex.h \
|
||||
pulsecore/thread-posix.c pulsecore/thread.h
|
||||
endif
|
||||
|
||||
###################################
|
||||
# Extra files #
|
||||
###################################
|
||||
|
|
@ -251,14 +263,15 @@ memblock_test_CFLAGS = $(AM_CFLAGS)
|
|||
memblock_test_LDADD = $(AM_LDADD) libpulsecore.la
|
||||
memblock_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
|
||||
|
||||
thread_test_SOURCES = tests/thread-test.c pulse/xmalloc.c pulsecore/flist.c pulsecore/thread-posix.c pulsecore/mutex-posix.c pulsecore/log.c pulsecore/core-util.c pulse/util.c pulse/utf8.c pulsecore/core-error.c pulsecore/once-posix.c
|
||||
thread_test_SOURCES = tests/thread-test.c
|
||||
thread_test_CFLAGS = $(AM_CFLAGS)
|
||||
thread_test_LDADD = $(AM_LDADD)
|
||||
thread_test_LDADD = $(AM_LDADD) libpulsecore.la
|
||||
thread_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
|
||||
|
||||
flist_test_SOURCES = tests/flist-test.c pulse/xmalloc.c pulsecore/flist.c pulsecore/thread-posix.c pulsecore/mutex-posix.c pulsecore/log.c pulsecore/core-util.c pulse/util.c pulse/utf8.c pulsecore/core-error.c pulsecore/once-posix.c
|
||||
flist_test_SOURCES = tests/flist-test.c \
|
||||
pulsecore/flist.c pulsecore/flist.h
|
||||
flist_test_CFLAGS = $(AM_CFLAGS)
|
||||
flist_test_LDADD = $(AM_LDADD)
|
||||
flist_test_LDADD = $(AM_LDADD) libpulsecore.la
|
||||
flist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
|
||||
|
||||
mcalign_test_SOURCES = tests/mcalign-test.c
|
||||
|
|
@ -434,7 +447,8 @@ libpulse_la_SOURCES += \
|
|||
pulsecore/tagstruct.c pulsecore/tagstruct.h \
|
||||
pulsecore/core-error.c pulsecore/core-error.h \
|
||||
pulsecore/winsock.h pulsecore/creds.h \
|
||||
pulsecore/shm.c pulsecore/shm.h
|
||||
pulsecore/shm.c pulsecore/shm.h \
|
||||
$(PA_THREAD_OBJS)
|
||||
|
||||
if OS_IS_WIN32
|
||||
libpulse_la_SOURCES += \
|
||||
|
|
@ -544,7 +558,8 @@ pulsecoreinclude_HEADERS = \
|
|||
pulsecore/llist.h \
|
||||
pulsecore/refcnt.h \
|
||||
pulsecore/mutex.h \
|
||||
pulsecore/thread.h
|
||||
pulsecore/thread.h \
|
||||
pulsecore/once.h
|
||||
|
||||
lib_LTLIBRARIES += libpulsecore.la
|
||||
|
||||
|
|
@ -586,7 +601,6 @@ libpulsecore_la_SOURCES += \
|
|||
pulsecore/modargs.c pulsecore/modargs.h \
|
||||
pulsecore/modinfo.c pulsecore/modinfo.h \
|
||||
pulsecore/module.c pulsecore/module.h \
|
||||
pulsecore/mutex.h \
|
||||
pulsecore/namereg.c pulsecore/namereg.h \
|
||||
pulsecore/pid.c pulsecore/pid.h \
|
||||
pulsecore/pipe.c pulsecore/pipe.h \
|
||||
|
|
@ -609,36 +623,18 @@ libpulsecore_la_SOURCES += \
|
|||
pulsecore/source.c pulsecore/source.h \
|
||||
pulsecore/source-output.c pulsecore/source-output.h \
|
||||
pulsecore/strbuf.c pulsecore/strbuf.h \
|
||||
pulsecore/thread.h \
|
||||
pulsecore/tokenizer.c pulsecore/tokenizer.h \
|
||||
pulsecore/winsock.h \
|
||||
pulsecore/core-error.c pulsecore/core-error.h \
|
||||
pulsecore/hook-list.c pulsecore/hook-list.h \
|
||||
pulsecore/shm.c pulsecore/shm.h
|
||||
pulsecore/shm.c pulsecore/shm.h \
|
||||
$(PA_THREAD_OBJS)
|
||||
|
||||
if OS_IS_WIN32
|
||||
libpulsecore_la_SOURCES += \
|
||||
pulsecore/dllmain.c
|
||||
endif
|
||||
|
||||
if OS_IS_WIN32
|
||||
libpulsecore_la_SOURCES += \
|
||||
pulsecore/mutex-win32.c \
|
||||
pulsecore/thread-win32.c
|
||||
libpulse_la_SOURCES += \
|
||||
pulsecore/mutex-win32.c \
|
||||
pulsecore/thread-win32.c
|
||||
else
|
||||
libpulsecore_la_SOURCES += \
|
||||
pulsecore/mutex-posix.c \
|
||||
pulsecore/thread-posix.c \
|
||||
pulsecore/once-posix.c
|
||||
libpulse_la_SOURCES += \
|
||||
pulsecore/mutex-posix.c \
|
||||
pulsecore/thread-posix.c \
|
||||
pulsecore/once-posix.c
|
||||
endif
|
||||
|
||||
libpulsecore_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBOIL_CFLAGS)
|
||||
libpulsecore_la_LDFLAGS = -version-info $(LIBPULSECORE_VERSION_INFO)
|
||||
libpulsecore_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSNDFILE_LIBS) $(WINSOCK_LIBS) $(LIBOIL_LIBS) $(LIBICONV)
|
||||
|
|
|
|||
67
src/pulsecore/once-win32.c
Normal file
67
src/pulsecore/once-win32.c
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/* $Id$ */
|
||||
|
||||
/***
|
||||
This file is part of PulseAudio.
|
||||
|
||||
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,
|
||||
or (at your option) any later version.
|
||||
|
||||
PulseAudio is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with PulseAudio; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
USA.
|
||||
***/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <pulsecore/mutex.h>
|
||||
|
||||
#include "once.h"
|
||||
|
||||
void pa_once(pa_once_t *control, pa_once_func_t func) {
|
||||
HANDLE mutex;
|
||||
char name[64];
|
||||
|
||||
assert(control);
|
||||
assert(func);
|
||||
|
||||
/* Create the global mutex */
|
||||
sprintf(name, "pulse%d", (int)GetCurrentProcessId());
|
||||
|
||||
mutex = CreateMutex(NULL, FALSE, name);
|
||||
assert(mutex);
|
||||
|
||||
/* Create the local mutex */
|
||||
WaitForSingleObject(mutex, INFINITE);
|
||||
if (!control->mutex)
|
||||
control->mutex = pa_mutex_new(1);
|
||||
ReleaseMutex(mutex);
|
||||
|
||||
CloseHandle(mutex);
|
||||
|
||||
/* Execute function */
|
||||
pa_mutex_lock(control->mutex);
|
||||
if (!control->once_value) {
|
||||
control->once_value = 1;
|
||||
func();
|
||||
}
|
||||
pa_mutex_unlock(control->mutex);
|
||||
|
||||
/* Caveat: We have to make sure that the once func has completed
|
||||
* before returning, even if the once func is not actually
|
||||
* executed by us. Hence the awkward locking. */
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <pulse/xmalloc.h>
|
||||
#include <pulsecore/log.h>
|
||||
#include <pulsecore/once.h>
|
||||
|
||||
#include "thread.h"
|
||||
|
||||
|
|
@ -50,9 +51,9 @@ struct pa_tls_monitor {
|
|||
};
|
||||
|
||||
static pa_tls *thread_tls;
|
||||
static pa_thread_once_t thread_tls_once = PA_THREAD_ONCE_INIT;
|
||||
static pa_once_t thread_tls_once = PA_ONCE_INIT;
|
||||
static pa_tls *monitor_tls;
|
||||
static pa_thread_once_t monitor_tls_once = PA_THREAD_ONCE_INIT;
|
||||
static pa_once_t monitor_tls_once = PA_ONCE_INIT;
|
||||
|
||||
static void thread_tls_once_func(void) {
|
||||
thread_tls = pa_tls_new(NULL);
|
||||
|
|
@ -63,7 +64,7 @@ static DWORD WINAPI internal_thread_func(LPVOID param) {
|
|||
pa_thread *t = param;
|
||||
assert(t);
|
||||
|
||||
pa_thread_once(&thread_tls_once, thread_tls_once_func);
|
||||
pa_once(&thread_tls_once, thread_tls_once_func);
|
||||
pa_tls_set(thread_tls, t);
|
||||
|
||||
t->thread_func(t->userdata);
|
||||
|
|
@ -119,7 +120,7 @@ int pa_thread_join(pa_thread *t) {
|
|||
}
|
||||
|
||||
pa_thread* pa_thread_self(void) {
|
||||
pa_thread_once(&thread_tls_once, thread_tls_once_func);
|
||||
pa_once(&thread_tls_once, thread_tls_once_func);
|
||||
return pa_tls_get(thread_tls);
|
||||
}
|
||||
|
||||
|
|
@ -127,30 +128,6 @@ void pa_thread_yield(void) {
|
|||
Sleep(0);
|
||||
}
|
||||
|
||||
void pa_thread_once(pa_thread_once_t *control, pa_thread_once_func_t once_func) {
|
||||
HANDLE mutex;
|
||||
char name[64];
|
||||
|
||||
assert(control);
|
||||
assert(once_func);
|
||||
|
||||
sprintf(name, "pulse%d", (int)GetCurrentProcessId());
|
||||
|
||||
mutex = CreateMutex(NULL, FALSE, name);
|
||||
assert(mutex);
|
||||
|
||||
WaitForSingleObject(mutex, INFINITE);
|
||||
|
||||
if (*control == PA_THREAD_ONCE_INIT) {
|
||||
*control = ~PA_THREAD_ONCE_INIT;
|
||||
ReleaseMutex(mutex);
|
||||
once_func();
|
||||
} else
|
||||
ReleaseMutex(mutex);
|
||||
|
||||
CloseHandle(mutex);
|
||||
}
|
||||
|
||||
static void monitor_tls_once_func(void) {
|
||||
monitor_tls = pa_tls_new(NULL);
|
||||
assert(monitor_tls);
|
||||
|
|
@ -212,7 +189,7 @@ void *pa_tls_set(pa_tls *t, void *userdata) {
|
|||
if (t->free_func) {
|
||||
struct pa_tls_monitor *m;
|
||||
|
||||
pa_thread_once(&monitor_tls_once, monitor_tls_once_func);
|
||||
pa_once(&monitor_tls_once, monitor_tls_once_func);
|
||||
|
||||
m = pa_tls_get(monitor_tls);
|
||||
if (!m) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue