Re: [meta-arago][master][PATCH v2] pulseaudio-service: Add systemd service for system-wide audio daemon

Yogesh Hegde <[email protected]>
Newsgroups org.yoctoproject.lists.meta-arago
Message-ID <20260205061034.oq53pehysfd2ylpi@yogi-work-pc>
Hi Jeevan, 

Thanks for the patch!

On 21:38-20260204, Jeevan via lists.yoctoproject.org wrote:
> Add a systemd service to run PulseAudio in system mode where multiple
> applications need audio access without user sessions. Depends on
> pulseaudio-server to ensure audio/pulse groups exist.
> 
> Enable this service by default to provide system-wide audio for all
> applications.
> 
> Signed-off-by: Telukula Jeevan Kumar Sahu <[email protected]>
> ---
> Changes in v2: Add SUMMARY, PV and PR.
> 
>  .../pulseaudio/files/pulseaudio.service       | 11 ++++++
>  .../pulseaudio/pulseaudio-service.bb          | 39 +++++++++++++++++++
>  2 files changed, 50 insertions(+)
>  create mode 100644 meta-arago-extras/recipes-multimedia/pulseaudio/files/pulseaudio.service
>  create mode 100644 meta-arago-extras/recipes-multimedia/pulseaudio/pulseaudio-service.bb
> 
> diff --git a/meta-arago-extras/recipes-multimedia/pulseaudio/files/pulseaudio.service b/meta-arago-extras/recipes-multimedia/pulseaudio/files/pulseaudio.service
> new file mode 100644
> index 00000000..1d3ac435
> --- /dev/null
> +++ b/meta-arago-extras/recipes-multimedia/pulseaudio/files/pulseaudio.service
> @@ -0,0 +1,11 @@
> +[Unit]
> +Description=PulseAudio Sound System
> +After=alsa-restore.service

I suggest adding Wants=alsa-restore.service to ensure that this service fails if
alsa-restore fails or is missing.

> +
> +[Service]
> +BusName=org.pulseaudio.Server
> +ExecStart=/usr/bin/pulseaudio --system
> +Restart=always
> +
> +[Install]
> +WantedBy=multi-user.target
> diff --git a/meta-arago-extras/recipes-multimedia/pulseaudio/pulseaudio-service.bb b/meta-arago-extras/recipes-multimedia/pulseaudio/pulseaudio-service.bb
> new file mode 100644
> index 00000000..5ce849fc
> --- /dev/null
> +++ b/meta-arago-extras/recipes-multimedia/pulseaudio/pulseaudio-service.bb
> @@ -0,0 +1,39 @@
> +SUMMARY = "PulseAudio systemd service for system-wide audio"
> +DESCRIPTION = "Systemd service to run PulseAudio in system mode for embedded systems"
> +LICENSE = "MIT"
> +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
> +
> +PV = "1.0"
> +PR = "r0"
> +
> +inherit ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}
> +inherit useradd
> +
> +DEPENDS = "pulseaudio"
> +
> +# Ensure pulseaudio-server is installed to create audio group
> +RDEPENDS:${PN} = "pulseaudio-server"
> +
> +SRC_URI = "\
> +    file://pulseaudio.service \
> +"
> +
> +S = "${UNPACKDIR}"
> +
> +SYSTEMD_PACKAGES = "${PN}"
> +SYSTEMD_SERVICE:${PN} = "pulseaudio.service"
> +SYSTEMD_AUTO_ENABLE:${PN} = "disable"

Commit message says "enable the service by default", while it is disabled
here.

> +
> +FILES:${PN} = " \
> +    ${systemd_system_unitdir}/pulseaudio.service \
> +"

inherit systemd should take care of the packaging the service file [0].
Best to drop the lines.

> +
> +USERADD_PACKAGES = "${PN}"
> +GROUPMEMS_PARAM:${PN} = "--add root --group audio"

Adding root to audio group seems redundant. Best to drop the lines. 

> +
> +do_install() {
> +    if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
> +        install -d ${D}${systemd_system_unitdir}
> +        install -m 0644 ${S}/pulseaudio.service ${D}${systemd_system_unitdir}/
> +    fi
> +}

inherit systemd should also take care of installing the service file [0].
Best to drop the lines. 

[0]: https://docs.yoctoproject.org/ref-manual/classes.html#systemd

Regards
Yogesh
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.