mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-12-17 08:56:42 -05:00
a bit of pa_bool_t'ization
This commit is contained in:
parent
adc2973c8d
commit
58b53bbc1a
2 changed files with 7 additions and 6 deletions
|
|
@ -28,13 +28,13 @@
|
||||||
|
|
||||||
#include "once.h"
|
#include "once.h"
|
||||||
|
|
||||||
int pa_once_begin(pa_once *control) {
|
pa_bool_t pa_once_begin(pa_once *control) {
|
||||||
pa_mutex *m;
|
pa_mutex *m;
|
||||||
|
|
||||||
pa_assert(control);
|
pa_assert(control);
|
||||||
|
|
||||||
if (pa_atomic_load(&control->done))
|
if (pa_atomic_load(&control->done))
|
||||||
return 0;
|
return FALSE;
|
||||||
|
|
||||||
pa_atomic_inc(&control->ref);
|
pa_atomic_inc(&control->ref);
|
||||||
|
|
||||||
|
|
@ -50,15 +50,17 @@ int pa_once_begin(pa_once *control) {
|
||||||
* wait until it is unlocked */
|
* wait until it is unlocked */
|
||||||
pa_mutex_lock(m);
|
pa_mutex_lock(m);
|
||||||
|
|
||||||
|
pa_assert(pa_atomic_load(&control->done));
|
||||||
|
|
||||||
pa_once_end(control);
|
pa_once_end(control);
|
||||||
return 0;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_assert_se(m = pa_mutex_new(FALSE, FALSE));
|
pa_assert_se(m = pa_mutex_new(FALSE, FALSE));
|
||||||
pa_mutex_lock(m);
|
pa_mutex_lock(m);
|
||||||
|
|
||||||
if (pa_atomic_ptr_cmpxchg(&control->mutex, NULL, m))
|
if (pa_atomic_ptr_cmpxchg(&control->mutex, NULL, m))
|
||||||
return 1;
|
return TRUE;
|
||||||
|
|
||||||
pa_mutex_unlock(m);
|
pa_mutex_unlock(m);
|
||||||
pa_mutex_free(m);
|
pa_mutex_free(m);
|
||||||
|
|
@ -91,4 +93,3 @@ void pa_run_once(pa_once *control, pa_once_func_t func) {
|
||||||
pa_once_end(control);
|
pa_once_end(control);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ typedef struct pa_once {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Not to be called directly, use the macros defined below instead */
|
/* Not to be called directly, use the macros defined below instead */
|
||||||
int pa_once_begin(pa_once *o);
|
pa_bool_t pa_once_begin(pa_once *o);
|
||||||
void pa_once_end(pa_once *o);
|
void pa_once_end(pa_once *o);
|
||||||
|
|
||||||
#define PA_ONCE_BEGIN \
|
#define PA_ONCE_BEGIN \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue