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
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to