Open Source Telephony
 help / color / mirror / Atom feed
From: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
To: ofono@ofono.org
Subject: Re: [PATCH 5/5] handsfree-audio: Add .Connect using the card driver
Date: Tue, 26 Mar 2013 18:21:32 -0300	[thread overview]
Message-ID: <20130326212132.GA2715@samus> (raw)
In-Reply-To: <1364249122-18332-5-git-send-email-vinicius.gomes@openbossa.org>

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

Hi,

On 19:05 Mon 25 Mar, Vinicius Costa Gomes wrote:
> ---
>  src/handsfree-audio.c | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
> index f8df6d6..9d3d64e 100644
> --- a/src/handsfree-audio.c
> +++ b/src/handsfree-audio.c
> @@ -307,6 +307,40 @@ done:
>  	return FALSE;
>  }
>  
> +static void card_connect_reply_cb(const struct ofono_error *error, void *data)
> +{
> +	struct ofono_handsfree_card *card = data;
> +	DBusMessage *reply;
> +
> +	if (error->type == OFONO_ERROR_TYPE_NO_ERROR)
> +		reply = dbus_message_new_method_return(card->msg);
> +	else
> +		reply = __ofono_error_failed(card->msg);
> +
> +	g_dbus_send_message(ofono_dbus_get_connection(), reply);
> +
> +	dbus_message_unref(card->msg);
> +	card->msg = NULL;
> +}
> +
> +static DBusMessage *card_connect_driver(struct ofono_handsfree_card *card,
> +							DBusMessage *msg)
> +{
> +	const struct ofono_handsfree_card_driver *driver = card->driver;
> +	int err;
> +
> +	err = driver->connect(card, card_connect_reply_cb, card);
> +	if (err == -EINPROGRESS) {
> +		card->msg = dbus_message_ref(msg);
> +		return NULL;
> +	}
> +
> +	if (err < 0)
> +		return __ofono_error_failed(msg);
> +
> +	return dbus_message_new_method_return(msg);
> +}
> +
>  static DBusMessage *card_connect(DBusConnection *conn,
>  						DBusMessage *msg, void *data)
>  {
> @@ -326,6 +360,10 @@ static DBusMessage *card_connect(DBusConnection *conn,
>  	if (card->msg)
>  		return __ofono_error_busy(msg);
>  
> +	if (card->driver && card->driver->connect)
> +		return card_connect_driver(card, msg);

In the case that both sides are HFP 1.6, but the Codec Negotiation feature is not
available on one of them, we should fallback to the direct codec connection
procedure.

I will send a version of this patch that makes it easier to handle this case,
without much repeated code.

> +
> +	/* There's no driver, fallback to direct SCO connection */
>  	sk = card_connect_sco(card);
>  	if (sk < 0)
>  		return __ofono_error_failed(msg);
> -- 
> 1.8.2
> 


Cheers,
-- 
Vinicius

  reply	other threads:[~2013-03-26 21:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-25 22:05 [PATCH 1/5] handsfree-audio: Add support for initiating SCO connections Vinicius Costa Gomes
2013-03-25 22:05 ` [PATCH 2/5] handsfree-audio: Add support for sending the SCO socket Vinicius Costa Gomes
2013-03-27  4:42   ` Denis Kenzior
2013-03-25 22:05 ` [PATCH 3/5] handsfree-audio: Reject .Connect() from other senders Vinicius Costa Gomes
2013-03-27  4:42   ` Denis Kenzior
2013-03-25 22:05 ` [PATCH 4/5] hfp_hf_bluez5: Add a card driver for HFP 1.6 Vinicius Costa Gomes
2013-03-27  4:43   ` Denis Kenzior
2013-03-25 22:05 ` [PATCH 5/5] handsfree-audio: Add .Connect using the card driver Vinicius Costa Gomes
2013-03-26 21:21   ` Vinicius Costa Gomes [this message]
2013-03-26 21:28     ` [PATCH] " Vinicius Costa Gomes
2013-03-27  4:59       ` Denis Kenzior
2013-03-27 14:22         ` Vinicius Costa Gomes
2013-03-27 14:32           ` Denis Kenzior
2013-03-27 14:45             ` Vinicius Costa Gomes
2013-03-27  4:41 ` [PATCH 1/5] handsfree-audio: Add support for initiating SCO connections Denis Kenzior

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=20130326212132.GA2715@samus \
    --to=vinicius.gomes@openbossa.org \
    --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