[pulseaudio-commits] 8 commits - src/modules
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Fri Jan 11 12:11:49 PST 2013
src/modules/bluetooth/bluetooth-util.c | 206 +++++++++++----------
src/modules/bluetooth/bluetooth-util.h | 6
src/modules/bluetooth/module-bluetooth-device.c | 86 ++++----
src/modules/bluetooth/module-bluetooth-discover.c | 2
src/modules/bluetooth/module-bluetooth-policy.c | 10 -
src/modules/bluetooth/module-bluetooth-proximity.c | 22 +-
6 files changed, 172 insertions(+), 160 deletions(-)
New commits:
commit b1e47df72c0bb8fd802a96911dc479bd8dfd8a0a
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Fri Jan 11 22:11:04 2013 +0200
bluetooth: Convert booleans to stdbool.
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index d78505f..92254f2 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -70,7 +70,7 @@ struct pa_bluetooth_discovery {
pa_hashmap *devices;
pa_hashmap *transports;
pa_hook hooks[PA_BLUETOOTH_HOOK_MAX];
- pa_bool_t filter_added;
+ bool filter_added;
};
static void get_properties_reply(DBusPendingCall *pending, void *userdata);
@@ -411,7 +411,7 @@ static int parse_device_property(pa_bluetooth_device *d, 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;
+ bool has_audio = false;
while (dbus_message_iter_get_arg_type(&ai) != DBUS_TYPE_INVALID) {
pa_bluetooth_uuid *node;
@@ -599,7 +599,7 @@ static int parse_audio_property(pa_bluetooth_device *d, const char *interface, D
return 0;
}
-static void run_callback(pa_bluetooth_device *d, pa_bool_t dead) {
+static void run_callback(pa_bluetooth_device *d, bool dead) {
pa_assert(d);
if (d->device_info_valid != 1)
@@ -1257,7 +1257,7 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
const char *sender, *path, *dev_path = NULL, *uuid = NULL;
uint8_t *config = NULL;
int size = 0;
- pa_bool_t nrec = false;
+ bool nrec = false;
enum profile p;
DBusMessageIter args, props;
DBusMessage *r;
@@ -1808,7 +1808,7 @@ const char*pa_bluetooth_get_form_factor(uint32_t class) {
char *pa_bluetooth_cleanup_name(const char *name) {
char *t, *s, *d;
- pa_bool_t space = false;
+ bool space = false;
pa_assert(name);
@@ -1837,7 +1837,7 @@ char *pa_bluetooth_cleanup_name(const char *name) {
return t;
}
-pa_bool_t pa_bluetooth_uuid_has(pa_bluetooth_uuid *uuids, const char *uuid) {
+bool pa_bluetooth_uuid_has(pa_bluetooth_uuid *uuids, const char *uuid) {
pa_assert(uuid);
while (uuids) {
diff --git a/src/modules/bluetooth/bluetooth-util.h b/src/modules/bluetooth/bluetooth-util.h
index b7c5973..6423f88 100644
--- a/src/modules/bluetooth/bluetooth-util.h
+++ b/src/modules/bluetooth/bluetooth-util.h
@@ -99,7 +99,7 @@ struct pa_bluetooth_transport {
int config_size;
pa_bluetooth_transport_state_t state;
- pa_bool_t nrec;
+ bool nrec;
uint16_t microphone_gain; /* Used for HSP/HFP */
uint16_t speaker_gain; /* Used for HSP/HFP */
};
@@ -115,7 +115,7 @@ typedef enum pa_bt_audio_state {
struct pa_bluetooth_device {
pa_bluetooth_discovery *discovery;
- pa_bool_t dead;
+ bool dead;
int device_info_valid; /* 0: no results yet; 1: good results; -1: bad results ... */
@@ -158,7 +158,7 @@ const char* pa_bluetooth_get_form_factor(uint32_t class);
char *pa_bluetooth_cleanup_name(const char *name);
-pa_bool_t pa_bluetooth_uuid_has(pa_bluetooth_uuid *uuids, const char *uuid);
+bool pa_bluetooth_uuid_has(pa_bluetooth_uuid *uuids, const char *uuid);
const char *pa_bt_profile_to_string(enum profile profile);
#endif
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index c2ac15f..becf716 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -104,7 +104,7 @@ static const char* const valid_modargs[] = {
struct a2dp_info {
sbc_t sbc; /* Codec data */
- pa_bool_t sbc_initialized; /* Keep track if the encoder is initialized */
+ bool sbc_initialized; /* Keep track if the encoder is initialized */
size_t codesize, frame_length; /* SBC Codesize, frame_length. We simply cache those values here */
void* buffer; /* Codec transfer buffer */
@@ -150,7 +150,7 @@ struct userdata {
pa_hook_slot *transport_speaker_changed_slot;
pa_bluetooth_discovery *discovery;
- pa_bool_t auto_connect;
+ bool auto_connect;
pa_card *card;
pa_sink *sink;
@@ -351,7 +351,7 @@ static void bt_transport_release(struct userdata *u) {
teardown_stream(u);
}
-static int bt_transport_acquire(struct userdata *u, pa_bool_t optional) {
+static int bt_transport_acquire(struct userdata *u, bool optional) {
pa_assert(u->transport);
if (u->transport_acquired)
@@ -378,7 +378,7 @@ static int bt_transport_acquire(struct userdata *u, pa_bool_t optional) {
/* 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;
+ bool failed = false;
int r;
pa_assert(u->sink == PA_SINK(o));
@@ -456,7 +456,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
/* 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;
+ bool failed = false;
int r;
pa_assert(u->source == PA_SOURCE(o));
@@ -627,7 +627,7 @@ static int hsp_process_push(struct userdata *u) {
struct cmsghdr *cm;
uint8_t aux[1024];
struct iovec iov;
- pa_bool_t found_tstamp = false;
+ bool found_tstamp = false;
pa_usec_t tstamp;
memset(&m, 0, sizeof(m));
@@ -854,7 +854,7 @@ static int a2dp_process_push(struct userdata *u) {
memchunk.index = memchunk.length = 0;
for (;;) {
- pa_bool_t found_tstamp = false;
+ bool found_tstamp = false;
pa_usec_t tstamp;
struct a2dp_info *a2dp;
struct rtp_header *header;
@@ -980,7 +980,7 @@ static void thread_func(void *userdata) {
struct userdata *u = userdata;
unsigned do_write = 0;
unsigned pending_read_bytes = 0;
- pa_bool_t writable = false;
+ bool writable = false;
pa_assert(u);
pa_assert(u->transport);
@@ -999,7 +999,7 @@ static void thread_func(void *userdata) {
for (;;) {
struct pollfd *pollfd;
int ret;
- pa_bool_t disable_timer = true;
+ bool disable_timer = true;
pollfd = u->rtpoll_item ? pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL) : NULL;
@@ -1196,8 +1196,8 @@ static pa_port_available_t transport_state_to_availability_merged(pa_bluetooth_t
/* Run from main thread */
static void handle_transport_state_change(struct userdata *u, struct pa_bluetooth_transport *transport) {
- pa_bool_t acquire = false;
- pa_bool_t release = false;
+ bool acquire = false;
+ bool release = false;
enum profile profile;
pa_bluetooth_transport_state_t state;
@@ -1372,7 +1372,7 @@ static void source_set_volume_cb(pa_source *s) {
}
/* Run from main thread */
-static char *get_name(const char *type, pa_modargs *ma, const char *device_id, pa_bool_t *namereg_fail) {
+static char *get_name(const char *type, pa_modargs *ma, const char *device_id, bool *namereg_fail) {
char *t;
const char *n;
@@ -1400,7 +1400,7 @@ static char *get_name(const char *type, pa_modargs *ma, const char *device_id, p
return pa_sprintf_malloc("bluez_%s.%s", type, n);
}
-static int sco_over_pcm_state_update(struct userdata *u, pa_bool_t changed) {
+static int sco_over_pcm_state_update(struct userdata *u, bool changed) {
pa_assert(u);
pa_assert(USE_SCO_OVER_PCM(u));
@@ -1592,7 +1592,7 @@ static int add_sink(struct userdata *u) {
pa_proplist_free(p);
} else {
pa_sink_new_data data;
- pa_bool_t b;
+ bool b;
pa_sink_new_data_init(&data);
data.driver = __FILE__;
@@ -1662,7 +1662,7 @@ static int add_source(struct userdata *u) {
pa_proplist_sets(u->source->proplist, "bluetooth.protocol", pa_bt_profile_to_string(u->profile));
} else {
pa_source_new_data data;
- pa_bool_t b;
+ bool b;
pa_source_new_data_init(&data);
data.driver = __FILE__;
@@ -2253,7 +2253,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
/* Run from main thread */
static int add_card(struct userdata *u) {
pa_card_new_data data;
- pa_bool_t b;
+ bool b;
pa_card_profile *p;
enum profile *d;
const char *ff;
diff --git a/src/modules/bluetooth/module-bluetooth-policy.c b/src/modules/bluetooth/module-bluetooth-policy.c
index f0bffe9..fc605b3 100644
--- a/src/modules/bluetooth/module-bluetooth-policy.c
+++ b/src/modules/bluetooth/module-bluetooth-policy.c
@@ -38,7 +38,7 @@
PA_MODULE_AUTHOR("Frédéric Dalleau");
PA_MODULE_DESCRIPTION("When a bluetooth sink or source is added, load module-loopback");
PA_MODULE_VERSION(PACKAGE_VERSION);
-PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_LOAD_ONCE(true);
PA_MODULE_USAGE(
"a2dp_source=<Handle a2dp_source card profile (sink role)?> "
"hfgw=<Handle hfgw card profile (headset role)?>");
@@ -159,7 +159,7 @@ static void set_port_profile(pa_card *card, pa_device_port *port) {
pa_log_debug("Setting card '%s' to profile '%s'", card->name, profile->name);
- if (pa_card_set_profile(card, profile->name, FALSE) != 0)
+ if (pa_card_set_profile(card, profile->name, false) != 0)
pa_log_warn("Could not set profile '%s'", profile->name);
return;
@@ -170,7 +170,7 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
pa_card *card;
const char *s;
uint32_t state;
- pa_bool_t is_active_profile;
+ bool is_active_profile;
pa_device_port *port2;
PA_IDXSET_FOREACH(card, c->cards, state)
@@ -233,13 +233,13 @@ int pa__init(pa_module *m) {
m->userdata = u = pa_xnew0(struct userdata, 1);
- u->enable_a2dp_source = TRUE;
+ u->enable_a2dp_source = true;
if (pa_modargs_get_value_boolean(ma, "a2dp_source", &u->enable_a2dp_source) < 0) {
pa_log("Failed to parse a2dp_source argument.");
goto fail;
}
- u->enable_hfgw = TRUE;
+ u->enable_hfgw = true;
if (pa_modargs_get_value_boolean(ma, "hfgw", &u->enable_hfgw) < 0) {
pa_log("Failed to parse hfgw argument.");
goto fail;
diff --git a/src/modules/bluetooth/module-bluetooth-proximity.c b/src/modules/bluetooth/module-bluetooth-proximity.c
index 7d69e82..7f90951 100644
--- a/src/modules/bluetooth/module-bluetooth-proximity.c
+++ b/src/modules/bluetooth/module-bluetooth-proximity.c
@@ -49,7 +49,7 @@
PA_MODULE_AUTHOR("Lennart Poettering");
PA_MODULE_DESCRIPTION("Bluetooth Proximity Volume Control");
PA_MODULE_VERSION(PACKAGE_VERSION);
-PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_LOAD_ONCE(true);
PA_MODULE_USAGE(
"sink=<sink name> "
"hci=<hci device> "
@@ -91,8 +91,8 @@ struct userdata {
unsigned n_found;
unsigned n_unknown;
- pa_bool_t muted:1;
- pa_bool_t filter_added:1;
+ bool muted:1;
+ bool filter_added:1;
};
static void update_volume(struct userdata *u) {
@@ -101,7 +101,7 @@ static void update_volume(struct userdata *u) {
if (u->muted && u->n_found > 0) {
pa_sink *s;
- u->muted = FALSE;
+ u->muted = false;
if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK))) {
pa_log_warn("Sink device '%s' not available for unmuting.", pa_strnull(u->sink_name));
@@ -109,12 +109,12 @@ static void update_volume(struct userdata *u) {
}
pa_log_info("Found %u BT devices, unmuting.", u->n_found);
- pa_sink_set_mute(s, FALSE, FALSE);
+ pa_sink_set_mute(s, false, false);
} else if (!u->muted && (u->n_found+u->n_unknown) <= 0) {
pa_sink *s;
- u->muted = TRUE;
+ u->muted = true;
if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK))) {
pa_log_warn("Sink device '%s' not available for muting.", pa_strnull(u->sink_name));
@@ -122,7 +122,7 @@ static void update_volume(struct userdata *u) {
}
pa_log_info("No BT devices found, muting.");
- pa_sink_set_mute(s, TRUE, FALSE);
+ pa_sink_set_mute(s, true, false);
} else
pa_log_info("%u devices now active, %u with unknown state.", u->n_found, u->n_unknown);
@@ -325,7 +325,7 @@ finish:
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-static int update_matches(struct userdata *u, pa_bool_t add) {
+static int update_matches(struct userdata *u, bool add) {
char *filter1, *filter2;
DBusError e;
int r = -1;
@@ -360,7 +360,7 @@ static int update_matches(struct userdata *u, pa_bool_t add) {
if (add) {
pa_assert_se(dbus_connection_add_filter(pa_dbus_connection_get(u->dbus_connection), filter_func, u, NULL));
- u->filter_added = TRUE;
+ u->filter_added = true;
} else if (u->filter_added)
dbus_connection_remove_filter(pa_dbus_connection_get(u->dbus_connection), filter_func, u);
@@ -401,7 +401,7 @@ int pa__init(pa_module*m) {
goto fail;
}
- if (update_matches(u, TRUE) < 0)
+ if (update_matches(u, true) < 0)
goto fail;
pa_assert_se(msg = dbus_message_new_method_call("org.bluez", u->hci_path, "org.bluez.Adapter", "ListBondings"));
@@ -476,7 +476,7 @@ void pa__done(pa_module*m) {
}
if (u->dbus_connection) {
- update_matches(u, FALSE);
+ update_matches(u, false);
pa_dbus_connection_unref(u->dbus_connection);
}
commit a0cc0136ea28d88bf95f24f80003493cb3c981ad
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date: Fri Jan 11 11:07:49 2013 +0100
bluetooth: Simplify redundant error check
As pointed out by Tanu, checking both error conditions is redundant and
raises the question whether it's possible that one of the conditions is
true while the other is false.
Therefore, simplify the condition by just checking one part of the
disjunction.
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 48e12da..d78505f 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1129,7 +1129,7 @@ int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, bool optional, siz
pa_assert_se(dbus_message_append_args(m, DBUS_TYPE_STRING, &accesstype, DBUS_TYPE_INVALID));
r = dbus_connection_send_with_reply_and_block(pa_dbus_connection_get(t->device->discovery->connection), m, -1, &err);
- if (dbus_error_is_set(&err) || !r) {
+ if (!r) {
dbus_error_free(&err);
return -1;
}
@@ -1220,9 +1220,7 @@ static int setup_dbus(pa_bluetooth_discovery *y) {
dbus_error_init(&err);
- y->connection = pa_dbus_bus_get(y->core, DBUS_BUS_SYSTEM, &err);
-
- if (dbus_error_is_set(&err) || !y->connection) {
+ if (!(y->connection = pa_dbus_bus_get(y->core, DBUS_BUS_SYSTEM, &err))) {
pa_log("Failed to get D-Bus connection: %s", err.message);
dbus_error_free(&err);
return -1;
commit 241059de7069911f41f1c0299b4a1cad4fa575cc
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date: Fri Jan 11 11:07:48 2013 +0100
bluetooth: Remove device_is_audio_ready()
The function was used to check whether the basic properties of the
Bluetooth device have been received. This can be simplified by just
checking d->device_info_valid, since the state of the audio interface
is only relevant inside pa_bluetooth_device_any_audio_connected(), which
is used to trigger the discovery callback.
While checking device_info_valid, special care must be taken with all
three possible values: when set to -1, it means some error was triggered
while getting the device properties. Therefore, these devices can also
be ignored outside bluetooth-util.
Besides that, the patch slightly modifies the behavior of the internal
API affecting pa_bluetooth_discovery_get_by_address() and
pa_bluetooth_discovery_get_by_path(), since they will return the device
no matter the state of the audio interface. This however makes sense and
should have no influence in the current codebase given that the modules
make use of devices only after the discovery hook has been triggered.
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 149a476..48e12da 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -234,15 +234,6 @@ static void device_free(pa_bluetooth_device *d) {
pa_xfree(d);
}
-static pa_bool_t device_is_audio_ready(const pa_bluetooth_device *d) {
- pa_assert(d);
-
- if (!d->device_info_valid || d->audio_state == PA_BT_AUDIO_STATE_INVALID)
- return false;
-
- return true;
-}
-
static const char *check_variant_property(DBusMessageIter *i) {
const char *key;
@@ -611,7 +602,7 @@ static int parse_audio_property(pa_bluetooth_device *d, const char *interface, D
static void run_callback(pa_bluetooth_device *d, pa_bool_t dead) {
pa_assert(d);
- if (!device_is_audio_ready(d))
+ if (d->device_info_valid != 1)
return;
d->dead = dead;
@@ -1054,7 +1045,7 @@ pa_bluetooth_device* pa_bluetooth_discovery_get_by_address(pa_bluetooth_discover
while ((d = pa_hashmap_iterate(y->devices, &state, NULL)))
if (pa_streq(d->address, address))
- return device_is_audio_ready(d) ? d : NULL;
+ return d->device_info_valid == 1 ? d : NULL;
return NULL;
}
@@ -1067,7 +1058,7 @@ pa_bluetooth_device* pa_bluetooth_discovery_get_by_path(pa_bluetooth_discovery *
pa_assert(path);
if ((d = pa_hashmap_get(y->devices, path)))
- if (device_is_audio_ready(d))
+ if (d->device_info_valid == 1)
return d;
return NULL;
@@ -1078,7 +1069,10 @@ bool pa_bluetooth_device_any_audio_connected(const pa_bluetooth_device *d) {
pa_assert(d);
- if (d->dead || !device_is_audio_ready(d))
+ if (d->dead || d->device_info_valid != 1)
+ return false;
+
+ if (d->audio_state == PA_BT_AUDIO_STATE_INVALID)
return false;
/* Make sure audio_state is *not* in CONNECTING state before we fire the
commit 8eb3d14b137e47ae68a0d87e4d22295885ec367d
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date: Fri Jan 11 11:07:47 2013 +0100
bluetooth: Do not check profile states is device_audio_is_ready()
The function is used to make sure some basic information has already
been gathered before the device is being used. At this point profile
states can be ignored, since their initial value will be
PA_BT_AUDIO_STATE_INVALID and thus effectively similar to
PA_BT_AUDIO_STATE_DISCONNECTED due to audio_state_to_transport_state().
The change should make no difference given that the behavior of
pa_bluetooth_device_any_audio_connected() doesn't change: by the time
TRUE is returned, a transport needs to exist. This means a profile
will exist in CONNECTING or CONNECTED state and thus the old
implementation of device_audio_is_ready() would also have returned TRUE.
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 066c82c..149a476 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -235,18 +235,12 @@ static void device_free(pa_bluetooth_device *d) {
}
static pa_bool_t device_is_audio_ready(const pa_bluetooth_device *d) {
- unsigned i;
-
pa_assert(d);
if (!d->device_info_valid || d->audio_state == PA_BT_AUDIO_STATE_INVALID)
return false;
- for (i = 0; i < PA_BLUETOOTH_PROFILE_COUNT; i++)
- if (d->profile_state[i] != PA_BT_AUDIO_STATE_INVALID)
- return true;
-
- return false;
+ return true;
}
static const char *check_variant_property(DBusMessageIter *i) {
commit 93e19c884b54cea4889d4e501ea1dce9b5c2b784
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date: Fri Jan 11 11:07:46 2013 +0100
bluetooth: Use stdbool for pa_bool_t
Use lowercase true/false instead of TRUE/FALSE for pa_bool_t.
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index aa69b57..066c82c 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -174,7 +174,7 @@ static pa_bluetooth_device* device_new(pa_bluetooth_discovery *discovery, const
d = pa_xnew0(pa_bluetooth_device, 1);
d->discovery = discovery;
- d->dead = FALSE;
+ d->dead = false;
d->device_info_valid = 0;
@@ -240,13 +240,13 @@ static pa_bool_t device_is_audio_ready(const pa_bluetooth_device *d) {
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) {
@@ -426,7 +426,7 @@ static int parse_device_property(pa_bluetooth_device *d, 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;
@@ -452,22 +452,22 @@ static int parse_device_property(pa_bluetooth_device *d, DBusMessageIter *i) {
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);
@@ -630,7 +630,7 @@ static void remove_all_devices(pa_bluetooth_discovery *y) {
pa_assert(y);
while ((d = pa_hashmap_steal_first(y->devices))) {
- run_callback(d, TRUE);
+ run_callback(d, true);
device_free(d);
}
}
@@ -746,7 +746,7 @@ static void get_properties_reply(DBusPendingCall *pending, void *userdata) {
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);
@@ -938,7 +938,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
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);
}
@@ -996,7 +996,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
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;
@@ -1271,7 +1271,7 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
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;
@@ -1372,7 +1372,7 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
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;
@@ -1410,7 +1410,7 @@ static DBusMessage *endpoint_clear_configuration(DBusConnection *c, DBusMessage
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);
}
@@ -1678,7 +1678,7 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
goto fail;
}
- y->filter_added = TRUE;
+ y->filter_added = true;
if (pa_dbus_add_matches(
conn, &err,
@@ -1822,7 +1822,7 @@ const char*pa_bluetooth_get_form_factor(uint32_t class) {
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);
@@ -1834,13 +1834,13 @@ char *pa_bluetooth_cleanup_name(const char *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;
@@ -1856,10 +1856,10 @@ pa_bool_t pa_bluetooth_uuid_has(pa_bluetooth_uuid *uuids, const char *uuid) {
while (uuids) {
if (strcasecmp(uuids->uuid, uuid) == 0)
- return TRUE;
+ return true;
uuids = uuids->next;
}
- return FALSE;
+ return false;
}
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 6962c7a..c2ac15f 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -63,7 +63,7 @@
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> "
@@ -309,11 +309,11 @@ static void setup_stream(struct userdata *u) {
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) {
@@ -378,7 +378,7 @@ static int bt_transport_acquire(struct userdata *u, pa_bool_t optional) {
/* 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));
@@ -412,7 +412,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
/* 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);
}
@@ -456,7 +456,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
/* 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));
@@ -489,7 +489,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
/* 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);
}
@@ -627,7 +627,7 @@ static int hsp_process_push(struct userdata *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));
@@ -670,7 +670,7 @@ static int hsp_process_push(struct userdata *u) {
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;
}
@@ -680,7 +680,7 @@ static int hsp_process_push(struct userdata *u) {
}
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);
@@ -854,7 +854,7 @@ static int a2dp_process_push(struct userdata *u) {
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;
@@ -898,7 +898,7 @@ static int a2dp_process_push(struct userdata *u) {
}
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);
@@ -980,7 +980,7 @@ static void thread_func(void *userdata) {
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);
@@ -999,7 +999,7 @@ static void thread_func(void *userdata) {
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;
@@ -1036,7 +1036,7 @@ static void thread_func(void *userdata) {
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;
@@ -1098,7 +1098,7 @@ static void thread_func(void *userdata) {
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) {
@@ -1117,7 +1117,7 @@ static void thread_func(void *userdata) {
sleep_for = PA_USEC_PER_MSEC * 500;
pa_rtpoll_set_timer_relative(u->rtpoll, sleep_for);
- disable_timer = FALSE;
+ disable_timer = false;
}
}
}
@@ -1130,7 +1130,7 @@ static void thread_func(void *userdata) {
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;
}
@@ -1160,7 +1160,7 @@ io_fail:
do_write = 0;
pending_read_bytes = 0;
- writable = FALSE;
+ writable = false;
teardown_stream(u);
}
@@ -1196,8 +1196,8 @@ static pa_port_available_t transport_state_to_availability_merged(pa_bluetooth_t
/* 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;
@@ -1289,12 +1289,12 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
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);
}
}
@@ -1307,12 +1307,12 @@ static void handle_transport_state_change(struct userdata *u, struct pa_bluetoot
/* 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);
}
}
}
@@ -1386,15 +1386,15 @@ static char *get_name(const char *type, pa_modargs *ma, const char *device_id, p
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);
@@ -1444,7 +1444,7 @@ static pa_hook_result_t sink_state_changed_cb(pa_core *c, pa_sink *s, struct use
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;
}
@@ -1457,7 +1457,7 @@ static pa_hook_result_t source_state_changed_cb(pa_core *c, pa_source *s, struct
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;
}
@@ -1744,7 +1744,7 @@ static void bt_transport_config_a2dp(struct userdata *u) {
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:
@@ -1989,7 +1989,7 @@ static int start_thread(struct userdata *u) {
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) {
@@ -2335,7 +2335,7 @@ static int add_card(struct userdata *u) {
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);
@@ -2480,7 +2480,7 @@ int pa__init(pa_module* m) {
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;
diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
index f6e3b83..eb59beb 100644
--- a/src/modules/bluetooth/module-bluetooth-discover.c
+++ b/src/modules/bluetooth/module-bluetooth-discover.c
@@ -42,7 +42,7 @@ PA_MODULE_DESCRIPTION("Detect available bluetooth audio devices and load bluetoo
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_USAGE("sco_sink=<name of sink> "
"sco_source=<name of source> ");
-PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_LOAD_ONCE(true);
static const char* const valid_modargs[] = {
"sco_sink",
commit 4e93d8711b78ff72755325ec4e0ce626589f7c27
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date: Fri Jan 11 11:07:45 2013 +0100
bluetooth: Check message signature for SetConfiguration
Make sure inside endpoint_set_configuration() that the received D-Bus
message matches the expected signature.
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index a3f72a4..aa69b57 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1277,17 +1277,19 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
DBusMessage *r;
bool old_any_connected;
- dbus_message_iter_init(m, &args);
+ if (!dbus_message_iter_init(m, &args) || !pa_streq(dbus_message_get_signature(m), "oa{sv}")) {
+ pa_log("Invalid signature for method SetConfiguration");
+ goto fail2;
+ }
dbus_message_iter_get_basic(&args, &path);
if (pa_hashmap_get(y->transports, path)) {
pa_log("org.bluez.MediaEndpoint.SetConfiguration: Transport %s is already configured.", path);
- goto fail;
+ goto fail2;
}
- if (!dbus_message_iter_next(&args))
- goto fail;
+ pa_assert_se(dbus_message_iter_next(&args));
dbus_message_iter_recurse(&args, &props);
if (dbus_message_iter_get_arg_type(&props) != DBUS_TYPE_DICT_ENTRY)
@@ -1351,7 +1353,7 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
if (d->transports[p] != NULL) {
pa_log("Cannot configure transport %s because profile %d is already used", path, p);
- goto fail;
+ goto fail2;
}
old_any_connected = pa_bluetooth_device_any_audio_connected(d);
@@ -1376,6 +1378,8 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
fail:
pa_log("org.bluez.MediaEndpoint.SetConfiguration: invalid arguments");
+
+fail2:
pa_assert_se(r = dbus_message_new_error(m, "org.bluez.MediaEndpoint.Error.InvalidArguments",
"Unable to set configuration"));
return r;
commit e2bee0e27ba25c9dc3a2514aefc4e8af2d384e83
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date: Fri Jan 11 11:07:44 2013 +0100
bluetooth: Fix minor style issues
Trivially fix some style issues affecting line wrap (128 chars max with
the exception of multi-line comments, which are limited to 80),
indentation and unnecessary parentheses.
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 65ed9c0..a3f72a4 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -74,7 +74,8 @@ struct pa_bluetooth_discovery {
};
static void get_properties_reply(DBusPendingCall *pending, void *userdata);
-static pa_dbus_pending* send_and_add_to_pending(pa_bluetooth_discovery *y, DBusMessage *m, DBusPendingCallNotifyFunction func, void *call_data);
+static pa_dbus_pending* send_and_add_to_pending(pa_bluetooth_discovery *y, DBusMessage *m, DBusPendingCallNotifyFunction func,
+ void *call_data);
static void found_adapter(pa_bluetooth_discovery *y, const char *path);
static pa_bluetooth_device *found_device(pa_bluetooth_discovery *y, const char* path);
@@ -423,10 +424,9 @@ static int parse_device_property(pa_bluetooth_device *d, DBusMessageIter *i) {
DBusMessageIter ai;
dbus_message_iter_recurse(&variant_i, &ai);
- if (dbus_message_iter_get_arg_type(&ai) == DBUS_TYPE_STRING &&
- pa_streq(key, "UUIDs")) {
- DBusMessage *m;
- pa_bool_t has_audio = FALSE;
+ if (dbus_message_iter_get_arg_type(&ai) == DBUS_TYPE_STRING && pa_streq(key, "UUIDs")) {
+ DBusMessage *m;
+ pa_bool_t has_audio = FALSE;
while (dbus_message_iter_get_arg_type(&ai) != DBUS_TYPE_INVALID) {
pa_bluetooth_uuid *node;
@@ -449,19 +449,23 @@ static int parse_device_property(pa_bluetooth_device *d, DBusMessageIter *i) {
/* Vudentz said the interfaces are here when the UUIDs are announced */
if (strcasecmp(HSP_AG_UUID, value) == 0 || strcasecmp(HFP_AG_UUID, value) == 0) {
- pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.HandsfreeGateway", "GetProperties"));
+ 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;
} 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"));
+ 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;
} 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"));
+ 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;
} 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"));
+ 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;
}
@@ -469,7 +473,9 @@ static int parse_device_property(pa_bluetooth_device *d, DBusMessageIter *i) {
dbus_message_iter_next(&ai);
}
- /* this might eventually be racy if .Audio is not there yet, but the State change will come anyway later, so this call is for cold-detection mostly */
+ /* this might eventually be racy if .Audio is not there yet, but
+ the State change will come anyway later, so this call is for
+ cold-detection mostly */
if (has_audio) {
pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.Audio", "GetProperties"));
send_and_add_to_pending(d->discovery, m, get_properties_reply, d);
@@ -695,7 +701,8 @@ static void get_properties_reply(DBusPendingCall *pending, void *userdata) {
}
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
- pa_log("%s.GetProperties() failed: %s: %s", dbus_message_get_interface(p->message), dbus_message_get_error_name(r), pa_dbus_get_error_message(r));
+ pa_log("%s.GetProperties() failed: %s: %s", dbus_message_get_interface(p->message), dbus_message_get_error_name(r),
+ pa_dbus_get_error_message(r));
goto finish;
}
@@ -748,7 +755,8 @@ finish2:
pa_dbus_pending_free(p);
}
-static pa_dbus_pending* send_and_add_to_pending(pa_bluetooth_discovery *y, DBusMessage *m, DBusPendingCallNotifyFunction func, void *call_data) {
+static pa_dbus_pending* send_and_add_to_pending(pa_bluetooth_discovery *y, DBusMessage *m, DBusPendingCallNotifyFunction func,
+ void *call_data) {
pa_dbus_pending *p;
DBusPendingCall *call;
@@ -792,7 +800,8 @@ static void register_endpoint_reply(DBusPendingCall *pending, void *userdata) {
}
if (dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR) {
- pa_log("org.bluez.Media.RegisterEndpoint() failed: %s: %s", dbus_message_get_error_name(r), pa_dbus_get_error_message(r));
+ pa_log("org.bluez.Media.RegisterEndpoint() failed: %s: %s", dbus_message_get_error_name(r),
+ pa_dbus_get_error_message(r));
goto finish;
}
@@ -1078,9 +1087,9 @@ bool pa_bluetooth_device_any_audio_connected(const pa_bluetooth_device *d) {
if (d->dead || !device_is_audio_ready(d))
return false;
- /* Make sure audio_state is *not* in CONNECTING state before we fire the hook
- * to report the new device state. This is actually very important in order to
- * make module-card-restore work well with headsets: if the headset
+ /* Make sure audio_state is *not* in CONNECTING state before we fire the
+ * hook to report the new device state. This is actually very important in
+ * order to make module-card-restore work well with headsets: if the headset
* supports both HSP and A2DP, one of those profiles is connected first and
* then the other, and lastly the Audio interface becomes connected.
* Checking only audio_state means that this function will return false at
@@ -1137,7 +1146,8 @@ int pa_bluetooth_transport_acquire(pa_bluetooth_transport *t, bool optional, siz
return -1;
}
- if (!dbus_message_get_args(r, &err, DBUS_TYPE_UNIX_FD, &ret, DBUS_TYPE_UINT16, &i, DBUS_TYPE_UINT16, &o, DBUS_TYPE_INVALID)) {
+ if (!dbus_message_get_args(r, &err, DBUS_TYPE_UNIX_FD, &ret, DBUS_TYPE_UINT16, &i, DBUS_TYPE_UINT16, &o,
+ DBUS_TYPE_INVALID)) {
pa_log("Failed to parse org.bluez.MediaTransport.Acquire(): %s", err.message);
ret = -1;
dbus_error_free(&err);
@@ -1296,24 +1306,29 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
dbus_message_iter_recurse(&entry, &value);
var = dbus_message_iter_get_arg_type(&value);
+
if (strcasecmp(key, "UUID") == 0) {
if (var != DBUS_TYPE_STRING)
goto fail;
+
dbus_message_iter_get_basic(&value, &uuid);
} else if (strcasecmp(key, "Device") == 0) {
if (var != DBUS_TYPE_OBJECT_PATH)
goto fail;
+
dbus_message_iter_get_basic(&value, &dev_path);
} else if (strcasecmp(key, "NREC") == 0) {
dbus_bool_t tmp_boolean;
if (var != DBUS_TYPE_BOOLEAN)
goto fail;
+
dbus_message_iter_get_basic(&value, &tmp_boolean);
nrec = tmp_boolean;
} else if (strcasecmp(key, "Configuration") == 0) {
DBusMessageIter array;
if (var != DBUS_TYPE_ARRAY)
goto fail;
+
dbus_message_iter_recurse(&value, &array);
dbus_message_iter_get_fixed_array(&array, &config, &size);
}
@@ -1361,8 +1376,8 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
fail:
pa_log("org.bluez.MediaEndpoint.SetConfiguration: invalid arguments");
- pa_assert_se(r = (dbus_message_new_error(m, "org.bluez.MediaEndpoint.Error.InvalidArguments",
- "Unable to set configuration")));
+ pa_assert_se(r = dbus_message_new_error(m, "org.bluez.MediaEndpoint.Error.InvalidArguments",
+ "Unable to set configuration"));
return r;
}
@@ -1401,8 +1416,8 @@ static DBusMessage *endpoint_clear_configuration(DBusConnection *c, DBusMessage
return r;
fail:
- pa_assert_se(r = (dbus_message_new_error(m, "org.bluez.MediaEndpoint.Error.InvalidArguments",
- "Unable to clear configuration")));
+ pa_assert_se(r = dbus_message_new_error(m, "org.bluez.MediaEndpoint.Error.InvalidArguments",
+ "Unable to clear configuration"));
return r;
}
@@ -1569,8 +1584,8 @@ done:
return r;
fail:
- pa_assert_se(r = (dbus_message_new_error(m, "org.bluez.MediaEndpoint.Error.InvalidArguments",
- "Unable to select configuration")));
+ pa_assert_se(r = dbus_message_new_error(m, "org.bluez.MediaEndpoint.Error.InvalidArguments",
+ "Unable to select configuration"));
return r;
}
@@ -1590,7 +1605,8 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
path = dbus_message_get_path(m);
dbus_error_init(&e);
- if (!pa_streq(path, A2DP_SOURCE_ENDPOINT) && !pa_streq(path, A2DP_SINK_ENDPOINT) && !pa_streq(path, HFP_AG_ENDPOINT) && !pa_streq(path, HFP_HS_ENDPOINT))
+ if (!pa_streq(path, A2DP_SOURCE_ENDPOINT) && !pa_streq(path, A2DP_SINK_ENDPOINT) && !pa_streq(path, HFP_AG_ENDPOINT) &&
+ !pa_streq(path, HFP_HS_ENDPOINT))
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
@@ -1622,6 +1638,7 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
DBusError err;
pa_bluetooth_discovery *y;
+ DBusConnection *conn;
unsigned i;
static const DBusObjectPathVTable vtable_endpoint = {
.message_function = endpoint_handler,
@@ -1649,16 +1666,20 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
if (setup_dbus(y) < 0)
goto fail;
+ conn = pa_dbus_connection_get(y->connection);
+
/* dynamic detection of bluetooth audio devices */
- if (!dbus_connection_add_filter(pa_dbus_connection_get(y->connection), filter_cb, y, NULL)) {
+ if (!dbus_connection_add_filter(conn, filter_cb, y, NULL)) {
pa_log_error("Failed to add filter function");
goto fail;
}
+
y->filter_added = TRUE;
if (pa_dbus_add_matches(
- pa_dbus_connection_get(y->connection), &err,
- "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.bluez'",
+ conn, &err,
+ "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged'"
+ ",arg0='org.bluez'",
"type='signal',sender='org.bluez',interface='org.bluez.Manager',member='AdapterAdded'",
"type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceRemoved'",
"type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceCreated'",
@@ -1674,17 +1695,16 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c) {
goto fail;
}
- pa_assert_se(dbus_connection_register_object_path(pa_dbus_connection_get(y->connection), HFP_AG_ENDPOINT, &vtable_endpoint, y));
- pa_assert_se(dbus_connection_register_object_path(pa_dbus_connection_get(y->connection), HFP_HS_ENDPOINT, &vtable_endpoint, y));
- pa_assert_se(dbus_connection_register_object_path(pa_dbus_connection_get(y->connection), A2DP_SOURCE_ENDPOINT, &vtable_endpoint, y));
- pa_assert_se(dbus_connection_register_object_path(pa_dbus_connection_get(y->connection), A2DP_SINK_ENDPOINT, &vtable_endpoint, y));
+ pa_assert_se(dbus_connection_register_object_path(conn, HFP_AG_ENDPOINT, &vtable_endpoint, y));
+ pa_assert_se(dbus_connection_register_object_path(conn, HFP_HS_ENDPOINT, &vtable_endpoint, y));
+ pa_assert_se(dbus_connection_register_object_path(conn, A2DP_SOURCE_ENDPOINT, &vtable_endpoint, y));
+ pa_assert_se(dbus_connection_register_object_path(conn, A2DP_SINK_ENDPOINT, &vtable_endpoint, y));
list_adapters(y);
return y;
fail:
-
if (y)
pa_bluetooth_discovery_unref(y);
@@ -1728,20 +1748,22 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), HFP_HS_ENDPOINT);
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), A2DP_SOURCE_ENDPOINT);
dbus_connection_unregister_object_path(pa_dbus_connection_get(y->connection), A2DP_SINK_ENDPOINT);
- pa_dbus_remove_matches(pa_dbus_connection_get(y->connection),
- "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.bluez'",
- "type='signal',sender='org.bluez',interface='org.bluez.Manager',member='AdapterAdded'",
- "type='signal',sender='org.bluez',interface='org.bluez.Manager',member='AdapterRemoved'",
- "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceRemoved'",
- "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceCreated'",
- "type='signal',sender='org.bluez',interface='org.bluez.Device',member='PropertyChanged'",
- "type='signal',sender='org.bluez',interface='org.bluez.Audio',member='PropertyChanged'",
- "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
- "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",
- "type='signal',sender='org.bluez',interface='org.bluez.AudioSource',member='PropertyChanged'",
- "type='signal',sender='org.bluez',interface='org.bluez.HandsfreeGateway',member='PropertyChanged'",
- "type='signal',sender='org.bluez',interface='org.bluez.MediaTransport',member='PropertyChanged'",
- NULL);
+ pa_dbus_remove_matches(
+ pa_dbus_connection_get(y->connection),
+ "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged'"
+ ",arg0='org.bluez'",
+ "type='signal',sender='org.bluez',interface='org.bluez.Manager',member='AdapterAdded'",
+ "type='signal',sender='org.bluez',interface='org.bluez.Manager',member='AdapterRemoved'",
+ "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceRemoved'",
+ "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceCreated'",
+ "type='signal',sender='org.bluez',interface='org.bluez.Device',member='PropertyChanged'",
+ "type='signal',sender='org.bluez',interface='org.bluez.Audio',member='PropertyChanged'",
+ "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
+ "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",
+ "type='signal',sender='org.bluez',interface='org.bluez.AudioSource',member='PropertyChanged'",
+ "type='signal',sender='org.bluez',interface='org.bluez.HandsfreeGateway',member='PropertyChanged'",
+ "type='signal',sender='org.bluez',interface='org.bluez.MediaTransport',member='PropertyChanged'",
+ NULL);
if (y->filter_added)
dbus_connection_remove_filter(pa_dbus_connection_get(y->connection), filter_cb, y);
commit 1c8fe4ad2f9039e5c908d3635e0e9ac34e493927
Author: Mikel Astiz <mikel.astiz at bmw-carit.de>
Date: Fri Jan 11 11:07:43 2013 +0100
bluetooth: Fix incorrect error messages
err.message doesn't contain anything useful in these error cases so
fix the mistake and avoid misleading messages.
diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index f216d9b..65ed9c0 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -975,7 +975,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
bool old_any_connected = pa_bluetooth_device_any_audio_connected(d);
if (!dbus_message_iter_init(m, &arg_i)) {
- pa_log("Failed to parse PropertyChanged: %s", err.message);
+ pa_log("Failed to parse PropertyChanged for device %s", d->path);
goto fail;
}
@@ -1025,7 +1025,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
goto fail;
if (!dbus_message_iter_init(m, &arg_i)) {
- pa_log("Failed to parse PropertyChanged: %s", err.message);
+ pa_log("Failed to parse PropertyChanged for transport %s", t->path);
goto fail;
}
More information about the pulseaudio-commits
mailing list