* [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
* [PATCH 2/7] handsfree-audio: Add support for detecting Transparent SCO support
2013-09-11 0:09 [PATCH 1/7] handsfree-audio: Add setting SCO air mode Vinicius Costa Gomes
@ 2013-09-11 0:09 ` 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
` (5 subsequent siblings)
6 siblings, 1 reply; 12+ messages in thread
From: Vinicius Costa Gomes @ 2013-09-11 0:09 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3168 bytes --]
---
include/handsfree-audio.h | 2 +-
plugins/hfp_hf_bluez5.c | 2 +-
src/handsfree-audio.c | 18 ++++++++++++++----
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/include/handsfree-audio.h b/include/handsfree-audio.h
index 846a032..03e3b38 100644
--- a/include/handsfree-audio.h
+++ b/include/handsfree-audio.h
@@ -53,7 +53,7 @@ ofono_bool_t ofono_handsfree_card_set_codec(struct ofono_handsfree_card *card,
ofono_bool_t ofono_handsfree_audio_has_wideband(void);
-ofono_bool_t ofono_handsfree_audio_has_defer_setup(void);
+ofono_bool_t ofono_handsfree_audio_has_transparent_sco(void);
void ofono_handsfree_card_set_data(struct ofono_handsfree_card *card,
void *data);
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 40d8ce0..f08bf53 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -645,7 +645,7 @@ static void connect_handler(DBusConnection *conn, void *user_data)
* Assuming that if defer_setup is supported, then SCO transparent
* mode is also supported
*/
- if (ofono_handsfree_audio_has_defer_setup())
+ if (ofono_handsfree_audio_has_transparent_sco())
features |= HFP_SDP_HF_FEATURE_WIDEBAND_SPEECH;
DBG("Registering External Profile handler ...");
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index c311b04..52d111a 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -67,6 +67,7 @@ static guint sco_watch = 0;
static GSList *drivers = 0;
static ofono_bool_t has_wideband = FALSE;
static int defer_setup = 1;
+static ofono_bool_t transparent_sco = FALSE;
static uint16_t codec2setting(uint8_t codec)
{
@@ -192,7 +193,9 @@ static int sco_init(void)
{
GIOChannel *sco_io;
struct sockaddr_sco saddr;
+ struct bt_voice voice;
int sk;
+ socklen_t len;
sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET | O_NONBLOCK | SOCK_CLOEXEC,
BTPROTO_SCO);
@@ -216,6 +219,13 @@ static int sco_init(void)
strerror(errno), errno);
}
+ memset(&voice, 0, sizeof(voice));
+ len = sizeof(voice);
+
+ if (defer_setup && getsockopt(sk, SOL_BLUETOOTH, BT_VOICE,
+ &voice, &len) == 0)
+ transparent_sco = TRUE;
+
if (listen(sk, 5) < 0) {
close(sk);
return -errno;
@@ -599,9 +609,9 @@ ofono_bool_t ofono_handsfree_audio_has_wideband(void)
return has_wideband;
}
-ofono_bool_t ofono_handsfree_audio_has_defer_setup(void)
+ofono_bool_t ofono_handsfree_audio_has_transparent_sco(void)
{
- return defer_setup == 1;
+ return transparent_sco;
}
static void agent_free(struct agent *agent)
@@ -721,12 +731,12 @@ static DBusMessage *am_agent_register(DBusConnection *conn,
DBG("Agent %s registered with the CODECs:%s%s", sender,
has_cvsd ? " CVSD" : "", has_msbc ? " mSBC" : "");
- if (has_msbc && defer_setup == 1)
+ if (has_msbc && transparent_sco)
has_wideband = TRUE;
else {
has_wideband = FALSE;
DBG("Wideband speech disabled: %s", has_msbc ?
- "no SCO defer setup support" : "no mSBC support");
+ "no Transparent SCO support" : "no mSBC support");
}
if (has_cvsd == FALSE) {
--
1.8.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/7] handsfree-audio: Set the voice setting for outgoing connections
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-11 0:09 ` 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
` (4 subsequent siblings)
6 siblings, 0 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: 786 bytes --]
In the AG case, the voice setting needs to be set before we can
use Transparent SCO mode, which is necessary for Wideband speech
support.
---
src/handsfree-audio.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 52d111a..5cfc939 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -478,6 +478,11 @@ int ofono_handsfree_card_connect_sco(struct ofono_handsfree_card *card)
addr.sco_family = AF_BLUETOOTH;
bt_str2ba(card->remote, &addr.sco_bdaddr);
+ if (apply_settings_from_codec(sk, card->selected_codec) == FALSE) {
+ close(sk);
+ return -1;
+ }
+
ret = connect(sk, (struct sockaddr *) &addr, sizeof(addr));
if (ret < 0 && errno != EINPROGRESS) {
close(sk);
--
1.8.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/7] handsfree-audio: Do not allow cards to be registered if no defer_setup
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-11 0:09 ` [PATCH 3/7] handsfree-audio: Set the voice setting for outgoing connections Vinicius Costa Gomes
@ 2013-09-11 0:09 ` Vinicius Costa Gomes
2013-09-11 0:09 ` [PATCH 5/7] handsfree-audio: Fix keeping the socket open without defer_setup Vinicius Costa Gomes
` (3 subsequent siblings)
6 siblings, 0 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: 613 bytes --]
If the kernel doesn't support defer_setup for SCO, we shouldn't allow
cards to be registered, because in that case we won't be able to
properly send the file descriptor to the Agent.
---
src/handsfree-audio.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 5cfc939..4d2c21f 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -816,6 +816,9 @@ int ofono_handsfree_card_driver_register(
{
DBG("driver: %p", d);
+ if (defer_setup == 0)
+ return -ENOSYS;
+
if (d->probe == NULL)
return -EINVAL;
--
1.8.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/7] handsfree-audio: Fix keeping the socket open without defer_setup
2013-09-11 0:09 [PATCH 1/7] handsfree-audio: Add setting SCO air mode Vinicius Costa Gomes
` (2 preceding siblings ...)
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 ` Vinicius Costa Gomes
2013-09-11 0:09 ` [PATCH 6/7] hfp_hf_bluez5: Handle org.bluez.Profile1.Cancel() Vinicius Costa Gomes
` (2 subsequent siblings)
6 siblings, 0 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: 753 bytes --]
As we won't allow any card to be registered when the kernel doesn't
support defer_setup, we don't need to have the listening SCO socket
open in this case.
---
src/handsfree-audio.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 4d2c21f..a1d9714 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -214,9 +214,12 @@ static int sco_init(void)
if (setsockopt(sk, SOL_BLUETOOTH, BT_DEFER_SETUP,
&defer_setup, sizeof(defer_setup)) < 0) {
+ int err = -errno;
defer_setup = 0;
ofono_warn("Can't enable deferred setup: %s (%d)",
strerror(errno), errno);
+ close(sk);
+ return err;
}
memset(&voice, 0, sizeof(voice));
--
1.8.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/7] hfp_hf_bluez5: Handle org.bluez.Profile1.Cancel()
2013-09-11 0:09 [PATCH 1/7] handsfree-audio: Add setting SCO air mode Vinicius Costa Gomes
` (3 preceding siblings ...)
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 ` 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:19 ` [PATCH 1/7] handsfree-audio: Add setting SCO air mode Denis Kenzior
6 siblings, 1 reply; 12+ messages in thread
From: Vinicius Costa Gomes @ 2013-09-11 0:09 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 769 bytes --]
Cancel() will be called when the ConnectProfile() is called, perhaps
even replied with a success, and the user cancels the connection
attempt.
---
plugins/hfp_hf_bluez5.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index f08bf53..7e98a45 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -574,9 +574,7 @@ static DBusMessage *profile_cancel(DBusConnection *conn,
{
DBG("Profile handler Cancel");
- return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
- ".NotImplemented",
- "Implementation not provided");
+ return dbus_message_new_method_return(msg);
}
static DBusMessage *profile_disconnection(DBusConnection *conn,
--
1.8.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 7/7] hfp_hf_bluez5: Handle org.bluez.Profile1.Release()
2013-09-11 0:09 [PATCH 1/7] handsfree-audio: Add setting SCO air mode Vinicius Costa Gomes
` (4 preceding siblings ...)
2013-09-11 0:09 ` [PATCH 6/7] hfp_hf_bluez5: Handle org.bluez.Profile1.Cancel() Vinicius Costa Gomes
@ 2013-09-11 0:09 ` 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
6 siblings, 1 reply; 12+ messages in thread
From: Vinicius Costa Gomes @ 2013-09-11 0:09 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 695 bytes --]
There's nothing we can do in this case, so we only reply with a
success.
---
plugins/hfp_hf_bluez5.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 7e98a45..391a74e 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -564,9 +564,7 @@ static DBusMessage *profile_release(DBusConnection *conn,
{
DBG("Profile handler Release");
- return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
- ".NotImplemented",
- "Implementation not provided");
+ return dbus_message_new_method_return(msg);
}
static DBusMessage *profile_cancel(DBusConnection *conn,
--
1.8.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 1/7] handsfree-audio: Add setting SCO air mode
2013-09-11 0:09 [PATCH 1/7] handsfree-audio: Add setting SCO air mode Vinicius Costa Gomes
` (5 preceding siblings ...)
2013-09-11 0:09 ` [PATCH 7/7] hfp_hf_bluez5: Handle org.bluez.Profile1.Release() Vinicius Costa Gomes
@ 2013-09-12 18:19 ` Denis Kenzior
2013-09-12 20:09 ` =?unknown-8bit?q?Vin=C3=ADcius?= Costa Gomes
6 siblings, 1 reply; 12+ messages in thread
From: Denis Kenzior @ 2013-09-12 18:19 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 547 bytes --]
Hi Vinicius,
On 09/10/2013 07:09 PM, Vinicius Costa Gomes wrote:
> ---
>
> 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(+)
Patch has been applied, but I tweaked the logic a bit in follow on
commit e574d44d00780f2c7010677a6c261ffba82ea83f. Can you double check
and see if you are okay with it?
Regards,
-Denis
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/7] handsfree-audio: Add support for detecting Transparent SCO support
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
0 siblings, 0 replies; 12+ messages in thread
From: Denis Kenzior @ 2013-09-12 18:20 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 362 bytes --]
Hi Vinicius,
On 09/10/2013 07:09 PM, Vinicius Costa Gomes wrote:
> ---
> include/handsfree-audio.h | 2 +-
> plugins/hfp_hf_bluez5.c | 2 +-
> src/handsfree-audio.c | 18 ++++++++++++++----
> 3 files changed, 16 insertions(+), 6 deletions(-)
>
Patches 2-5 have been applied with a tweak of the commit description.
Regards,
-Denis
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 6/7] hfp_hf_bluez5: Handle org.bluez.Profile1.Cancel()
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
0 siblings, 0 replies; 12+ messages in thread
From: Denis Kenzior @ 2013-09-12 18:21 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 493 bytes --]
Hi Vinicius,
On 09/10/2013 07:09 PM, Vinicius Costa Gomes wrote:
> Cancel() will be called when the ConnectProfile() is called, perhaps
> even replied with a success, and the user cancels the connection
> attempt.
> ---
> plugins/hfp_hf_bluez5.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
Since BlueZ removed the Cancel method from the profile implementation,
I've removed it as well in commit 62c2b81db78eb32de0be9c3a809ddbf27b6e1c32.
Regards,
-Denis
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 7/7] hfp_hf_bluez5: Handle org.bluez.Profile1.Release()
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
0 siblings, 0 replies; 12+ messages in thread
From: Denis Kenzior @ 2013-09-12 18:21 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 399 bytes --]
Hi Vinicius,
On 09/10/2013 07:09 PM, Vinicius Costa Gomes wrote:
> There's nothing we can do in this case, so we only reply with a
> success.
> ---
> plugins/hfp_hf_bluez5.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
Since BlueZ now marks this method as noreply, I fixed it to be the same
in commit f2103a7ada1a4f5bfb7fee8e5d0ff261718ca759.
Regards,
-Denis
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/7] handsfree-audio: Add setting SCO air mode
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
0 siblings, 0 replies; 12+ messages in thread
From: =?unknown-8bit?q?Vin=C3=ADcius?= Costa Gomes @ 2013-09-12 20:09 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 724 bytes --]
Hi Denis,
On Thu, Sep 12, 2013 at 3:19 PM, Denis Kenzior <denkenz@gmail.com> wrote:
>
> Hi Vinicius,
>
>
> On 09/10/2013 07:09 PM, Vinicius Costa Gomes wrote:
>>
>> ---
>>
>> 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(+)
>
>
> Patch has been applied, but I tweaked the logic a bit in follow on commit e574d44d00780f2c7010677a6c261ffba82ea83f. Can you double check and see if you are okay with it?
Yeah, I am ok with it.
>
> Regards,
> -Denis
Cheers,
--
Vinicius
^ permalink raw reply [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.