Skip to content

Instantly share code, notes, and snippets.

@jakobrs
Created August 8, 2021 18:47
Show Gist options
  • Save jakobrs/c71130a968fbcf20f1a336a5a6fa34f8 to your computer and use it in GitHub Desktop.
Save jakobrs/c71130a968fbcf20f1a336a5a6fa34f8 to your computer and use it in GitHub Desktop.
local function create_null_sink()
print("Creating null sink")
null_node = Node("adapter", {
["factory.name"] = "support.null-audio-sink",
["media.class"] = "Audio/Sink",
["object.linger"] = true,
["audio.position"] = "[FL FR]",
["node.name"] = "automatic-null-sink",
})
null_node:activate(Feature.Proxy.BOUND)
end
om = ObjectManager {
Interest { type = "node",
Constraint { "media.class", "matches", "Audio/*" },
Constraint { "node.name", "not-equals", "automatic-null-sink" },
},
}
om:connect("object-added", function(om, node)
print("Node added:", node)
Debug.dump_table(node.properties)
if null_node and om:get_n_objects() >= 1 then
print("Destroying null sink")
null_node:request_destroy()
null_node = nil
end
end)
om:connect("object-removed", function(om, node)
print("Node removed:", node)
Debug.dump_table(node.properties)
if not null_node and om:get_n_objects() == 0 then
create_null_sink()
end
end)
om:connect("installed", function(om)
print("Installed object manager")
if om:get_n_objects() == 0 then
create_null_sink()
end
end)
om:activate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment