From ad8491df4455434c4fea47828855e296af232147 Mon Sep 17 00:00:00 2001
From: Julian Bouzas <julian.bouzas@collabora.com>
Date: Wed, 28 Aug 2019 13:30:42 -0400
Subject: [PATCH] modules: destroy all alsa/bluez nodes when an alsa/bluez
 device is removed

---
 modules/module-pw-alsa-udev.c | 6 ++++++
 modules/module-pw-bluez.c     | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/modules/module-pw-alsa-udev.c b/modules/module-pw-alsa-udev.c
index 6c499495..534776e7 100644
--- a/modules/module-pw-alsa-udev.c
+++ b/modules/module-pw-alsa-udev.c
@@ -415,12 +415,18 @@ update_device(struct impl *impl, struct device *dev,
 static void
 destroy_device(struct impl *impl, struct device *dev)
 {
+  struct node *node;
+
   /* Remove the device from the list */
   spa_list_remove(&dev->link);
 
   /* Remove the device listener */
   spa_hook_remove(&dev->device_listener);
 
+  /* Destry all the nodes that the device has */
+  spa_list_consume(node, &dev->node_list, link)
+    destroy_node(impl, dev, node);
+
   /* Destroy the device proxy */
   pw_proxy_destroy(dev->proxy);
 
diff --git a/modules/module-pw-bluez.c b/modules/module-pw-bluez.c
index e1392dd1..754b7f93 100644
--- a/modules/module-pw-bluez.c
+++ b/modules/module-pw-bluez.c
@@ -445,12 +445,18 @@ update_device(struct impl *impl, struct device *dev,
 static void
 destroy_device(struct impl *impl, struct device *dev)
 {
+  struct node *node;
+
   /* Remove the device from the list */
   spa_list_remove(&dev->link);
 
   /* Remove the device listener */
   spa_hook_remove(&dev->device_listener);
 
+  /* Destry all the nodes that the device has */
+  spa_list_consume(node, &dev->node_list, link)
+    destroy_node(impl, dev, node);
+
   /* Destroy the device proxy */
   pw_proxy_destroy(dev->proxy);
 
-- 
GitLab