mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-09 13:29:59 -05:00
fix handling of "running" variable
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1349 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
ad0535beef
commit
2f6cc4f8fa
1 changed files with 8 additions and 3 deletions
|
|
@ -66,9 +66,9 @@ static void* internal_thread_func(void *userdata) {
|
||||||
ASSERT_SUCCESS(pthread_once(&thread_tls_once, thread_tls_once_func));
|
ASSERT_SUCCESS(pthread_once(&thread_tls_once, thread_tls_once_func));
|
||||||
pa_tls_set(thread_tls, t);
|
pa_tls_set(thread_tls, t);
|
||||||
|
|
||||||
AO_store_release_write(&t->running, 1);
|
AO_fetch_and_add1_full(&t->running);
|
||||||
t->thread_func(t->userdata);
|
t->thread_func(t->userdata);
|
||||||
AO_store_release_write(&t->running, 0);
|
AO_fetch_and_add_full(&t->running, (AO_t) -2);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -79,19 +79,24 @@ pa_thread* pa_thread_new(pa_thread_func_t thread_func, void *userdata) {
|
||||||
t = pa_xnew(pa_thread, 1);
|
t = pa_xnew(pa_thread, 1);
|
||||||
t->thread_func = thread_func;
|
t->thread_func = thread_func;
|
||||||
t->userdata = userdata;
|
t->userdata = userdata;
|
||||||
|
AO_store_full(&t->running, 0);
|
||||||
|
|
||||||
if (pthread_create(&t->id, NULL, internal_thread_func, t) < 0) {
|
if (pthread_create(&t->id, NULL, internal_thread_func, t) < 0) {
|
||||||
pa_xfree(t);
|
pa_xfree(t);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AO_fetch_and_add1_full(&t->running);
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pa_thread_is_running(pa_thread *t) {
|
int pa_thread_is_running(pa_thread *t) {
|
||||||
|
AO_t r;
|
||||||
assert(t);
|
assert(t);
|
||||||
|
|
||||||
return !!AO_load_acquire_read(&t->running);
|
r = AO_load_full(&t->running);
|
||||||
|
return r == 1 || r == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa_thread_free(pa_thread *t) {
|
void pa_thread_free(pa_thread *t) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue