All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] handsfree-audio: Add setting SCO air mode
@ 2013-09-11  0:09 Vinicius Costa Gomes
  2013-09-11  0:09 ` [PATCH 2/7] handsfree-audio: Add support for detecting Transparent SCO support Vinicius Costa Gomes
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Vinicius Costa Gomes @ 2013-09-11  0:09 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1548 bytes --]

---

I did a few quick tests here, but it would be much appreciated if
someone with access to more devices could test it.

Sorry for the delay.

Cheers,

 src/handsfree-audio.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 0bdeb99..c311b04 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -68,6 +68,33 @@ static GSList *drivers = 0;
 static ofono_bool_t has_wideband = FALSE;
 static int defer_setup = 1;

+static uint16_t codec2setting(uint8_t codec)
+{
+	switch (codec) {
+		case HFP_CODEC_CVSD:
+			return BT_VOICE_CVSD_16BIT;
+		default:
+			return BT_VOICE_TRANSPARENT;
+	}
+}
+
+static ofono_bool_t apply_settings_from_codec(int fd, uint8_t codec)
+{
+	struct bt_voice voice;
+
+	/* CVSD is the default, no need to set BT_VOICE. */
+	if (codec == HFP_CODEC_CVSD)
+		return TRUE;
+
+	memset(&voice, 0, sizeof(voice));
+	voice.setting = codec2setting(codec);
+
+	if (setsockopt(fd, SOL_BLUETOOTH, BT_VOICE, &voice, sizeof(voice)) < 0)
+		return FALSE;
+
+	return TRUE;
+}
+
 static void send_new_connection(const char *card, int fd, uint8_t codec)
 {
 	DBusMessage *msg;
@@ -150,6 +177,11 @@ static gboolean sco_accept(GIOChannel *io, GIOCondition cond,
 		return TRUE;
 	}

+	if (apply_settings_from_codec(nsk, card->selected_codec) == FALSE) {
+		close(nsk);
+		return TRUE;
+	}
+
 	send_new_connection(card->path, nsk, card->selected_codec);
 	close(nsk);

--
1.8.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-09-12 20:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11  0:09 [PATCH 1/7] handsfree-audio: Add setting SCO air mode Vinicius Costa Gomes
2013-09-11  0:09 ` [PATCH 2/7] handsfree-audio: Add support for detecting Transparent SCO support Vinicius Costa Gomes
2013-09-12 18:20   ` Denis Kenzior
2013-09-11  0:09 ` [PATCH 3/7] handsfree-audio: Set the voice setting for outgoing connections Vinicius Costa Gomes
2013-09-11  0:09 ` [PATCH 4/7] handsfree-audio: Do not allow cards to be registered if no defer_setup Vinicius Costa Gomes
2013-09-11  0:09 ` [PATCH 5/7] handsfree-audio: Fix keeping the socket open without defer_setup Vinicius Costa Gomes
2013-09-11  0:09 ` [PATCH 6/7] hfp_hf_bluez5: Handle org.bluez.Profile1.Cancel() Vinicius Costa Gomes
2013-09-12 18:21   ` Denis Kenzior
2013-09-11  0:09 ` [PATCH 7/7] hfp_hf_bluez5: Handle org.bluez.Profile1.Release() Vinicius Costa Gomes
2013-09-12 18:21   ` Denis Kenzior
2013-09-12 18:19 ` [PATCH 1/7] handsfree-audio: Add setting SCO air mode Denis Kenzior
2013-09-12 20:09   ` =?unknown-8bit?q?Vin=C3=ADcius?= Costa Gomes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.