suspend-node: check if the node still exists before suspending it

After a timeout, it's possible that something else may have
destroyed the node already. This can happen for example with virtual
sinks that were created from another process.

Fixes: #467
This commit is contained in:
George Kiagiadakis 2023-06-14 23:26:30 +03:00
parent a7b8966c06
commit 5d4db78427

View file

@ -38,8 +38,11 @@ om:connect("object-added", function (om, node)
-- add idle timeout; multiply by 1000, timeout_add() expects ms
sources[id] = Core.timeout_add(timeout * 1000, function()
-- Suspend the node
Log.info(node, "was idle for a while; suspending ...")
node:send_command("Suspend")
-- but check first if the node still exists
if (node:get_active_features() & Feature.Proxy.BOUND) ~= 0 then
Log.info(node, "was idle for a while; suspending ...")
node:send_command("Suspend")
end
-- Unref the source
sources[id] = nil