do_install:append() {
# install smack-specific config
- config_dir="${D}${sysconfdir}/wireplumber/config.lua.d/"
- access_dir="${D}${sysconfdir}/wireplumber/scripts/access/"
- mkdir -p ${access_dir}
+ config_dir="${D}${sysconfdir}/wireplumber/host.lua.d/"
+ access_dir="${D}${datadir}/wireplumber/scripts/access/"
+ install -d ${access_dir}
install -m 0644 ${WORKDIR}/50-access-agl.lua ${config_dir}
install -m 0644 ${WORKDIR}/access-smack.lua ${access_dir}
}
+++ /dev/null
--- Enable local & bluetooth audio devices
-alsa_monitor.enable()
-bluez_monitor.enable()
-
--- Load policy
-default_policy.enable()
-
--- Implements storing metadata about objects in RAM
-load_module("metadata")
-
--- Keeps track of the "default" sources and sinks
-load_module("default-nodes", {
- -- do not store runtime user changes in $HOME
- ["use-persistent-storage"] = false,
-})
-
--- Selects default routes on devices that advertise routes
-load_script("default-routes.lua", {
- -- do not store runtime user changes in $HOME
- ["use-persistent-storage"] = false,
-})
-
--- Automatically suspends idle nodes after 3 seconds
-load_script("suspend-node.lua")
-
--- Automatically sets device profiles to 'On'
-load_module("device-activation")
--- /dev/null
+-- WirePlumber
+--
+-- This script mutes all ALSA sinks when the "suspend.playback" metadata
+-- key is set to 1; compliments pipewire-ic-ipc and the respective support
+-- for handling "suspend.playback" in the policy scripts
+--
+-- Copyright © 2021 Collabora Ltd.
+-- @author George Kiagiadakis <george.kiagiadakis@collabora.com>
+--
+-- SPDX-License-Identifier: MIT
+
+mixer_api = Plugin.find("mixer-api")
+
+nodes_om = ObjectManager {
+ Interest { type = "node",
+ Constraint { "media.class", "matches", "Audio/Sink" },
+ Constraint { "object.path", "matches", "alsa:pcm:*" },
+ },
+}
+
+metadata_om = ObjectManager {
+ Interest { type = "metadata",
+ Constraint { "metadata.name", "=", "default" },
+ }
+}
+
+metadata_om:connect("object-added", function (om, metadata)
+ metadata:connect("changed", function (m, subject, key, t, value)
+ if key == "suspend.playback" then
+ local suspended = (value == "1")
+
+ Log.info(string.format("%s ALSA nodes for IC sound",
+ suspended and "muting" or "unmuting"))
+
+ for n in nodes_om:iterate() do
+ mixer_api:call("set-volume", n["bound-id"], {
+ ["mute"] = suspended,
+ })
+ end
+ end
+ end)
+end)
+
+nodes_om:activate()
+metadata_om:activate()
--- /dev/null
+# WirePlumber daemon context configuration #
+
+context.properties = {
+ ## Properties to configure the PipeWire context and some modules
+
+ application.name = "WirePlumber Bluetooth"
+ log.level = 2
+ wireplumber.script-engine = lua-scripting
+ wireplumber.export-core = false
+
+ #mem.mlock-all = false
+ #support.dbus = true
+}
+
+context.spa-libs = {
+ #<factory-name regex> = <library-name>
+ #
+ # Used to find spa factory names. It maps an spa factory name
+ # regular expression to a library name that should contain
+ # that factory.
+ #
+ api.bluez5.* = bluez5/libspa-bluez5
+ audio.convert.* = audioconvert/libspa-audioconvert
+ support.* = support/libspa-support
+}
+
+context.modules = [
+ #{ name = <module-name>
+ # [ args = { <key> = <value> ... } ]
+ # [ flags = [ [ ifexists ] [ nofail ] ]
+ #}
+ #
+ # PipeWire modules to load.
+ # If ifexists is given, the module is ignored when it is not found.
+ # If nofail is given, module initialization failures are ignored.
+ #
+
+ # The native communication protocol.
+ { name = libpipewire-module-protocol-native }
+
+ # Allows creating nodes that run in the context of the
+ # client. Is used by all clients that want to provide
+ # data to PipeWire.
+ { name = libpipewire-module-client-node }
+
+ # Allows creating devices that run in the context of the
+ # client. Is used by the session manager.
+ { name = libpipewire-module-client-device }
+
+ # Makes a factory for wrapping nodes in an adapter with a
+ # converter and resampler.
+ { name = libpipewire-module-adapter }
+
+ # Allows applications to create metadata objects. It creates
+ # a factory for Metadata objects.
+ { name = libpipewire-module-metadata }
+
+ # Provides factories to make session manager objects.
+ { name = libpipewire-module-session-manager }
+]
+
+wireplumber.components = [
+ #{ name = <component-name>, type = <component-type> }
+ #
+ # WirePlumber components to load
+ #
+
+ # The lua scripting engine
+ { name = libwireplumber-module-lua-scripting, type = module }
+
+ # The lua configuration file
+ # Other components are loaded from there
+ { name = bluetooth.lua, type = config/lua }
+]
},
}
-function bluez_monitor.enable()
- load_monitor("bluez", {
- properties = bluez_monitor.properties,
- rules = bluez_monitor.rules,
- })
-end
+load_monitor("bluez", {
+ properties = bluez_monitor.properties,
+ rules = bluez_monitor.rules,
+})
--- /dev/null
+-- V4L2 monitor config file --
+
+v4l2_monitor = {}
+v4l2_monitor.properties = {}
+
+v4l2_monitor.rules = {
+ -- An array of matches/actions to evaluate.
+ {
+ -- Rules for matching a device or node. It is an array of
+ -- properties that all need to match the regexp. If any of the
+ -- matches work, the actions are executed for the object.
+ matches = {
+ {
+ -- This matches all cards.
+ { "device.name", "matches", "v4l2_device.*" },
+ },
+ },
+ -- Apply properties on the matched object.
+ apply_properties = {
+ -- ["device.nick"] = "My Device",
+ },
+ },
+ {
+ matches = {
+ {
+ -- Matches all sources.
+ { "node.name", "matches", "v4l2_input.*" },
+ },
+ {
+ -- Matches all sinks.
+ { "node.name", "matches", "v4l2_output.*" },
+ },
+ },
+ apply_properties = {
+ --["node.nick"] = "My Node",
+ --["priority.driver"] = 100,
+ --["priority.session"] = 100,
+ --["node.pause-on-idle"] = false,
+ },
+ },
+}
+
+function v4l2_monitor.enable()
+ load_monitor("v4l2", {
+ properties = v4l2_monitor.properties,
+ rules = v4l2_monitor.rules,
+ })
+end
--- /dev/null
+device_defaults = {}
+
+device_defaults.properties = {
+ -- store preferences to the file system and restore them at startup;
+ -- when set to false, default nodes and routes are selected based on
+ -- their priorities and any runtime changes do not persist after restart
+ ["use-persistent-storage"] = false,
+}
+
+function device_defaults.enable()
+ -- Selects appropriate default nodes and enables saving and restoring them
+ load_module("default-nodes", device_defaults.properties)
+
+ -- Selects appropriate default routes ("ports" in pulseaudio terminology)
+ -- and enables saving and restoring them together with
+ -- their properties (per-route/port volume levels, channel maps, etc)
+ load_script("default-routes.lua", device_defaults.properties)
+
+ if device_defaults.properties["use-persistent-storage"] then
+ -- Enables functionality to save and restore default device profiles
+ load_module("default-profile")
+
+ -- Save and restore stream-specific properties
+ load_script("restore-stream.lua")
+ end
+end
--- /dev/null
+-- Provide the "default" pw_metadata, which stores
+-- dynamic properties of pipewire objects in RAM
+load_module("metadata")
+
+-- Load devices
+alsa_monitor.enable()
+--v4l2_monitor.enable()
+
+-- Track/store/restore user choices about devices
+device_defaults.enable()
+
+-- Automatically suspends idle nodes after 3 seconds
+load_script("suspend-node.lua")
+
+-- Automatically sets device profiles to 'On'
+load_module("device-activation")
+
+-- Mute ALSA sinks when requested by pipewire-ic-ipc
+load_module("mixer-api")
+load_script("alsa-suspend.lua")
--- /dev/null
+# WirePlumber daemon context configuration #
+
+context.properties = {
+ ## Properties to configure the PipeWire context and some modules
+
+ application.name = "WirePlumber Policy"
+ log.level = 2
+ wireplumber.script-engine = lua-scripting
+ wireplumber.export-core = false
+
+ #mem.mlock-all = false
+ #support.dbus = true
+}
+
+context.spa-libs = {
+ #<factory-name regex> = <library-name>
+ #
+ # Used to find spa factory names. It maps an spa factory name
+ # regular expression to a library name that should contain
+ # that factory.
+ #
+ audio.convert.* = audioconvert/libspa-audioconvert
+ support.* = support/libspa-support
+}
+
+context.modules = [
+ #{ name = <module-name>
+ # [ args = { <key> = <value> ... } ]
+ # [ flags = [ [ ifexists ] [ nofail ] ]
+ #}
+ #
+ # PipeWire modules to load.
+ # If ifexists is given, the module is ignored when it is not found.
+ # If nofail is given, module initialization failures are ignored.
+ #
+
+ # The native communication protocol.
+ { name = libpipewire-module-protocol-native }
+
+ # Allows creating nodes that run in the context of the
+ # client. Is used by all clients that want to provide
+ # data to PipeWire.
+ { name = libpipewire-module-client-node }
+
+ # Allows creating devices that run in the context of the
+ # client. Is used by the session manager.
+ { name = libpipewire-module-client-device }
+
+ # Makes a factory for wrapping nodes in an adapter with a
+ # converter and resampler.
+ { name = libpipewire-module-adapter }
+
+ # Allows applications to create metadata objects. It creates
+ # a factory for Metadata objects.
+ { name = libpipewire-module-metadata }
+
+ # Provides factories to make session manager objects.
+ { name = libpipewire-module-session-manager }
+]
+
+wireplumber.components = [
+ #{ name = <component-name>, type = <component-type> }
+ #
+ # WirePlumber components to load
+ #
+
+ # The lua scripting engine
+ { name = libwireplumber-module-lua-scripting, type = module }
+
+ # The lua configuration file
+ # Other components are loaded from there
+ { name = policy.lua, type = config/lua }
+]
--- Default policy config file --
+-- Policy config file --
-default_policy = {}
+policy_config = {}
-default_policy.endpoints = {
+policy_config.endpoints = {
-- [endpoint name] = { endpoint properties }
["endpoint.multimedia"] = {
},
}
-default_policy.policy = {
+policy_config.policy = {
["move"] = false, -- moves session items when metadata target.node changes
["follow"] = true, -- moves session items to the default device when it has changed
-- how much to lower the volume of lower priority streams when ducking
- -- note that this is a linear volume modifier (not cubic as in the mixer)
+ -- note that this is a linear volume modifier (not cubic as in pulseaudio)
["duck.level"] = 0.2,
["roles"] = {
},
}
-function default_policy.enable()
- -- Session item factories, building blocks for the session management graph
- -- Do not disable these unless you really know what you are doing
- load_module("si-node")
- load_module("si-audio-adapter")
- load_module("si-standard-link")
- load_module("si-audio-endpoint")
+-- Session item factories, building blocks for the session management graph
+-- Do not disable these unless you really know what you are doing
+load_module("si-node")
+load_module("si-audio-adapter")
+load_module("si-standard-link")
+load_module("si-audio-endpoint")
- -- API to access default nodes from scripts
- load_module("default-nodes-api")
+-- API to access default nodes from scripts
+load_module("default-nodes-api")
- -- API to access mixer controls, needed for volume ducking
- load_module("mixer-api")
+-- API to access mixer controls, needed for volume ducking
+load_module("mixer-api")
- -- Create endpoints statically at startup
- load_script("static-endpoints.lua", default_policy.endpoints)
+-- Create endpoints statically at startup
+load_script("static-endpoints.lua", policy_config.endpoints)
- -- Create session items for nodes that appear in the graph
- load_script("create-item.lua")
+-- Create items for nodes that appear in the graph
+load_script("create-item.lua")
- -- Link nodes to each other to make media flow in the graph
- load_script("policy-node.lua", default_policy.policy)
+-- Link nodes to each other to make media flow in the graph
+load_script("policy-node.lua", policy_config.policy)
- -- Link client nodes with endpoints to make media flow in the graph
- load_script("policy-endpoint-client.lua", default_policy.policy)
- load_script("policy-endpoint-client-links.lua", default_policy.policy)
+-- Link client nodes with endpoints to make media flow in the graph
+load_script("policy-endpoint-client.lua", policy_config.policy)
+load_script("policy-endpoint-client-links.lua", policy_config.policy)
- -- Link endpoints with device nodes to make media flow in the graph
- load_script("policy-endpoint-device.lua", default_policy.policy)
-end
+-- Link endpoints with device nodes to make media flow in the graph
+load_script("policy-endpoint-device.lua", policy_config.policy)
# The lua configuration file(s)
# Other components are loaded from there
- { name = config.lua, type = config/lua }
+ { name = host.lua, type = config/lua }
]
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "\
+ file://bluetooth.lua.d/ \
+ file://host.lua.d/ \
+ file://policy.lua.d \
file://00-functions.lua \
- file://10-default-policy.lua \
- file://30-alsa-monitor.lua \
- file://30-bluez-monitor.lua \
- file://99-load-modules.lua \
+ file://alsa-suspend.lua \
+ file://bluetooth.conf \
+ file://policy.conf \
file://wireplumber.conf \
file://wireplumber-bluetooth.conf \
"
do_configure[noexec] = "1"
do_compile[noexec] = "1"
do_install:append() {
- config_dir="${D}${sysconfdir}/wireplumber/config.lua.d/"
+ config_dir="${D}${sysconfdir}/wireplumber/"
+ scripts_dir="${D}${datadir}/wireplumber/scripts/"
dbus_config_dir="${D}${sysconfdir}/dbus-1/system.d/"
+ systemd_dir="${D}${sysconfdir}/systemd/system/pipewire.service.wants/"
install -d ${config_dir}
install -m 0644 ${WORKDIR}/00-functions.lua ${config_dir}
- install -m 0644 ${WORKDIR}/10-default-policy.lua ${config_dir}
- install -m 0644 ${WORKDIR}/30-alsa-monitor.lua ${config_dir}
- install -m 0644 ${WORKDIR}/30-bluez-monitor.lua ${config_dir}
- install -m 0644 ${WORKDIR}/99-load-modules.lua ${config_dir}
- install -m 0644 ${WORKDIR}/wireplumber.conf ${D}${sysconfdir}/wireplumber/
+ # config of the main (host) instance
+ install -d ${config_dir}/host.lua.d/
+ ln -s ../00-functions.lua ${config_dir}/host.lua.d/00-functions.lua
+ install -m 0644 ${WORKDIR}/host.lua.d/*.lua ${config_dir}/host.lua.d/
+ install -m 0644 ${WORKDIR}/wireplumber.conf ${config_dir}
+ # config of the policy instance
+ install -d ${config_dir}/policy.lua.d/
+ ln -s ../00-functions.lua ${config_dir}/policy.lua.d/00-functions.lua
+ install -m 0644 ${WORKDIR}/policy.lua.d/*.lua ${config_dir}/policy.lua.d/
+ install -m 0644 ${WORKDIR}/policy.conf ${config_dir}
+
+ # config of the bluetooth instance
+ install -d ${config_dir}/bluetooth.lua.d/
+ ln -s ../00-functions.lua ${config_dir}/bluetooth.lua.d/00-functions.lua
+ install -m 0644 ${WORKDIR}/bluetooth.lua.d/*.lua ${config_dir}/bluetooth.lua.d/
+ install -m 0644 ${WORKDIR}/bluetooth.conf ${config_dir}
+
+ # install the alsa-suspend script, loaded by the main instance
+ install -d ${scripts_dir}
+ install -m 0644 ${WORKDIR}/alsa-suspend.lua ${scripts_dir}
+
+ # install dbus daemon configuration
install -d ${dbus_config_dir}
install -m 0644 ${WORKDIR}/wireplumber-bluetooth.conf ${dbus_config_dir}
+
+ # enable additional systemd services
+ install -d ${systemd_dir}
+ ln -s ${systemd_system_unitdir}/wireplumber@.service ${systemd_dir}/wireplumber@policy.service
+ ln -s ${systemd_system_unitdir}/wireplumber@.service ${systemd_dir}/wireplumber@bluetooth.service
}
FILES:${PN} += "\
- ${sysconfdir}/wireplumber/* \
+ ${sysconfdir}/* \
+ ${datadir}/wireplumber/* \
"
CONFFILES:${PN} += "\
- ${sysconfdir}/wireplumber/* \
+ ${sysconfdir}/* \
"
RPROVIDES:${PN} += "virtual/wireplumber-config"