From 40b16974cf800ce728c7f084fbdd8b30b7a9f03c Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Tue, 11 Jan 2022 11:27:33 -0500 Subject: [PATCH 08/14] scripts: monitors: log warning if spa devices were not created successfully Can happen if the user does not have the specific spa pluging installed. --- src/scripts/monitors/alsa.lua | 10 +++++++--- src/scripts/monitors/bluez.lua | 9 +++++++-- src/scripts/monitors/libcamera.lua | 10 +++++++--- src/scripts/monitors/v4l2.lua | 10 +++++++--- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/scripts/monitors/alsa.lua b/src/scripts/monitors/alsa.lua index be4648e..8d297c1 100644 --- a/src/scripts/monitors/alsa.lua +++ b/src/scripts/monitors/alsa.lua @@ -177,9 +177,13 @@ end function createDevice(parent, id, factory, properties) local device = SpaDevice(factory, properties) - device:connect("create-object", createNode) - device:activate(Feature.SpaDevice.ENABLED | Feature.Proxy.BOUND) - parent:store_managed_object(id, device) + if device then + device:connect("create-object", createNode) + device:activate(Feature.SpaDevice.ENABLED | Feature.Proxy.BOUND) + parent:store_managed_object(id, device) + else + Log.warning ("Failed to create '" .. factory .. "' device") + end end function prepareDevice(parent, id, type, factory, properties) diff --git a/src/scripts/monitors/bluez.lua b/src/scripts/monitors/bluez.lua index 172e013..4a54a7b 100644 --- a/src/scripts/monitors/bluez.lua +++ b/src/scripts/monitors/bluez.lua @@ -109,8 +109,13 @@ function createDevice(parent, id, type, factory, properties) -- create the device device = SpaDevice(factory, properties) - device:connect("create-object", createNode) - parent:store_managed_object(id, device) + if device then + device:connect("create-object", createNode) + parent:store_managed_object(id, device) + else + Log.warning ("Failed to create '" .. factory .. "' device") + return + end end Log.info(parent, string.format("%d, %s (%s): %s", diff --git a/src/scripts/monitors/libcamera.lua b/src/scripts/monitors/libcamera.lua index e6e3ed9..27c7459 100644 --- a/src/scripts/monitors/libcamera.lua +++ b/src/scripts/monitors/libcamera.lua @@ -125,9 +125,13 @@ function createDevice(parent, id, type, factory, properties) -- create the device local device = SpaDevice(factory, properties) - device:connect("create-object", createNode) - device:activate(Feature.SpaDevice.ENABLED | Feature.Proxy.BOUND) - parent:store_managed_object(id, device) + if device then + device:connect("create-object", createNode) + device:activate(Feature.SpaDevice.ENABLED | Feature.Proxy.BOUND) + parent:store_managed_object(id, device) + else + Log.warning ("Failed to create '" .. factory .. "' device") + end end monitor = SpaDevice("api.libcamera.enum.manager", config.properties or {}) diff --git a/src/scripts/monitors/v4l2.lua b/src/scripts/monitors/v4l2.lua index fd9a20d..102eb81 100644 --- a/src/scripts/monitors/v4l2.lua +++ b/src/scripts/monitors/v4l2.lua @@ -125,9 +125,13 @@ function createDevice(parent, id, type, factory, properties) -- create the device local device = SpaDevice(factory, properties) - device:connect("create-object", createNode) - device:activate(Feature.SpaDevice.ENABLED | Feature.Proxy.BOUND) - parent:store_managed_object(id, device) + if device then + device:connect("create-object", createNode) + device:activate(Feature.SpaDevice.ENABLED | Feature.Proxy.BOUND) + parent:store_managed_object(id, device) + else + Log.warning ("Failed to create '" .. factory .. "' device") + end end monitor = SpaDevice("api.v4l2.enum.udev", config.properties or {}) -- 2.34.1