Skip to contentSkip to conversation

Fix error message when getting SCO connection handle

PATCH In review Luiz Augusto von Dentz 2 participants 3 messages Mar 24, 2011 – Mar 25, 2011 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 Fix error message when getting SCO connection handle

From: Luiz Augusto von Dentz <[email protected]>

Error message should indicate the transport correctly which is SCO not RFCOMM.

---
 btio/btio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
btio/btio.c +2 -2
index d8439e0..3f5b69a 100644
@@ -1020,14 +1020,14 @@ static gboolean sco_get(int sock, GError **err, BtIOOption opt1, va_list args)
 			break;
 		case BT_IO_OPT_HANDLE:
 			if (sco_get_info(sock, &handle, dev_class) < 0) {
-				ERROR_FAILED(err, "RFCOMM_CONNINFO", errno);
+				ERROR_FAILED(err, "SCO_CONNINFO", errno);
 				return FALSE;
 			}
 			*(va_arg(args, uint16_t *)) = handle;
 			break;
 		case BT_IO_OPT_CLASS:
 			if (sco_get_info(sock, &handle, dev_class) < 0) {
-				ERROR_FAILED(err, "RFCOMM_CONNINFO", errno);
+				ERROR_FAILED(err, "SCO_CONNINFO", errno);
 				return FALSE;
 			}
 			memcpy(va_arg(args, uint8_t *), dev_class, 3);
Signature · 1 line
1.7.1
author maintainer
#1 lore raw

PATCH 1/1 Wait SCO socket to HUP before changing state

From: Luiz Augusto von Dentz <[email protected]>

In situations where application wants to switch profiles e.g hfp to a2dp it normally needs to wait SCO to be disconnected to resume a2dp due to resource limitations on headset.

There seems to be an issue in the kernel side which prevent this to work properly, apparently shutdown does not wait the link to be disconnected, but it is under investigation.

---
 audio/headset.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
audio/headset.c +6 -2
index bdaa8da..dff10d1 100644
@@ -1345,6 +1345,7 @@ static gboolean sco_cb(GIOChannel *chan, GIOCondition cond,
 
 	error("Audio connection got disconnected");
 
+	pending_connect_finalize(device);
 	headset_set_state(device, HEADSET_STATE_CONNECTED);
 
 	return FALSE;
@@ -2385,6 +2386,7 @@ unsigned int headset_suspend_stream(struct audio_device *dev,
 {
 	struct headset *hs = dev->headset;
 	unsigned int id;
+	int sock;
 
 	if (hs->state == HEADSET_STATE_DISCONNECTED ||
 				hs->state == HEADSET_STATE_CONNECTING)
@@ -2395,10 +2397,12 @@ unsigned int headset_suspend_stream(struct audio_device *dev,
 		hs->dc_timer = 0;
 	}
 
-	headset_set_state(dev, HEADSET_STATE_CONNECTED);
+	sock = g_io_channel_unix_get_fd(hs->sco);
+
+	/* shutdown but leave the socket open and wait for hup */
+	shutdown(sock, SHUT_RDWR);
 
 	id = connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb, user_data);
-	g_idle_add((GSourceFunc) dummy_connect_complete, dev);
 
 	return id;
 }
Signature · 1 line
1.7.1
#2 lore raw
In reply to Luiz Augusto von Dentz

Hi Luiz,

Quoted 7 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

Error message should indicate the transport correctly which is SCO not RFCOMM.

---
 btio/btio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Both of your patches have been pushed upstream. Thanks.

Johan