[pulseaudio-discuss] [PATCH v0 10/16] bluetooth: Check return value of init_profile()
Mikel Astiz
mikel.astiz.oss at gmail.com
Fri Sep 28 08:45:34 PDT 2012
From: Mikel Astiz <mikel.astiz at bmw-carit.de>
If profile could not be successfully initialized, the card should be
set to PROFILE_OFF automatically. If sinks or sources exist, they need
to be destroyed, therefore stop_thread() is called.
---
src/modules/bluetooth/module-bluetooth-device.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index dd255e9..b6bdd52 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -2265,7 +2265,8 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
save_sco_volume_callbacks(u);
if (u->profile != PROFILE_OFF)
- init_profile(u);
+ if (init_profile(u) < 0)
+ goto off;
if (u->sink || u->source)
start_thread(u);
@@ -2273,6 +2274,15 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
move_all_end(u, inputs, outputs);
return 0;
+
+off:
+ stop_thread(u);
+ move_all_end(u, inputs, outputs);
+
+ if (pa_card_set_profile(u->card, "off", FALSE) < 0)
+ pa_log_debug("Failed to switch profile to off");
+
+ return -PA_ERR_IO;
}
static void create_ports_for_profile(struct userdata *u, const pa_bluetooth_device *device, pa_card_new_data *card_new_data, pa_card_profile *profile) {
--
1.7.11.4
More information about the pulseaudio-discuss
mailing list