d = pa_xnew0(pa_bluetooth_device, 1);
d->discovery = discovery;
- d->dead = FALSE;
+ d->dead = false;
d->device_info_valid = 0;
pa_assert(d);
if (!d->device_info_valid || d->audio_state == PA_BT_AUDIO_STATE_INVALID)
- return FALSE;
+ return false;
for (i = 0; i < PA_BLUETOOTH_PROFILE_COUNT; i++)
if (d->profile_state[i] != PA_BT_AUDIO_STATE_INVALID)
- return TRUE;
+ return true;
- return FALSE;
+ return false;
}
static const char *check_variant_property(DBusMessageIter *i) {
if (dbus_message_iter_get_arg_type(&ai) == DBUS_TYPE_STRING && pa_streq(key, "UUIDs")) {
DBusMessage *m;
- pa_bool_t has_audio = FALSE;
+ pa_bool_t has_audio = false;
while (dbus_message_iter_get_arg_type(&ai) != DBUS_TYPE_INVALID) {
pa_bluetooth_uuid *node;
pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.HandsfreeGateway",
"GetProperties"));
send_and_add_to_pending(d->discovery, m, get_properties_reply, d);
- has_audio = TRUE;
+ has_audio = true;
} else if (strcasecmp(HSP_HS_UUID, value) == 0 || strcasecmp(HFP_HS_UUID, value) == 0) {
pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.Headset",
"GetProperties"));
send_and_add_to_pending(d->discovery, m, get_properties_reply, d);
- has_audio = TRUE;
+ has_audio = true;
} else if (strcasecmp(A2DP_SINK_UUID, value) == 0) {
pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.AudioSink",
"GetProperties"));
send_and_add_to_pending(d->discovery, m, get_properties_reply, d);
- has_audio = TRUE;
+ has_audio = true;
} else if (strcasecmp(A2DP_SOURCE_UUID, value) == 0) {
pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.AudioSource",
"GetProperties"));
send_and_add_to_pending(d->discovery, m, get_properties_reply, d);
- has_audio = TRUE;
+ has_audio = true;
}
dbus_message_iter_next(&ai);
pa_assert(y);
while ((d = pa_hashmap_steal_first(y->devices))) {
- run_callback(d, TRUE);
+ run_callback(d, true);
device_free(d);
}
}
finish:
if (d != NULL && old_any_connected != pa_bluetooth_device_any_audio_connected(d))
- run_callback(d, FALSE);
+ run_callback(d, false);
finish2:
dbus_message_unref(r);
pa_log_debug("Device %s removed", path);
if ((d = pa_hashmap_remove(y->devices, path))) {
- run_callback(d, TRUE);
+ run_callback(d, true);
device_free(d);
}
goto fail;
if (old_any_connected != pa_bluetooth_device_any_audio_connected(d))
- run_callback(d, FALSE);
+ run_callback(d, false);
}
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
const char *sender, *path, *dev_path = NULL, *uuid = NULL;
uint8_t *config = NULL;
int size = 0;
- pa_bool_t nrec = FALSE;
+ pa_bool_t nrec = false;
enum profile p;
DBusMessageIter args, props;
DBusMessage *r;
pa_assert_se(r = dbus_message_new_method_return(m));
if (old_any_connected != pa_bluetooth_device_any_audio_connected(d))
- run_callback(d, FALSE);
+ run_callback(d, false);
return r;
pa_hook_fire(&y->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED], t);
if (old_any_connected != pa_bluetooth_device_any_audio_connected(t->device))
- run_callback(t->device, FALSE);
+ run_callback(t->device, false);
transport_free(t);
}
goto fail;
}
- y->filter_added = TRUE;
+ y->filter_added = true;
if (pa_dbus_add_matches(
conn, &err,
char *pa_bluetooth_cleanup_name(const char *name) {
char *t, *s, *d;
- pa_bool_t space = FALSE;
+ pa_bool_t space = false;
pa_assert(name);
for (s = d = t; *s; s++) {
if (*s <= 32 || *s >= 127 || *s == '_') {
- space = TRUE;
+ space = true;
continue;
}
if (space) {
*(d++) = ' ';
- space = FALSE;
+ space = false;
}
*(d++) = *s;
while (uuids) {
if (strcasecmp(uuids->uuid, uuid) == 0)
- return TRUE;
+ return true;
uuids = uuids->next;
}
- return FALSE;
+ return false;
}
PA_MODULE_AUTHOR("Joao Paulo Rechi Vita");
PA_MODULE_DESCRIPTION("Bluetooth audio sink and source");
PA_MODULE_VERSION(PACKAGE_VERSION);
-PA_MODULE_LOAD_ONCE(FALSE);
+PA_MODULE_LOAD_ONCE(false);
PA_MODULE_USAGE(
"name=<name for the card/sink/source, to be prefixed> "
"card_name=<name for the card> "
u->read_smoother = pa_smoother_new(
PA_USEC_PER_SEC,
PA_USEC_PER_SEC*2,
- TRUE,
- TRUE,
+ true,
+ true,
10,
pa_rtclock_now(),
- TRUE);
+ true);
}
static void teardown_stream(struct userdata *u) {
/* Run from IO thread */
static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
struct userdata *u = PA_SINK(o)->userdata;
- pa_bool_t failed = FALSE;
+ pa_bool_t failed = false;
int r;
pa_assert(u->sink == PA_SINK(o));
/* Resume the device if the source was suspended as well */
if (!u->source || !PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
if (bt_transport_acquire(u, false) < 0)
- failed = TRUE;
+ failed = true;
else
setup_stream(u);
}
/* Run from IO thread */
static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
struct userdata *u = PA_SOURCE(o)->userdata;
- pa_bool_t failed = FALSE;
+ pa_bool_t failed = false;
int r;
pa_assert(u->source == PA_SOURCE(o));
/* Resume the device if the sink was suspended as well */
if (!u->sink || !PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
if (bt_transport_acquire(u, false) < 0)
- failed = TRUE;
+ failed = true;
else
setup_stream(u);
}
struct cmsghdr *cm;
uint8_t aux[1024];
struct iovec iov;
- pa_bool_t found_tstamp = FALSE;
+ pa_bool_t found_tstamp = false;
pa_usec_t tstamp;
memset(&m, 0, sizeof(m));
struct timeval *tv = (struct timeval*) CMSG_DATA(cm);
pa_rtclock_from_wallclock(tv);
tstamp = pa_timeval_load(tv);
- found_tstamp = TRUE;
+ found_tstamp = true;
break;
}
}
pa_smoother_put(u->read_smoother, tstamp, pa_bytes_to_usec(u->read_index, &u->sample_spec));
- pa_smoother_resume(u->read_smoother, tstamp, TRUE);
+ pa_smoother_resume(u->read_smoother, tstamp, true);
pa_source_post(u->source, &memchunk);
memchunk.index = memchunk.length = 0;
for (;;) {
- pa_bool_t found_tstamp = FALSE;
+ pa_bool_t found_tstamp = false;
pa_usec_t tstamp;
struct a2dp_info *a2dp;
struct rtp_header *header;
}
pa_smoother_put(u->read_smoother, tstamp, pa_bytes_to_usec(u->read_index, &u->sample_spec));
- pa_smoother_resume(u->read_smoother, tstamp, TRUE);
+ pa_smoother_resume(u->read_smoother, tstamp, true);
p = (uint8_t*) a2dp->buffer + sizeof(*header) + sizeof(*payload);
to_decode = l - sizeof(*header) - sizeof(*payload);
struct userdata *u = userdata;
unsigned do_write = 0;
unsigned pending_read_bytes = 0;
- pa_bool_t writable = FALSE;
+ pa_bool_t writable = false;
pa_assert(u);
pa_assert(u->transport);
for (;;) {
struct pollfd *pollfd;
int ret;
- pa_bool_t disable_timer = TRUE;
+ pa_bool_t disable_timer = true;
pollfd = u->rtpoll_item ? pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL) : NULL;
if (pollfd) {
if (pollfd->revents & POLLOUT)
- writable = TRUE;
+ writable = true;
if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && do_write <= 0 && writable) {
pa_usec_t time_passed;
pa_log("Broken kernel: we got EAGAIN on write() after POLLOUT!");
do_write -= n_written;
- writable = FALSE;
+ writable = false;
}
if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && do_write <= 0) {
sleep_for = PA_USEC_PER_MSEC * 500;
pa_rtpoll_set_timer_relative(u->rtpoll, sleep_for);
- disable_timer = FALSE;
+ disable_timer = false;
}
}
}
pollfd->events = (short) (((u->sink && PA_SINK_IS_LINKED(u->sink->thread_info.state) && !writable) ? POLLOUT : 0) |
(u->source && PA_SOURCE_IS_LINKED(u->source->thread_info.state) ? POLLIN : 0));
- if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0) {
+ if ((ret = pa_rtpoll_run(u->rtpoll, true)) < 0) {
pa_log_debug("pa_rtpoll_run failed with: %d", ret);
goto fail;
}
do_write = 0;
pending_read_bytes = 0;
- writable = FALSE;
+ writable = false;
teardown_stream(u);
}
/* Run from main thread */
static void handle_transport_state_change(struct userdata *u, struct pa_bluetooth_transport *transport) {
- bool acquire = FALSE;
- bool release = FALSE;
+ pa_bool_t acquire = false;
+ pa_bool_t release = false;
enum profile profile;
pa_bluetooth_transport_state_t state;
if (bt_transport_acquire(u, true) >= 0) {
if (u->source) {
pa_log_debug("Resuming source %s, because the bluetooth audio state changed to 'playing'.", u->source->name);
- pa_source_suspend(u->source, FALSE, PA_SUSPEND_IDLE|PA_SUSPEND_USER);
+ pa_source_suspend(u->source, false, PA_SUSPEND_IDLE|PA_SUSPEND_USER);
}
if (u->sink) {
pa_log_debug("Resuming sink %s, because the bluetooth audio state changed to 'playing'.", u->sink->name);
- pa_sink_suspend(u->sink, FALSE, PA_SUSPEND_IDLE|PA_SUSPEND_USER);
+ pa_sink_suspend(u->sink, false, PA_SUSPEND_IDLE|PA_SUSPEND_USER);
}
}
/* Remote side closed the stream so we consider it PA_SUSPEND_USER */
if (u->source) {
pa_log_debug("Suspending source %s, because the remote end closed the stream.", u->source->name);
- pa_source_suspend(u->source, TRUE, PA_SUSPEND_USER);
+ pa_source_suspend(u->source, true, PA_SUSPEND_USER);
}
if (u->sink) {
pa_log_debug("Suspending sink %s, because the remote end closed the stream.", u->sink->name);
- pa_sink_suspend(u->sink, TRUE, PA_SUSPEND_USER);
+ pa_sink_suspend(u->sink, true, PA_SUSPEND_USER);
}
}
}
pa_xfree(t);
if (n) {
- *namereg_fail = TRUE;
+ *namereg_fail = true;
return pa_xstrdup(n);
}
if ((n = pa_modargs_get_value(ma, "name", NULL)))
- *namereg_fail = TRUE;
+ *namereg_fail = true;
else {
n = device_id;
- *namereg_fail = FALSE;
+ *namereg_fail = false;
}
return pa_sprintf_malloc("bluez_%s.%s", type, n);
if (!USE_SCO_OVER_PCM(u) || s != u->hsp.sco_sink)
return PA_HOOK_OK;
- sco_over_pcm_state_update(u, TRUE);
+ sco_over_pcm_state_update(u, true);
return PA_HOOK_OK;
}
if (!USE_SCO_OVER_PCM(u) || s != u->hsp.sco_source)
return PA_HOOK_OK;
- sco_over_pcm_state_update(u, TRUE);
+ sco_over_pcm_state_update(u, true);
return PA_HOOK_OK;
}
sbc_reinit(&a2dp->sbc, 0);
else
sbc_init(&a2dp->sbc, 0);
- a2dp->sbc_initialized = TRUE;
+ a2dp->sbc_initialized = true;
switch (config->frequency) {
case SBC_SAMPLING_FREQ_16000:
pa_thread_mq_init(&u->thread_mq, u->core->mainloop, u->rtpoll);
if (USE_SCO_OVER_PCM(u)) {
- if (sco_over_pcm_state_update(u, FALSE) < 0) {
+ if (sco_over_pcm_state_update(u, false) < 0) {
char *k;
if (u->sink) {
if (*d != PROFILE_OFF && !device->transports[*d]) {
pa_log_warn("Default profile not connected, selecting off profile");
u->card->active_profile = pa_hashmap_get(u->card->profiles, "off");
- u->card->save_profile = FALSE;
+ u->card->save_profile = false;
}
d = PA_CARD_PROFILE_DATA(u->card->active_profile);
goto fail;
}
- u->auto_connect = TRUE;
+ u->auto_connect = true;
if (pa_modargs_get_value_boolean(ma, "auto_connect", &u->auto_connect)) {
pa_log("Failed to parse auto_connect= argument");
goto fail;