Skip to contentSkip to conversation

Fix not calling SetConfiguration on hfp/hsp endpoints before connected

PATCH In review Luiz Augusto von Dentz 2 participants 4 messages Dec 16, 2010 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 Fix not calling SetConfiguration on hfp/hsp endpoints before connected

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

This cause some clients like PulseAudio to fail to find a proper transport since connected state is send before transport configuration is set.

To fix this now SetConfiguration is called early on when headset is still in connecting phase, this matches sink/source where SetConfiguration is also called before connected.

---
 audio/media.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
audio/media.c +4 -7
index 0e6ccc9..b28bb33 100644
@@ -151,16 +151,13 @@ static void headset_state_changed(struct audio_device *dev,
 
 	switch (new_state) {
 	case HEADSET_STATE_DISCONNECTED:
-		if (old_state != HEADSET_STATE_CONNECTING)
-			media_endpoint_clear_configuration(endpoint);
+		media_endpoint_clear_configuration(endpoint);
+		break;
 	case HEADSET_STATE_CONNECTING:
+		media_endpoint_set_configuration(endpoint, dev, NULL, 0,
+						headset_setconf_cb, dev);
 		break;
 	case HEADSET_STATE_CONNECTED:
-		if (old_state != HEADSET_STATE_PLAY_IN_PROGRESS &&
-				old_state != HEADSET_STATE_PLAYING)
-			media_endpoint_set_configuration(endpoint, dev, NULL,
-							0, headset_setconf_cb,
-									dev);
 		break;
 	case HEADSET_STATE_PLAY_IN_PROGRESS:
 		break;
Signature · 1 line
1.7.1
author maintainer
#1 lore raw

PATCH 1/1 Fix sending duplicate speaker/microphone gains to the headset

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

Current code only prevent duplicate D-Bus signals, so in case headset changes the volume a client may set the same volume level again which would be send as new volume level.

To fix this headset_set_gain now return -EALREADY if nothing has changed so code using it can just ignore the change instead of sending to remote device.

---
 audio/headset.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
audio/headset.c +8 -4
index 97ae4fd..52d0ce8 100644
@@ -958,7 +958,7 @@ static int headset_set_gain(struct audio_device *device, uint16_t gain, char typ
 	case HEADSET_GAIN_SPEAKER:
 		if (slc->sp_gain == gain) {
 			DBG("Ignoring no-change in speaker gain");
-			return 0;
+			return -EALREADY;
 		}
 		name = "SpeakerGainChanged";
 		property = "SpeakerGain";
@@ -967,7 +967,7 @@ static int headset_set_gain(struct audio_device *device, uint16_t gain, char typ
 	case HEADSET_GAIN_MICROPHONE:
 		if (slc->mic_gain == gain) {
 			DBG("Ignoring no-change in microphone gain");
-			return 0;
+			return -EALREADY;
 		}
 		name = "MicrophoneGainChanged";
 		property = "MicrophoneGain";
@@ -1004,7 +1004,7 @@ static int signal_gain_setting(struct audio_device *device, const char *buf)
 	gain = (dbus_uint16_t) strtol(&buf[7], NULL, 10);
 
 	err = headset_set_gain(device, gain, buf[5]);
-	if (err < 0)
+	if (err < 0 && err != -EALREADY)
 		return err;
 
 	return headset_send(hs, "\r\nOK\r\n");
@@ -1887,10 +1887,14 @@ static DBusMessage *hs_set_gain(DBusConnection *conn,
 		return btd_error_not_connected(msg);
 
 	err = headset_set_gain(device, gain, type);
-	if (err < 0)
+	if (err < 0) {
+		/* Ignore if nothing has changed */
+		if (err == -EALREADY)
+			return dbus_message_new_method_return(msg);
 		return g_dbus_create_error(msg, ERROR_INTERFACE
 						".InvalidArgument",
 						"Must be less than or equal to 15");
+	}
 
 	reply = dbus_message_new_method_return(msg);
 	if (!reply)
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH] Fix sending duplicate speaker/microphone gains to the headset

Hi Luiz,

Quoted 6 lines · Luiz Augusto von Dentz

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

Current code only prevent duplicate D-Bus signals, so in case headset changes the volume a client may set the same volume level again which would be send as new volume level.

Quoted 6 lines

To fix this headset_set_gain now return -EALREADY if nothing has changed so code using it can just ignore the change instead of sending to remote device.

---
 audio/headset.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

This one has also been pushed upstream. Thanks.

Johan

#3 lore raw
In reply to Luiz Augusto von Dentz

Hi Luiz,

Quoted 6 lines · Luiz Augusto von Dentz

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

This cause some clients like PulseAudio to fail to find a proper transport since connected state is send before transport configuration is set.

Quoted 6 lines

To fix this now SetConfiguration is called early on when headset is still in connecting phase, this matches sink/source where SetConfiguration is also called before connected.

---
 audio/media.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

Pushed upstream. Thanks.

Johan