Currently, when a bluetooth device is disconnected, pulseaudio doesn't unload the device module. The last patch fixes that. The preceding patches do some refactoring so that the final patch can be as nice as it is. This patch set seems to have caused a regression: profile restoring with module-card-restore doesn't work if the first profile to get connected isn't the one that module-card-restore tries to restore, then it doesn't work. For example, if HSP gets connected first and module-card-restore has A2DP configured in its database, restoring the profile will fail because A2DP isn't yet connected. The reason why this appeared to work (at least with headsets) in the past is probably that the Audio interface used to change its state to "connected" only after both HSP and A2DP were connected. I haven't done testing to confirm this theory, though. v3 will probably be needed to resolve the regression, but I'm sending these patches anyway to gather feedback about what should be done. Probably the Audio interface needs to be taken into use again, but I'd prefer to have something better in the long term, because using the Audio interface is only a hack that works only with headsets and only if bluetoothd always sends the update for the Audio interface only after both HSP and A2DP are connected. Tanu Kaskinen (5): bluetooth: Ignore Device.Connected and the whole org.bluez.Audio interface. bluetooth: Add "any_audio_profile_connected" field to pa_bluetooth_device. bluetooth: Add a pa_bluetooth_discovery pointer to pa_bluetooth_device. bluetooth: Run the discovery hook only when necessary. bluetooth: Unload the device module when there are no audio profiles connected. src/modules/bluetooth/bluetooth-util.c | 118 +++++++++++---------- src/modules/bluetooth/bluetooth-util.h | 8 +- src/modules/bluetooth/module-bluetooth-device.c | 22 +++- src/modules/bluetooth/module-bluetooth-discover.c | 5 +- 4 files changed, 88 insertions(+), 65 deletions(-) -- 1.7.10.4