Open Source Telephony
 help / color / mirror / Atom feed
From: Vinicius Costa Gomes <vcgomes@gmail.com>
To: ofono@ofono.org
Subject: [PATCH 2/6] handsfree-audio: Add setting SCO air mode
Date: Thu, 15 Aug 2013 23:26:05 -0300	[thread overview]
Message-ID: <1376619969-15080-3-git-send-email-vcgomes@gmail.com> (raw)
In-Reply-To: <1376619969-15080-1-git-send-email-vcgomes@gmail.com>

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

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

diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 0bdeb99..0caa458 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -68,6 +68,16 @@ 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 void send_new_connection(const char *card, int fd, uint8_t codec)
 {
 	DBusMessage *msg;
@@ -107,6 +117,7 @@ static gboolean sco_accept(GIOChannel *io, GIOCondition cond,
 {
 	struct ofono_handsfree_card *card;
 	struct sockaddr_sco saddr;
+	struct bt_voice voice;
 	socklen_t alen;
 	int sk, nsk;
 	char local[18], remote[18];
@@ -150,6 +161,13 @@ static gboolean sco_accept(GIOChannel *io, GIOCondition cond,
 		return TRUE;
 	}
 
+	memset(&voice, 0, sizeof(voice));
+	voice.setting = codec2setting(card->selected_codec);
+
+	if (setsockopt(nsk, SOL_BLUETOOTH, BT_VOICE, &voice, sizeof(voice)) < 0)
+		ofono_error("Can't set voice settings: %s (%d)",
+						strerror(errno), errno);
+
 	send_new_connection(card->path, nsk, card->selected_codec);
 	close(nsk);
 
-- 
1.8.3.4


  parent reply	other threads:[~2013-08-16  2:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-16  2:26 [PATCH 0/6] hfp_hf_bluez5: Add support for Transparent SCO Vinicius Costa Gomes
2013-08-16  2:26 ` [PATCH 1/6] bluetooth: Add define for SCO voice settings Vinicius Costa Gomes
2013-08-19 17:59   ` Denis Kenzior
2013-08-16  2:26 ` Vinicius Costa Gomes [this message]
2013-08-19 17:49   ` [PATCH 2/6] handsfree-audio: Add setting SCO air mode Denis Kenzior
2013-08-19 18:42     ` Vinicius Costa Gomes
2013-08-16  2:26 ` [PATCH 3/6] handsfree-audio: Add support for detecting Transparent SCO support Vinicius Costa Gomes
2013-08-19 17:55   ` Denis Kenzior
2013-08-19 19:36     ` Vinicius Costa Gomes
2013-08-16  2:26 ` [PATCH 4/6] handsfree-audio: Set the voice setting for outgoing connections Vinicius Costa Gomes
2013-08-19 17:56   ` Denis Kenzior
2013-08-16  2:26 ` [PATCH 5/6] hfp_hf_bluez5: Handle org.bluez.Profile1.Cancel() Vinicius Costa Gomes
2013-08-16  2:26 ` [PATCH 6/6] hfp_hf_bluez5: Handle org.bluez.Profile1.Release() Vinicius Costa Gomes
2013-08-19 17:57   ` Denis Kenzior
2013-08-19 18:47     ` Vinicius Costa Gomes
2013-08-20 13:51       ` Luiz Augusto von Dentz
2013-08-20 15:41         ` Denis Kenzior
2013-08-21 10:29           ` Luiz Augusto von Dentz
2013-08-21 15:21             ` Denis Kenzior
2013-08-22 14:41               ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1376619969-15080-3-git-send-email-vcgomes@gmail.com \
    --to=vcgomes@gmail.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox