From efd24584182903bf5ee4660a3b3360cc47ad895b Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Tue, 23 Nov 2021 13:17:29 +0100
Subject: [PATCH] alsa: handle the release-requested signal

Handle the release-requested signal by destroying the device and
then calling release.

Fixes pipewire/pipewire#1846
---
 src/scripts/monitors/alsa.lua | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/scripts/monitors/alsa.lua b/src/scripts/monitors/alsa.lua
index 68c39d8..be4648e 100644
--- a/src/scripts/monitors/alsa.lua
+++ b/src/scripts/monitors/alsa.lua
@@ -287,6 +287,12 @@ function prepareDevice(parent, id, type, factory, properties)
       end
     end)
 
+    rd:connect("release-requested", function (rd)
+        Log.info("release requested")
+        parent:store_managed_object(id, nil)
+        rd:call("release")
+    end)
+
     if jack_device then
       rd:connect("notify::owner-name-changed", function (rd, pspec)
         if rd["state"] == "busy" and
-- 
2.34.1

