2006-04-30 23:34:17 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
|
|
/***
|
2006-06-19 21:53:48 +00:00
|
|
|
This file is part of PulseAudio.
|
2006-04-30 23:34:17 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
2006-04-30 23:34:17 +00:00
|
|
|
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.
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
2006-04-30 23:34:17 +00:00
|
|
|
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
|
2006-06-19 21:53:48 +00:00
|
|
|
along with PulseAudio; if not, write to the Free Software
|
2006-04-30 23:34:17 +00:00
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2006-05-02 08:41:41 +00:00
|
|
|
#ifdef HAVE_SYS_POLL_H
|
|
|
|
|
#include <sys/poll.h>
|
|
|
|
|
#else
|
2006-06-19 21:53:48 +00:00
|
|
|
#include "../pulsecore/poll.h"
|
2006-05-02 08:41:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_PTHREAD
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef HAVE_WINDOWS_H
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulse/xmalloc.h>
|
2006-05-17 16:34:18 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulsecore/log.h>
|
|
|
|
|
#include <pulsecore/hashmap.h>
|
2006-04-30 23:34:17 +00:00
|
|
|
|
|
|
|
|
#include "mainloop.h"
|
|
|
|
|
#include "thread-mainloop.h"
|
|
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#if defined(HAVE_PTHREAD) || defined(OS_IS_WIN32)
|
2006-05-02 08:41:41 +00:00
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
struct pa_threaded_mainloop {
|
|
|
|
|
pa_mainloop *real_mainloop;
|
2006-05-11 14:57:24 +00:00
|
|
|
int n_waiting;
|
|
|
|
|
int thread_running;
|
|
|
|
|
|
|
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
DWORD thread_id;
|
|
|
|
|
HANDLE thread;
|
|
|
|
|
CRITICAL_SECTION mutex;
|
|
|
|
|
pa_hashmap *cond_events;
|
|
|
|
|
HANDLE accept_cond;
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_t thread_id;
|
|
|
|
|
pthread_mutex_t mutex;
|
2006-05-11 13:01:24 +00:00
|
|
|
pthread_cond_t cond, accept_cond;
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
};
|
|
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
static inline int in_worker(pa_threaded_mainloop *m) {
|
|
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
return GetCurrentThreadId() == m->thread_id;
|
|
|
|
|
#else
|
|
|
|
|
return pthread_equal(pthread_self(), m->thread_id);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
static int poll_func(struct pollfd *ufds, unsigned long nfds, int timeout, void *userdata) {
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
CRITICAL_SECTION *mutex = userdata;
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_t *mutex = userdata;
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
assert(mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
/* Before entering poll() we unlock the mutex, so that
|
|
|
|
|
* avahi_simple_poll_quit() can succeed from another thread. */
|
|
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
LeaveCriticalSection(mutex);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_unlock(mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
r = poll(ufds, nfds, timeout);
|
2006-05-11 14:57:24 +00:00
|
|
|
|
|
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
EnterCriticalSection(mutex);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_lock(mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
static DWORD WINAPI thread(void *userdata) {
|
|
|
|
|
#else
|
|
|
|
|
static void* thread(void *userdata) {
|
|
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
pa_threaded_mainloop *m = userdata;
|
2006-05-11 14:57:24 +00:00
|
|
|
|
|
|
|
|
#ifndef OS_IS_WIN32
|
2006-04-30 23:34:17 +00:00
|
|
|
sigset_t mask;
|
|
|
|
|
|
|
|
|
|
/* Make sure that signals are delivered to the main thread */
|
|
|
|
|
sigfillset(&mask);
|
|
|
|
|
pthread_sigmask(SIG_BLOCK, &mask, NULL);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
EnterCriticalSection(&m->mutex);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_lock(&m->mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
pa_mainloop_run(m->real_mainloop, NULL);
|
2006-05-11 14:57:24 +00:00
|
|
|
|
|
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
LeaveCriticalSection(&m->mutex);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_unlock(&m->mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
return 0;
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
return NULL;
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pa_threaded_mainloop *pa_threaded_mainloop_new(void) {
|
|
|
|
|
pa_threaded_mainloop *m;
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifndef OS_IS_WIN32
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutexattr_t a;
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
|
|
|
|
|
m = pa_xnew(pa_threaded_mainloop, 1);
|
|
|
|
|
|
|
|
|
|
if (!(m->real_mainloop = pa_mainloop_new())) {
|
|
|
|
|
pa_xfree(m);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pa_mainloop_set_poll_func(m->real_mainloop, poll_func, &m->mutex);
|
|
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
InitializeCriticalSection(&m->mutex);
|
|
|
|
|
|
|
|
|
|
m->cond_events = pa_hashmap_new(NULL, NULL);
|
|
|
|
|
assert(m->cond_events);
|
|
|
|
|
m->accept_cond = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
|
|
|
assert(m->accept_cond);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutexattr_init(&a);
|
|
|
|
|
pthread_mutexattr_settype(&a, PTHREAD_MUTEX_RECURSIVE);
|
2006-05-06 20:58:02 +00:00
|
|
|
pthread_mutex_init(&m->mutex, &a);
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutexattr_destroy(&a);
|
|
|
|
|
|
|
|
|
|
pthread_cond_init(&m->cond, NULL);
|
2006-05-11 13:01:24 +00:00
|
|
|
pthread_cond_init(&m->accept_cond, NULL);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
m->thread_running = 0;
|
2006-05-06 20:58:02 +00:00
|
|
|
m->n_waiting = 0;
|
2006-04-30 23:34:17 +00:00
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_free(pa_threaded_mainloop* m) {
|
|
|
|
|
assert(m);
|
|
|
|
|
|
|
|
|
|
/* Make sure that this function is not called from the helper thread */
|
2006-05-11 14:57:24 +00:00
|
|
|
assert(!m->thread_running || !in_worker(m));
|
2006-04-30 23:34:17 +00:00
|
|
|
|
|
|
|
|
if (m->thread_running)
|
|
|
|
|
pa_threaded_mainloop_stop(m);
|
|
|
|
|
|
|
|
|
|
if (m->real_mainloop)
|
|
|
|
|
pa_mainloop_free(m->real_mainloop);
|
|
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
pa_hashmap_free(m->cond_events, NULL, NULL);
|
|
|
|
|
CloseHandle(m->accept_cond);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_destroy(&m->mutex);
|
|
|
|
|
pthread_cond_destroy(&m->cond);
|
2006-05-11 13:01:24 +00:00
|
|
|
pthread_cond_destroy(&m->accept_cond);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
|
|
|
|
|
pa_xfree(m);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int pa_threaded_mainloop_start(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(m);
|
|
|
|
|
|
|
|
|
|
assert(!m->thread_running);
|
|
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
|
|
|
|
|
EnterCriticalSection(&m->mutex);
|
|
|
|
|
|
|
|
|
|
m->thread = CreateThread(NULL, 0, thread, m, 0, &m->thread_id);
|
|
|
|
|
if (!m->thread) {
|
|
|
|
|
LeaveCriticalSection(&m->mutex);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_lock(&m->mutex);
|
|
|
|
|
|
|
|
|
|
if (pthread_create(&m->thread_id, NULL, thread, m) < 0) {
|
|
|
|
|
pthread_mutex_unlock(&m->mutex);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
m->thread_running = 1;
|
|
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
LeaveCriticalSection(&m->mutex);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_unlock(&m->mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_stop(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(m);
|
|
|
|
|
|
|
|
|
|
if (!m->thread_running)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Make sure that this function is not called from the helper thread */
|
2006-05-11 14:57:24 +00:00
|
|
|
assert(!in_worker(m));
|
2006-04-30 23:34:17 +00:00
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
EnterCriticalSection(&m->mutex);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_lock(&m->mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
pa_mainloop_quit(m->real_mainloop, 0);
|
2006-05-11 14:57:24 +00:00
|
|
|
|
|
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
LeaveCriticalSection(&m->mutex);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_unlock(&m->mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
WaitForSingleObject(m->thread, INFINITE);
|
|
|
|
|
CloseHandle(m->thread);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_join(m->thread_id, NULL);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
m->thread_running = 0;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_lock(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(m);
|
|
|
|
|
|
|
|
|
|
/* Make sure that this function is not called from the helper thread */
|
2006-05-11 14:57:24 +00:00
|
|
|
assert(!m->thread_running || !in_worker(m));
|
2006-04-30 23:34:17 +00:00
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
EnterCriticalSection(&m->mutex);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_lock(&m->mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_unlock(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(m);
|
|
|
|
|
|
|
|
|
|
/* Make sure that this function is not called from the helper thread */
|
2006-05-11 14:57:24 +00:00
|
|
|
assert(!m->thread_running || !in_worker(m));
|
2006-04-30 23:34:17 +00:00
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
LeaveCriticalSection(&m->mutex);
|
|
|
|
|
#else
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_mutex_unlock(&m->mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-11 13:01:24 +00:00
|
|
|
void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_accept) {
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
void *iter;
|
|
|
|
|
const void *key;
|
|
|
|
|
HANDLE event;
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
assert(m);
|
2006-05-11 14:57:24 +00:00
|
|
|
|
|
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
|
|
|
|
|
iter = NULL;
|
|
|
|
|
while (1) {
|
|
|
|
|
pa_hashmap_iterate(m->cond_events, &iter, &key);
|
|
|
|
|
if (key == NULL)
|
|
|
|
|
break;
|
|
|
|
|
event = (HANDLE)pa_hashmap_get(m->cond_events, key);
|
|
|
|
|
SetEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_cond_broadcast(&m->cond);
|
2006-05-06 20:58:02 +00:00
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (wait_for_accept && m->n_waiting > 0) {
|
|
|
|
|
|
|
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
|
|
|
|
|
/* This is just to make sure it's unsignaled */
|
|
|
|
|
WaitForSingleObject(m->accept_cond, 0);
|
|
|
|
|
|
|
|
|
|
LeaveCriticalSection(&m->mutex);
|
|
|
|
|
|
|
|
|
|
WaitForSingleObject(m->accept_cond, INFINITE);
|
|
|
|
|
|
|
|
|
|
EnterCriticalSection(&m->mutex);
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
2006-05-11 13:01:24 +00:00
|
|
|
pthread_cond_wait(&m->accept_cond, &m->mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
2006-04-30 23:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) {
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
HANDLE event;
|
|
|
|
|
DWORD result;
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
assert(m);
|
|
|
|
|
|
|
|
|
|
/* Make sure that this function is not called from the helper thread */
|
2006-05-11 14:57:24 +00:00
|
|
|
assert(!m->thread_running || !in_worker(m));
|
2006-04-30 23:34:17 +00:00
|
|
|
|
2006-05-06 20:58:02 +00:00
|
|
|
m->n_waiting ++;
|
2006-05-11 14:57:24 +00:00
|
|
|
|
|
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
|
|
|
|
|
event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
|
|
|
assert(event);
|
|
|
|
|
|
|
|
|
|
pa_hashmap_put(m->cond_events, event, event);
|
|
|
|
|
|
|
|
|
|
LeaveCriticalSection(&m->mutex);
|
|
|
|
|
|
|
|
|
|
result = WaitForSingleObject(event, INFINITE);
|
|
|
|
|
assert(result == WAIT_OBJECT_0);
|
|
|
|
|
|
|
|
|
|
EnterCriticalSection(&m->mutex);
|
|
|
|
|
|
|
|
|
|
pa_hashmap_remove(m->cond_events, event);
|
|
|
|
|
|
|
|
|
|
CloseHandle(event);
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
2006-04-30 23:34:17 +00:00
|
|
|
pthread_cond_wait(&m->cond, &m->mutex);
|
2006-05-11 14:57:24 +00:00
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-05-06 20:58:02 +00:00
|
|
|
assert(m->n_waiting > 0);
|
|
|
|
|
m->n_waiting --;
|
2006-05-11 13:01:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_accept(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(m);
|
|
|
|
|
|
|
|
|
|
/* Make sure that this function is not called from the helper thread */
|
2006-05-11 14:57:24 +00:00
|
|
|
assert(!m->thread_running || !in_worker(m));
|
2006-05-11 13:01:24 +00:00
|
|
|
|
2006-05-11 14:57:24 +00:00
|
|
|
#ifdef OS_IS_WIN32
|
|
|
|
|
SetEvent(m->accept_cond);
|
|
|
|
|
#else
|
2006-05-11 13:01:24 +00:00
|
|
|
pthread_cond_signal(&m->accept_cond);
|
2006-05-11 14:57:24 +00:00
|
|
|
#endif
|
2006-04-30 23:34:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int pa_threaded_mainloop_get_retval(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(m);
|
|
|
|
|
|
|
|
|
|
return pa_mainloop_get_retval(m->real_mainloop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pa_mainloop_api* pa_threaded_mainloop_get_api(pa_threaded_mainloop*m) {
|
|
|
|
|
assert(m);
|
|
|
|
|
|
|
|
|
|
return pa_mainloop_get_api(m->real_mainloop);
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-09 08:39:26 +00:00
|
|
|
#else /* defined(OS_IS_WIN32) || defined(HAVE_PTHREAD) */
|
2006-05-02 08:41:41 +00:00
|
|
|
|
2006-05-09 08:39:26 +00:00
|
|
|
pa_threaded_mainloop *pa_threaded_mainloop_new(void) {
|
|
|
|
|
pa_log_error(__FILE__": Threaded main loop not supported on this platform");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_free(pa_threaded_mainloop* m) {
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int pa_threaded_mainloop_start(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(0);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_stop(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_lock(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_unlock(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_wait(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void pa_threaded_mainloop_signal(pa_threaded_mainloop *m, int wait_for_release) {
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int pa_threaded_mainloop_get_retval(pa_threaded_mainloop *m) {
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pa_mainloop_api* pa_threaded_mainloop_get_api(pa_threaded_mainloop*m) {
|
|
|
|
|
assert(0);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2006-05-02 08:41:41 +00:00
|
|
|
|
2006-05-09 08:39:26 +00:00
|
|
|
#endif /* defined(OS_IS_WIN32) || defined(HAVE_PTHREAD) */
|