[pulseaudio-discuss] [RFCv0 18/21] bluetooth: Implement org.ofono.HandsfreeAudioAgent.NewConnection()

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Sun Jun 1 03:33:55 PDT 2014


On Tue, 2014-02-04 at 19:04 -0300, jprvita at gmail.com wrote:
> From: João Paulo Rechi Vita <jprvita at openbossa.org>
> 
> ---
>  src/modules/bluetooth/hfaudioagent-ofono.c | 29 +++++++++++++++++++++++++++--
>  1 file changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/src/modules/bluetooth/hfaudioagent-ofono.c b/src/modules/bluetooth/hfaudioagent-ofono.c
> index 423e42a..fa8af94 100644
> --- a/src/modules/bluetooth/hfaudioagent-ofono.c
> +++ b/src/modules/bluetooth/hfaudioagent-ofono.c
> @@ -506,7 +506,10 @@ static DBusMessage *hf_audio_agent_release(DBusConnection *c, DBusMessage *m, vo
>  
>  static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage *m, void *data) {
>      DBusMessage *r;
> -    const char *sender;
> +    const char *sender, *card;
> +    int fd;
> +    uint8_t codec;
> +    hf_audio_card *hfac;
>      hf_audio_agent_data *hfdata = data;
>  
>      pa_assert(hfdata);
> @@ -517,7 +520,29 @@ static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage
>          return r;
>      }
>  
> -    r = dbus_message_new_error(m, "org.ofono.Error.NotImplemented", "Operation is not implemented");
> +    if (dbus_message_get_args(m, NULL,
> +                              DBUS_TYPE_OBJECT_PATH, &card,
> +                              DBUS_TYPE_UNIX_FD, &fd,
> +                              DBUS_TYPE_BYTE, &codec,
> +                              DBUS_TYPE_INVALID) == FALSE) {
> +        pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", "Invalid arguments in method call"));
> +        return r;
> +    }
> +
> +    if ( !(hfac = pa_hashmap_get(hfdata->hf_audio_cards, card)) ) {

Extra spaces around the if condition.

> +        pa_log_warn("New audio connection on unknown card %s (fd=%d, codec=%d)", card, fd, codec);
> +        pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", "Unknown card"));
> +        return r;
> +    } else
> +        pa_log_debug("New audio connection on card %s (fd=%d, codec=%d)", card, fd, codec);

I think we should check that hfac is in an expected state, i.e. not
already playing. Also the codec value needs to be validated.

> +
> +    hfac->fd = fd;
> +    hfac->codec = codec;
> +    hfac->transport->state = PA_BLUETOOTH_TRANSPORT_STATE_PLAYING;
> +    pa_hook_fire(pa_bluetooth_discovery_hook(hfdata->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED), hfac->transport);

It would be good to have pa_bluetooth_transport_set_state() that would
fire the hook.

-- 
Tanu



More information about the pulseaudio-discuss mailing list