[pulseaudio-discuss] [RFC next v0 03/11] bluetooth: Add backend->core notification of new transports

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Tue Jun 25 01:51:27 PDT 2013


On Wed, 2013-05-15 at 10:46 +0200, Mikel Astiz wrote:
> From: Mikel Astiz <mikel.astiz at bmw-carit.de>
> 
> Backends are responsible for the notification of new transports, which
> is backend-dependant. The core still holds ownership of the transport
> objects.
> ---
>  src/modules/bluetooth/bluetooth-util.c | 45 ++++++++++++++++++++++++----------
>  src/modules/bluetooth/bluetooth-util.h | 13 ++++++++++
>  2 files changed, 45 insertions(+), 13 deletions(-)
> 
> diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
> index 2e3203e..56156a9 100644
> --- a/src/modules/bluetooth/bluetooth-util.c
> +++ b/src/modules/bluetooth/bluetooth-util.c
> @@ -1594,23 +1594,22 @@ static int setup_dbus(pa_bluetooth_discovery *y) {
>  static pa_bluetooth_transport *transport_new(pa_bluetooth_device *d, const char *owner, const char *path, enum profile p,
>                                               const uint8_t *config, int size) {
>      pa_bluetooth_transport *t;
> +    pa_bluetooth_transport_new_data data;
>  
> -    t = pa_xnew0(pa_bluetooth_transport, 1);
> -    t->device = d;
> -    t->owner = pa_xstrdup(owner);
> -    t->path = pa_xstrdup(path);
> -    t->profile = p;
> -    t->config_size = size;
> -
> -    if (size > 0) {
> -        t->config = pa_xnew(uint8_t, size);
> -        memcpy(t->config, config, size);
> -    }
> +    data.device = d;
> +    data.profile = p;
> +    data.config_size = size;
> +    data.config = config;
>  
>      if (d->discovery->version == BLUEZ_VERSION_4)
> -        t->state = audio_state_to_transport_state(d->profile_state[p]);
> +        data.state = audio_state_to_transport_state(d->profile_state[p]);
>      else
> -        t->state = PA_BLUETOOTH_TRANSPORT_STATE_IDLE;
> +        data.state = PA_BLUETOOTH_TRANSPORT_STATE_IDLE;
> +
> +    t = pa_bt_backend_notify_transport_added(&data);
> +
> +    t->owner = pa_xstrdup(owner);
> +    t->path = pa_xstrdup(path);
>  
>      return t;
>  }

If we want to follow common patterns of the PulseAudio code base,
transport_new() would be renamed to bluez_transport_new() and
pa_bt_backend_notify_transport_added() would be renamed to
pa_bluetooth_transport_new(). Then there would be also
pa_bluetooth_transport_put() to be called after the backend has fully
completed the transport initialization.

Is the configuration byte array a BlueZ specific thing, or is the config
blob part of the Bluetooth specification?

-- 
Tanu



More information about the pulseaudio-discuss mailing list