[pulseaudio-discuss] [RFC v0 3/5] bluetooth: Expose card profile availability

Tanu Kaskinen tanuk at iki.fi
Sat Feb 16 08:16:53 PST 2013


On Wed, 2013-02-13 at 14:48 +0100, Mikel Astiz wrote:
> From: Mikel Astiz <mikel.astiz at bmw-carit.de>
> 
> Use the transport's state to not only update the ports availability, but
> also to update the card profile availability flag. The interpretation is
> as follows:
> - PA_PROFILE_AVAILABLE_UNKNOWN: BT profile is connected but no audio
> - PA_PROFILE_AVAILABLE_NO: BT profile disconnected
> - PA_PROFILE_AVAILABLE_YES: BT profile connected and audio streaming
> ---
>  src/modules/bluetooth/module-bluetooth-device.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
> index 33b2afa..0eaa4e5 100644
> --- a/src/modules/bluetooth/module-bluetooth-device.c
> +++ b/src/modules/bluetooth/module-bluetooth-device.c
> @@ -1210,11 +1210,21 @@ static pa_port_available_t transport_state_to_availability_merged(pa_bluetooth_t
>          return PA_PORT_AVAILABLE_UNKNOWN;
>  }
>  
> +static pa_profile_available_t transport_state_to_profile_availability(pa_bluetooth_transport_state_t state) {
> +    if (state == PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)
> +        return PA_PROFILE_AVAILABLE_NO;
> +    else if (state >= PA_BLUETOOTH_TRANSPORT_STATE_PLAYING)
> +        return PA_PROFILE_AVAILABLE_YES;
> +    else
> +        return PA_PROFILE_AVAILABLE_UNKNOWN;
> +}

I think a switch would be better, because if states are added, the
compiler will complain if this function isn't updated. There might be
new states that should map to "no", like "connecting".

-- 
Tanu



More information about the pulseaudio-discuss mailing list