From b76ee008731843fb4c40b3bb642d2388bc4b348f Mon Sep 17 00:00:00 2001 From: Mikel Astiz Date: Fri, 28 Sep 2012 17:45:28 +0200 Subject: [PATCH] bluetooth: Fix potential assertion failure It might happen that a PropertyChanged signal is received but the corresponding card profile has not been created, leading to an assertion failure in filter_cb() due to inexistent ports. This can happen if BlueZ misbehaves, or also if the UUIDs are reported later on (i.e. during pairing discovery). In any case, the signal should just be ignored. --- src/modules/bluetooth/module-bluetooth-device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 3e518b538..bfb47d1e1 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -1357,7 +1357,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us } else if (dbus_message_is_signal(m, "org.bluez.HandsfreeGateway", "PropertyChanged")) { pa_bt_audio_state_t state = parse_state_property_change(m); - if (state != PA_BT_AUDIO_STATE_INVALID) { + if (state != PA_BT_AUDIO_STATE_INVALID && pa_hashmap_get(u->card->profiles, "hfgw")) { pa_device_port *port; pa_port_available_t available = audio_state_to_availability(state); @@ -1373,7 +1373,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us } else if (dbus_message_is_signal(m, "org.bluez.Headset", "PropertyChanged")) { pa_bt_audio_state_t state = parse_state_property_change(m); - if (state != PA_BT_AUDIO_STATE_INVALID) { + if (state != PA_BT_AUDIO_STATE_INVALID && pa_hashmap_get(u->card->profiles, "hsp")) { pa_device_port *port; pa_port_available_t available = audio_state_to_availability(state); @@ -1389,7 +1389,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us } else if (dbus_message_is_signal(m, "org.bluez.AudioSource", "PropertyChanged")) { pa_bt_audio_state_t state = parse_state_property_change(m); - if (state != PA_BT_AUDIO_STATE_INVALID) { + if (state != PA_BT_AUDIO_STATE_INVALID && pa_hashmap_get(u->card->profiles, "a2dp_source")) { pa_device_port *port; pa_port_available_t available = audio_state_to_availability(state); @@ -1402,7 +1402,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us } else if (dbus_message_is_signal(m, "org.bluez.AudioSink", "PropertyChanged")) { pa_bt_audio_state_t state = parse_state_property_change(m); - if (state != PA_BT_AUDIO_STATE_INVALID) { + if (state != PA_BT_AUDIO_STATE_INVALID && pa_hashmap_get(u->card->profiles, "a2dp")) { pa_device_port *port; pa_port_available_t available = audio_state_to_availability(state);