[RFCv0 16/21] bluetooth: Handle CardRemoved signal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/src/modules/bluetooth/hfaudioagent-ofono.c b/src/modules/bluetooth/hfaudioagent-ofono.c
> index 9daf964..6a26367 100644
> --- a/src/modules/bluetooth/hfaudioagent-ofono.c
> +++ b/src/modules/bluetooth/hfaudioagent-ofono.c
> @@ -444,6 +444,29 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *da
>  
>          hf_audio_agent_card_found(hfdata, p, &props_i);
>  
> +    } else if (dbus_message_is_signal(m, "org.ofono.HandsfreeAudioManager", "CardRemoved")) {
> +        const char *p;
> +        hf_audio_card *hfac;
> +        bool old_any_connected;
> +
> +        if (!dbus_message_get_args(m, &err, DBUS_TYPE_OBJECT_PATH, &p, DBUS_TYPE_INVALID)) {
> +            pa_log_error("Failed to parse org.ofono.HandsfreeAudioManager.CardRemoved: %s", err.message);
> +            goto fail;
> +        }
> +
> +        if ((hfac = pa_hashmap_remove(hfdata->hf_audio_cards, p)) != NULL) {
> +            old_any_connected = pa_bluetooth_device_any_transport_connected(hfac->transport->device);
> +
> +            hfac->transport->state = PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED;
> +            hfac->transport->device->transports[hfac->transport->profile] = NULL;
> +            pa_hook_fire(pa_bluetooth_discovery_hook(hfdata->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED), hfac->transport);
> +
> +            if (old_any_connected != pa_bluetooth_device_any_transport_connected(hfac->transport->device)) {
> +                pa_hook_fire(pa_bluetooth_discovery_hook(hfdata->discovery, PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED), hfac->transport->device);
> +            }

This is not nice from encapsulation point of view.

There should be pa_bluetooth_device_set_transport(), which given NULL
would fire DEVICE_CONNECTION_CHANGED if necessary.
pa_bluetooth_device_set_transport() should be called by
pa_transport_unlink(). pa_transport_unlink() should also take care of
setting transport->state and firing TRANSPORT_STATE_CHANGED.

> +
> +            hf_audio_card_free(hfac);

This is the only call that belongs here.

-- 
Tanu



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux