unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: mirai <mirai@makinata.eu>, 59866 <59866@debbugs.gnu.org>
Subject: [bug#59866] Pulseaudio woes
Date: Tue, 03 Jan 2023 20:38:14 +0100	[thread overview]
Message-ID: <8af12f33afa0ef406711e8ed144d49b3e67935c3.camel@gmail.com> (raw)
In-Reply-To: <b381d59b-2278-1a6b-5f93-7b008504d544@makinata.eu>

Am Dienstag, dem 03.01.2023 um 14:43 +0000 schrieb mirai:
> I've found out that this service (even before this patch-set)
> is biased towards being used as a home service rather than a system
> service.
> 
> The reason is that it sets the XDG_RUNTIME_DIR environment variable
> through shepherd
> to:
> 
> --8<---------------cut here---------------start------------->8---
> (list (string-append
>         "XDG_RUNTIME_DIR=/run/user/"
>         (number->string (passwd:uid (getpwnam #$user)))))
> --8<---------------cut here---------------end--------------->8---
> 
> This directory does not exist if this is launched as a system-wide
> service.
> I presume that this went unnoticed because most of the times you'd
> want to use this service system-wide you also configure this either
> as a MPD 'satellite instance' or the audio-outputs are always
> network-streaming ones.
> 
> This falls apart if you configure a system-wide mpd-service with a
> pulseaudio output as it will try to access XDG_RUNTIME_DIR which is
> not created for the system? #t 'mpd' user.
As far as I'm aware, you can instantiate the MPD service system-wide
while also pointing it to a non-system user.  Admittedly, this is a
somewhat degenerate use case, but that's how things were handled before
home services were a thing, and there might still be valid reasons to
support it.

> Now, pulseaudio is usually launched as a 'per-user' daemon although
> it can be used in a system-pulse configuration though this is
> strongly discouraged.
If it is, then XDG_RUNTIME_DIR doesn't matter.

> Under most conditions (pulseaudio config mostly unchanged),
> a system-wide mpd-service-type is also able to launch its own pulse
> instance but due to the inherent assumptions present in the original
> service we have that:
>   - The XDG_RUNTIME_DIR env var is set when it should only be set for
> 'system? #f' users.
>   - PULSE_CLIENTCONFIG and PULSE_CONFIG are not set by shepherd.
>         These usually correspond to:
>           PULSE_CONFIG =/etc/pulse/client.conf
>           PULSE_CONFIG=/etc/pulse/daemon.conf
>         But if you use mpd-service-type as a home service, you could
> also have
>       these set to a user-specific pulse config, which will be
> overridden by shepherd
>       if these are set in mpd-service-type.
>         But again, if you don't set these env vars and use it as a
> systemwide service
>       with a pulseaudio output and you workaround the XDG_RUNTIME_DIR
> by unsetting it,
>       your pulse daemon won't read its config and there will be no
> output.
何?

> This is not just a theoretical issue, consider this snippet:
> 
> --8<---------------cut here---------------start------------->8---
> ;; Set a systemwide mpd service that streams with pulseaudio RTP
> output.
> 
> (service pulseaudio-service-type (pulseaudio-configuration
>                                     (extra-script-files
>                                        (list
>                                          (plain-file
>                                            "rtp.pa"
>                                            (string-join (list "load-
> module module-null-sink sink_name=rtp"
>                                                               "load-
> module module-rtp-send source=rtp.monitor"
>                                                               "set-
> default-sink rtp") "\n" 'suffix))))))
> (service mpd-service-type
>                    (mpd-configuration
>                     (outputs (list (mpd-output (name "Pulseaudio over
> RTP")
>                                      (type "pulse")
>                                      (extra-options '((sink .
> "rtp")))))))
> --8<---------------cut here---------------end--------------->8---
> 
> The problem here is how to conditionally select which environment
> variables should be set based on whether this is being launched as a
> system-wide or home-instance service. I'm all ears for
> suggestions.
I don't think you need to think about the home service too hard here. 
If you can't get the two use cases to work together, you can define a
home-mpd-service-type which takes a regular mpd-configuration or a
particularly crafted home-mpd-configuration, whichever makes more
sense.  Not saying that this would be a good design idea, just that the
option exists.

I do think trying to figure out what you're going to do with your
environment variables is a more worthwhile exercise at the moment.

> Regarding the current patch-set, I'm thinking that some of the non-
> public procedures could be defined with 'define-deprecated' instead
> which should (?) be cleaner than the current
> comments that are demarcating deprecated code.
If they aren't public, what is the point of define-deprecated?  You
will only trip over your own uses.

Cheers

  reply	other threads:[~2023-01-03 19:39 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06 23:22 [bug#59866] [PATCH 0/2] services: mpd: Refactor MPD service mirai
2022-12-06 23:25 ` [bug#59866] [PATCH 1/2] services: mpd: use 'define-configuration' mirai
2022-12-06 23:25 ` [bug#59866] [PATCH 2/2] services: mpd: Refactor MPD service mirai
2022-12-07  8:59 ` [bug#59866] [PATCH 0/2] " ( via Guix-patches via
2022-12-07 13:42   ` mirai
2022-12-07 13:43     ` ( via Guix-patches via
2022-12-07 18:27 ` Liliana Marie Prikler
2022-12-08 13:11   ` mirai
2022-12-08 13:35     ` [bug#54986] " Liliana Marie Prikler
2022-12-09 13:44       ` [bug#59866] " mirai
2022-12-09 19:22         ` Liliana Marie Prikler
2022-12-11 12:05           ` mirai
2022-12-08  0:59 ` [bug#59866] [PATCH v2] " mirai
2022-12-16 14:15 ` [bug#59866] [PATCH v3] " mirai
2022-12-21 14:15 ` [bug#59866] [PATCH v4 1/2] services: mpd: use 'define-configuration' mirai
2022-12-21 14:15   ` [bug#59866] [PATCH v4 2/2] services: mpd: Refactor MPD service mirai
2022-12-24 13:51 ` [bug#59866] [PATCH v5 1/2] services: mpd: rewrite using 'define-configuration' mirai
2022-12-24 13:51   ` [bug#59866] [PATCH v5 2/2] services: mpd: Refactor MPD service mirai
2022-12-24 14:11 ` [bug#59866] [PATCH v5.1] " mirai
2022-12-24 17:20   ` Liliana Marie Prikler
2022-12-24 19:17     ` mirai
2022-12-24 18:53 ` [bug#59866] [PATCH v5.2] " mirai
2023-01-03 14:43 ` [bug#59866] Pulseaudio woes mirai
2023-01-03 19:38   ` Liliana Marie Prikler [this message]
2023-02-02 20:07 ` [bug#59866] [PATCH v6 1/3] services: mpd: Rewrite using 'define-configuration' Bruno Victal
2023-02-02 20:07   ` [bug#59866] [PATCH v6 2/3] services: mpd: Refactor MPD service Bruno Victal
2023-02-02 21:08     ` Liliana Marie Prikler
2023-02-05  6:11       ` bug#59866: " Liliana Marie Prikler
2023-02-02 20:07   ` [bug#59866] [PATCH v6 3/3] services: mpd: Do not hardcode environment variables Bruno Victal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8af12f33afa0ef406711e8ed144d49b3e67935c3.camel@gmail.com \
    --to=liliana.prikler@gmail.com \
    --cc=59866@debbugs.gnu.org \
    --cc=mirai@makinata.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).