add proper boolean type pa_bool_t

git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1836 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2007-09-16 23:28:56 +00:00
parent 116ddaaae9
commit 61b90a0951
10 changed files with 83 additions and 56 deletions

View file

@ -130,6 +130,18 @@ else
AC_MSG_RESULT([no])
fi
AC_MSG_CHECKING([whether $CC knows _Bool])
AC_LANG_CONFTEST([int main() { _Bool b; }])
$CC conftest.c $CFLAGS -o conftest > /dev/null 2> /dev/null
ret=$?
rm -f conftest.o conftest
if test $ret -eq 0 ; then
AC_DEFINE([HAVE_STD_BOOL], 1, [Have _Bool.])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
#### libtool stuff ####
AC_LTDL_ENABLE_INSTALL

View file

@ -72,6 +72,21 @@ static inline size_t pa_page_align(size_t l) {
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
/* This type is not intended to be used in exported APIs! Use classic "int" there! */
#ifdef HAVE_STD_BOOL
typedef _Bool pa_bool_t;
#else
typedef int pa_bool_t;
#endif
#ifndef FALSE
#define FALSE ((pa_bool_t) 0)
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#ifdef __GNUC__
#define PA_PRETTY_FUNCTION __PRETTY_FUNCTION__
#else

View file

@ -79,10 +79,10 @@ void pa_sink_input_new_data_set_sample_spec(pa_sink_input_new_data *data, const
data->sample_spec = *spec;
}
void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, int mute) {
void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, pa_bool_t mute) {
pa_assert(data);
data->muted_is_set = 1;
data->muted_is_set = TRUE;
data->muted = !!mute;
}
@ -607,7 +607,7 @@ const pa_cvolume *pa_sink_input_get_volume(pa_sink_input *i) {
return &i->volume;
}
void pa_sink_input_set_mute(pa_sink_input *i, int mute) {
void pa_sink_input_set_mute(pa_sink_input *i, pa_bool_t mute) {
pa_assert(i);
pa_sink_input_assert_ref(i);
pa_assert(PA_SINK_INPUT_LINKED(i->state));
@ -628,7 +628,7 @@ int pa_sink_input_get_mute(pa_sink_input *i) {
return !!i->muted;
}
void pa_sink_input_cork(pa_sink_input *i, int b) {
void pa_sink_input_cork(pa_sink_input *i, pa_bool_t b) {
pa_sink_input_assert_ref(i);
pa_assert(PA_SINK_INPUT_LINKED(i->state));

View file

@ -46,7 +46,7 @@ typedef enum pa_sink_input_state {
PA_SINK_INPUT_UNLINKED /*< The stream is dead */
} pa_sink_input_state_t;
static inline int PA_SINK_INPUT_LINKED(pa_sink_input_state_t x) {
static inline pa_bool_t PA_SINK_INPUT_LINKED(pa_sink_input_state_t x) {
return x == PA_SINK_INPUT_DRAINED || x == PA_SINK_INPUT_RUNNING || x == PA_SINK_INPUT_CORKED;
}
@ -80,7 +80,7 @@ struct pa_sink_input {
pa_sink_input *sync_prev, *sync_next;
pa_cvolume volume;
int muted;
pa_bool_t muted;
/* Returns the chunk of audio data (but doesn't drop it
* yet!). Returns -1 on failure. Called from IO thread context. If
@ -139,7 +139,7 @@ struct pa_sink_input {
pa_sink_input *sync_prev, *sync_next;
pa_cvolume volume;
int muted;
pa_bool_t muted;
} thread_info;
void *userdata;
@ -165,14 +165,14 @@ typedef struct pa_sink_input_new_data {
pa_sink *sink;
pa_sample_spec sample_spec;
int sample_spec_is_set;
pa_bool_t sample_spec_is_set;
pa_channel_map channel_map;
int channel_map_is_set;
pa_bool_t channel_map_is_set;
pa_cvolume volume;
int volume_is_set;
int muted;
int muted_is_set;
pa_bool_t volume_is_set;
pa_bool_t muted;
pa_bool_t muted_is_set;
pa_resample_method_t resample_method;
@ -183,7 +183,7 @@ pa_sink_input_new_data* pa_sink_input_new_data_init(pa_sink_input_new_data *data
void pa_sink_input_new_data_set_sample_spec(pa_sink_input_new_data *data, const pa_sample_spec *spec);
void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const pa_channel_map *map);
void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume);
void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, int mute);
void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, pa_bool_t mute);
/* To be called by the implementing module only */
@ -206,10 +206,10 @@ pa_usec_t pa_sink_input_get_latency(pa_sink_input *i);
void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume);
const pa_cvolume *pa_sink_input_get_volume(pa_sink_input *i);
void pa_sink_input_set_mute(pa_sink_input *i, int mute);
void pa_sink_input_set_mute(pa_sink_input *i, pa_bool_t mute);
int pa_sink_input_get_mute(pa_sink_input *i);
void pa_sink_input_cork(pa_sink_input *i, int b);
void pa_sink_input_cork(pa_sink_input *i, pa_bool_t b);
int pa_sink_input_set_rate(pa_sink_input *i, uint32_t rate);

View file

@ -105,8 +105,8 @@ pa_sink* pa_sink_new(
s->n_corked = 0;
pa_cvolume_reset(&s->volume, spec->channels);
s->muted = 0;
s->refresh_volume = s->refresh_mute = 0;
s->muted = FALSE;
s->refresh_volume = s->refresh_mute = FALSE;
s->get_latency = NULL;
s->set_volume = NULL;
@ -295,7 +295,7 @@ int pa_sink_update_status(pa_sink*s) {
return sink_set_state(s, pa_sink_used_by(s) ? PA_SINK_RUNNING : PA_SINK_IDLE);
}
int pa_sink_suspend(pa_sink *s, int suspend) {
int pa_sink_suspend(pa_sink *s, pa_bool_t suspend) {
pa_sink_assert_ref(s);
pa_assert(PA_SINK_LINKED(s->state));
@ -678,7 +678,7 @@ const pa_cvolume *pa_sink_get_volume(pa_sink *s) {
return &s->volume;
}
void pa_sink_set_mute(pa_sink *s, int mute) {
void pa_sink_set_mute(pa_sink *s, pa_bool_t mute) {
int changed;
pa_sink_assert_ref(s);
@ -697,8 +697,8 @@ void pa_sink_set_mute(pa_sink *s, int mute) {
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
}
int pa_sink_get_mute(pa_sink *s) {
int old_muted;
pa_bool_t pa_sink_get_mute(pa_sink *s) {
pa_bool_t old_muted;
pa_sink_assert_ref(s);
pa_assert(PA_SINK_LINKED(s->state));
@ -927,7 +927,7 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
return 0;
case PA_SINK_MESSAGE_GET_MUTE:
*((int*) userdata) = s->thread_info.soft_muted;
*((pa_bool_t*) userdata) = s->thread_info.soft_muted;
return 0;
case PA_SINK_MESSAGE_PING:
@ -960,7 +960,7 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
return -1;
}
int pa_sink_suspend_all(pa_core *c, int suspend) {
int pa_sink_suspend_all(pa_core *c, pa_bool_t suspend) {
pa_sink *sink;
uint32_t idx;
int ret = 0;

View file

@ -52,11 +52,11 @@ typedef enum pa_sink_state {
PA_SINK_UNLINKED
} pa_sink_state_t;
static inline int PA_SINK_OPENED(pa_sink_state_t x) {
static inline pa_bool_t PA_SINK_OPENED(pa_sink_state_t x) {
return x == PA_SINK_RUNNING || x == PA_SINK_IDLE;
}
static inline int PA_SINK_LINKED(pa_sink_state_t x) {
static inline pa_bool_t PA_SINK_LINKED(pa_sink_state_t x) {
return x == PA_SINK_RUNNING || x == PA_SINK_IDLE || x == PA_SINK_SUSPENDED;
}
@ -81,9 +81,9 @@ struct pa_sink {
pa_source *monitor_source;
pa_cvolume volume;
int muted;
int refresh_volume;
int refresh_mute;
pa_bool_t muted;
pa_bool_t refresh_volume;
pa_bool_t refresh_mute;
int (*set_state)(pa_sink *s, pa_sink_state_t state); /* may be NULL */
int (*set_volume)(pa_sink *s); /* dito */
@ -101,7 +101,7 @@ struct pa_sink {
pa_sink_state_t state;
pa_hashmap *inputs;
pa_cvolume soft_volume;
int soft_muted;
pa_bool_t soft_muted;
} thread_info;
pa_memblock *silence;
@ -154,8 +154,8 @@ void pa_sink_attach(pa_sink *s);
pa_usec_t pa_sink_get_latency(pa_sink *s);
int pa_sink_update_status(pa_sink*s);
int pa_sink_suspend(pa_sink *s, int suspend);
int pa_sink_suspend_all(pa_core *c, int suspend);
int pa_sink_suspend(pa_sink *s, pa_bool_t suspend);
int pa_sink_suspend_all(pa_core *c, pa_bool_t suspend);
/* Sends a ping message to the sink thread, to make it wake up and
* check for data to process even if there is no real message is
@ -164,8 +164,8 @@ void pa_sink_ping(pa_sink *s);
void pa_sink_set_volume(pa_sink *sink, const pa_cvolume *volume);
const pa_cvolume *pa_sink_get_volume(pa_sink *sink);
void pa_sink_set_mute(pa_sink *sink, int mute);
int pa_sink_get_mute(pa_sink *sink);
void pa_sink_set_mute(pa_sink *sink, pa_bool_t mute);
pa_bool_t pa_sink_get_mute(pa_sink *sink);
unsigned pa_sink_linked_by(pa_sink *s); /* Number of connected streams */
unsigned pa_sink_used_by(pa_sink *s); /* Number of connected streams which are not corked */

View file

@ -306,7 +306,7 @@ void pa_source_output_push(pa_source_output *o, const pa_memchunk *chunk) {
pa_memblock_unref(rchunk.memblock);
}
void pa_source_output_cork(pa_source_output *o, int b) {
void pa_source_output_cork(pa_source_output *o, pa_bool_t b) {
pa_source_output_assert_ref(o);
pa_assert(PA_SOURCE_OUTPUT_LINKED(o->state));

View file

@ -42,7 +42,7 @@ typedef enum pa_source_output_state {
PA_SOURCE_OUTPUT_UNLINKED
} pa_source_output_state_t;
static inline int PA_SOURCE_OUTPUT_LINKED(pa_source_output_state_t x) {
static inline pa_bool_t PA_SOURCE_OUTPUT_LINKED(pa_source_output_state_t x) {
return x == PA_SOURCE_OUTPUT_RUNNING || x == PA_SOURCE_OUTPUT_CORKED;
}
@ -126,9 +126,9 @@ typedef struct pa_source_output_new_data {
pa_source *source;
pa_sample_spec sample_spec;
int sample_spec_is_set;
pa_bool_t sample_spec_is_set;
pa_channel_map channel_map;
int channel_map_is_set;
pa_bool_t channel_map_is_set;
pa_resample_method_t resample_method;
} pa_source_output_new_data;
@ -157,7 +157,7 @@ void pa_source_output_kill(pa_source_output*o);
pa_usec_t pa_source_output_get_latency(pa_source_output *i);
void pa_source_output_cork(pa_source_output *i, int b);
void pa_source_output_cork(pa_source_output *i, pa_bool_t b);
int pa_source_output_set_rate(pa_source_output *o, uint32_t rate);

View file

@ -97,8 +97,8 @@ pa_source* pa_source_new(
s->monitor_of = NULL;
pa_cvolume_reset(&s->volume, spec->channels);
s->muted = 0;
s->refresh_volume = s->refresh_muted = 0;
s->muted = FALSE;
s->refresh_volume = s->refresh_muted = FALSE;
s->get_latency = NULL;
s->set_volume = NULL;
@ -240,7 +240,7 @@ int pa_source_update_status(pa_source*s) {
return source_set_state(s, pa_source_used_by(s) ? PA_SOURCE_RUNNING : PA_SOURCE_IDLE);
}
int pa_source_suspend(pa_source *s, int suspend) {
int pa_source_suspend(pa_source *s, pa_bool_t suspend) {
pa_source_assert_ref(s);
pa_assert(PA_SOURCE_LINKED(s->state));
@ -348,7 +348,7 @@ const pa_cvolume *pa_source_get_volume(pa_source *s) {
return &s->volume;
}
void pa_source_set_mute(pa_source *s, int mute) {
void pa_source_set_mute(pa_source *s, pa_bool_t mute) {
int changed;
pa_source_assert_ref(s);
@ -367,8 +367,8 @@ void pa_source_set_mute(pa_source *s, int mute) {
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
}
int pa_source_get_mute(pa_source *s) {
int old_muted;
pa_bool_t pa_source_get_mute(pa_source *s) {
pa_bool_t old_muted;
pa_source_assert_ref(s);
pa_assert(PA_SOURCE_LINKED(s->state));
@ -487,7 +487,7 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_
return 0;
case PA_SOURCE_MESSAGE_GET_MUTE:
*((int*) userdata) = s->thread_info.soft_muted;
*((pa_bool_t*) userdata) = s->thread_info.soft_muted;
return 0;
case PA_SOURCE_MESSAGE_PING:
@ -519,7 +519,7 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_
return -1;
}
int pa_source_suspend_all(pa_core *c, int suspend) {
int pa_source_suspend_all(pa_core *c, pa_bool_t suspend) {
uint32_t idx;
pa_source *source;
int ret = 0;

View file

@ -54,11 +54,11 @@ typedef enum pa_source_state {
PA_SOURCE_UNLINKED
} pa_source_state_t;
static inline int PA_SOURCE_OPENED(pa_source_state_t x) {
static inline pa_bool_t PA_SOURCE_OPENED(pa_source_state_t x) {
return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE;
}
static inline int PA_SOURCE_LINKED(pa_source_state_t x) {
static inline pa_bool_t PA_SOURCE_LINKED(pa_source_state_t x) {
return x == PA_SOURCE_RUNNING || x == PA_SOURCE_IDLE || x == PA_SOURCE_SUSPENDED;
}
@ -83,9 +83,9 @@ struct pa_source {
pa_sink *monitor_of; /* may be NULL */
pa_cvolume volume;
int muted;
int refresh_volume;
int refresh_muted;
pa_bool_t muted;
pa_bool_t refresh_volume;
pa_bool_t refresh_muted;
int (*set_state)(pa_source*source, pa_source_state_t state); /* may be NULL */
int (*set_volume)(pa_source *s); /* dito */
@ -103,7 +103,7 @@ struct pa_source {
pa_source_state_t state;
pa_hashmap *outputs;
pa_cvolume soft_volume;
int soft_muted;
pa_bool_t soft_muted;
} thread_info;
void *userdata;
@ -153,15 +153,15 @@ void pa_source_attach(pa_source *s);
pa_usec_t pa_source_get_latency(pa_source *s);
int pa_source_update_status(pa_source*s);
int pa_source_suspend(pa_source *s, int suspend);
int pa_source_suspend_all(pa_core *c, int suspend);
int pa_source_suspend(pa_source *s, pa_bool_t suspend);
int pa_source_suspend_all(pa_core *c, pa_bool_t suspend);
void pa_source_ping(pa_source *s);
void pa_source_set_volume(pa_source *source, const pa_cvolume *volume);
const pa_cvolume *pa_source_get_volume(pa_source *source);
void pa_source_set_mute(pa_source *source, int mute);
int pa_source_get_mute(pa_source *source);
void pa_source_set_mute(pa_source *source, pa_bool_t mute);
pa_bool_t pa_source_get_mute(pa_source *source);
unsigned pa_source_linked_by(pa_source *s); /* Number of connected streams */
unsigned pa_source_used_by(pa_source *s); /* Number of connected streams that are not corked */