[pulseaudio-discuss] [PATCH v2 5/5] bluetooth: Unload the device module when there are no audio profiles connected.
Mikel Astiz
mikel.astiz.oss at gmail.com
Wed Nov 21 01:41:20 PST 2012
Hi Tanu,
On Tue, Nov 20, 2012 at 3:48 PM, Tanu Kaskinen <tanuk at iki.fi> wrote:
> Without this patch, device modules will be left around after the
> device has been disconnected and when they are reconnected, the
> discovery module will load duplicate device module instances.
>
> BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=57239
> ---
> src/modules/bluetooth/bluetooth-util.c | 2 ++
> src/modules/bluetooth/bluetooth-util.h | 1 +
> src/modules/bluetooth/module-bluetooth-device.c | 22 +++++++++++++++++++---
> 3 files changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
> index 6b3085b..1f40e81 100644
> --- a/src/modules/bluetooth/bluetooth-util.c
> +++ b/src/modules/bluetooth/bluetooth-util.c
> @@ -517,6 +517,8 @@ static void device_update_any_audio_profile_connected(pa_bluetooth_device *d) {
> else
> pa_log_debug("Device %s doesn't have any audio profiles connected anymore.", d->path);
>
> + pa_hook_fire(&d->hooks[PA_BLUETOOTH_DEVICE_HOOK_ANY_AUDIO_PROFILE_CONNECTED_CHANGED], NULL);
> +
> run_callback(d, false);
> }
>
> diff --git a/src/modules/bluetooth/bluetooth-util.h b/src/modules/bluetooth/bluetooth-util.h
> index c865b93..bcc7be3 100644
> --- a/src/modules/bluetooth/bluetooth-util.h
> +++ b/src/modules/bluetooth/bluetooth-util.h
> @@ -95,6 +95,7 @@ typedef enum pa_bt_audio_state {
> typedef enum pa_bluetooth_device_hook {
> PA_BLUETOOTH_DEVICE_HOOK_REMOVED, /* Call data: NULL. */
> PA_BLUETOOTH_DEVICE_HOOK_UUID_ADDED, /* Call data: const char *uuid. */
> + PA_BLUETOOTH_DEVICE_HOOK_ANY_AUDIO_PROFILE_CONNECTED_CHANGED, /* Call data: NULL. */
I would suggest you split this patch into two, in order to add to hook
in the first one without any further changes in
module-bluetooth-device.
Besides, I propose changing the hook to
PA_BLUETOOTH_DEVICE_HOOK_PROFILE_CONNECTED_CHANGED. I think this could
fit your idea and it would additionally be handy to server other
purposes, such as completely removing D-Bus code in
module-bluetooth-device (i.e. remove filter_cb).
Cheers,
Mikel
More information about the pulseaudio-discuss
mailing list