[pulseaudio-discuss] [RFCv0 12/21] bluetooth: Implement transport acquire for hf_audio_agent transports

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Fri May 30 03:07:58 PDT 2014


On Tue, 2014-02-04 at 19:03 -0300, jprvita at gmail.com wrote:
> From: João Paulo Rechi Vita <jprvita at openbossa.org>
> 
> ---
>  src/modules/bluetooth/hfaudioagent-ofono.c | 35 +++++++++++++++++++++++++++++-
>  1 file changed, 34 insertions(+), 1 deletion(-)
> 
> diff --git a/src/modules/bluetooth/hfaudioagent-ofono.c b/src/modules/bluetooth/hfaudioagent-ofono.c
> index d381a29..a565601 100644
> --- a/src/modules/bluetooth/hfaudioagent-ofono.c
> +++ b/src/modules/bluetooth/hfaudioagent-ofono.c
> @@ -23,6 +23,8 @@
>  #include <config.h>
>  #endif
>  
> +#include <errno.h>
> +
>  #include <pulsecore/core-util.h>
>  #include <pulsecore/dbus-shared.h>
>  #include <pulsecore/shared.h>
> @@ -121,7 +123,38 @@ static void hf_audio_card_free(void *data) {
>  }
>  
>  static int hf_audio_agent_transport_acquire(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu) {
> -    return -1;
> +    hf_audio_agent_data *hfdata = t->userdata;
> +    hf_audio_card *hfac = pa_hashmap_get(hfdata->hf_audio_cards, t->path);

I think it would make more sense to set the transport userdata to point
to the hf_audio_card, and have a pointer from hf_audio_card to
hf_audio_agent.

> +
> +    if (!optional) {
> +        DBusMessage *m;
> +
> +        pa_assert_se(m = dbus_message_new_method_call(t->owner, t->path, "org.ofono.HandsfreeAudioCard", "Connect"));
> +        pa_assert_se(dbus_connection_send(pa_dbus_connection_get(hfdata->connection), m, NULL));
> +
> +        return -1;
> +    }
> +
> +    /* The correct block size should take into account the SCO MTU from
> +     * the Bluetooth adapter and (for adapters in the USB bus) the MxPS
> +     * value from the Isoc USB endpoint in use by btusb and should be
> +     * made available to userspace by the Bluetooth kernel subsystem.
> +     * Meanwhile the empiric value 48 will be used. */
> +    if (imtu)
> +        *imtu = 48;
> +    if (omtu)
> +        *omtu = 48;
> +
> +    if (hfac) {

As far as I can see, it's not possible that an oFono transport would
exist without the corresponding audio card existing too.

> +        t->codec = hfac->codec;
> +
> +        /* Do the socket deferred setup */
> +        if (recv(hfac->fd, NULL, 0, 0) < 0)

hfac->fd is always -1. Patches in wrong order? Well, you also pass NULL
as the buffer, so I suppose it's intentional that this will always fail.
A TODO comment would be nice if you implement broken stuff on purpose.

-- 
Tanu



More information about the pulseaudio-discuss mailing list