GNU bug report logs - #38172
fixing dangerous PulseAudio defaults and giving it a record type

Previous Next

Package: guix;

Reported by: raingloom <raingloom <at> riseup.net>

Date: Mon, 11 Nov 2019 21:11:02 UTC

Severity: normal

Done: Marius Bakke <mbakke <at> fastmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38172 in the body.
You can then email your comments to 38172 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#38172; Package guix. (Mon, 11 Nov 2019 21:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to raingloom <raingloom <at> riseup.net>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Mon, 11 Nov 2019 21:11:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: raingloom <raingloom <at> riseup.net>
To: bug-guix <at> gnu.org
Subject: fixing dangerous PulseAudio defaults and giving it a record type
Date: Mon, 11 Nov 2019 22:09:41 +0100
Discussion from IRC:
http://logs.guix.gnu.org/guix/2019-11-11.log#213424

Basically it makes volume settings behave in erratic and surprising
ways that are not obvious even to seasoned Linux users, including
sudden loud noises.

The fix is as simple as adding "flat-volumes = no"
to .config/pulse/daemon.conf, but this should really be a system
default.

However, rather than patching it, the consensus seems to be that we
should create a <pulseaudio-configuration> record type.
http://logs.guix.gnu.org/guix/2019-11-11.log#213953




Information forwarded to bug-guix <at> gnu.org:
bug#38172; Package guix. (Tue, 12 Nov 2019 11:01:01 GMT) Full text and rfc822 format available.

Message #8 received at 38172 <at> debbugs.gnu.org (full text, mbox):

From: Leo Prikler <leo.prikler <at> student.tugraz.at>
To: 38172 <at> debbugs.gnu.org
Subject: bug#38172: fixing dangerous PulseAudio defaults and giving it a
 record type
Date: Tue, 12 Nov 2019 12:00:40 +0100
[Message part 1 (text/plain, inline)]

[0001-services-Add-PulseAudio-service.patch (text/x-patch, attachment)]

Information forwarded to bug-guix <at> gnu.org:
bug#38172; Package guix. (Tue, 07 Jan 2020 06:08:01 GMT) Full text and rfc822 format available.

Message #11 received at 38172 <at> debbugs.gnu.org (full text, mbox):

From: raingloom <raingloom <at> riseup.net>
To: Alek Zikon <lekzikon <at> protonmail.com>, "help-guix <at> gnu.org"
 <help-guix <at> gnu.org>
Cc: 38172 <at> debbugs.gnu.org
Subject: Re: WebkitGTK-based browsers: System volume suddenly maxed out when
 playing audio or video
Date: Tue, 07 Jan 2020 07:07:20 +0100
On Mon, 2020-01-06 at 18:02 +0000, Alek Zikon wrote:
> Everytime audio or video starts playing on WebkitGTK-based browsers
> (epiphany, next), the system volume is maxed out. This happens when
> you start the audio or video by clicking on the play button and also
> when audio or videos are played automatically (in a playlist, or ad
> videos, for example).
> 
> This issue has been reported before upstream, but epiphany people say
> the source of the problem is in pulsaudio defaults on distros (
> https://gitlab.gnome.org/GNOME/epiphany/issues/73):
> 
>   Thanks for reporting this issue. You'll need to ask Debian to
> disable
>   PulseAudio's flat volumes feature, as is done by all other major
>   distributions (Ubuntu, Arch, Fedora, openSUSE, probably more),
>   since we're not going to make any changes here.
> 
> I found that there is a related pulsaudio bug reported on Guix (
> https://issues.guix.gnu.org/issue/38172). Unfortunately, this issue
> is still open.
> 
> Epiphany people say you, as a user, can work around the issue by
> setting "flat-volumes = no in your /etc/pulse/daemon.conf." What's
> the correct way to this on the Guix System?
> 
> 
> I'm using this software:
> 
> epiphany 3.30.4
> WebKitGTK+ 2.26.1
> GNOME 3.30.2
> 
> $ guix describe
> Generation 16	Jan 03 2020 14:36:37	(current)
>   guix 7158fe4
>     repository URL: https://git.savannah.gnu.org/git/guix.git
>     branch: master
>     commit: 7158fe4ded47a599ceb8d556132ba83fcc686962
> 
CC-ing https://issues.guix.gnu.org/issue/38172





Information forwarded to bug-guix <at> gnu.org:
bug#38172; Package guix. (Thu, 09 Jan 2020 01:23:02 GMT) Full text and rfc822 format available.

Message #14 received at 38172 <at> debbugs.gnu.org (full text, mbox):

From: Leo Prikler <leo.prikler <at> student.tugraz.at>
To: raingloom <at> riseup.net
Cc: 38172 <at> debbugs.gnu.org
Subject: bug#38172: WebkitGTK-based browsers: System volume suddenly maxed
 out when playing audio or video
Date: Thu, 09 Jan 2020 02:22:23 +0100
[Message part 1 (text/plain, inline)]
Hi Guix,

After looking at my older patch (which no longer cleanly applies), I've
noticed, that pulseaudio doesn't even read the files from /etc.  This
is troublesome in multiple ways.  For one, pulseaudio causes >500
rebuilds (with >900 dependent packages) and is therefore staging
material, for the other, hardcoding /etc in such a way breaks
pulseaudio without the service.

So far, I've only tested containers via `guix environment --container`, 
but from what I can gather with strace, the config file is indeed read
and hence flat-volumes are eliminated.  Other ways of making pulseaudio
accept /etc are very welcome.  Looking at Nix, they configure
pulseaudio with "--sysconfdir=/etc", but then override sysconfdir and
pulseconfdir during install.  I'm not quite sure which solution is
"better", but neither is going to read the config shipped with the
package.

Note: before this can be applied on staging,
a66ee82a05d8ff1ef7c5ff9ac7723cb32fc4e22a needs to be applied.

Regards,
Leo


[0001-services-Add-pulseaudio-configuration.patch (text/x-patch, attachment)]
[0002-gnu-pulseaudio-Honor-etc.patch (text/x-patch, attachment)]
[0003-services-Add-pulseaudio-to-desktop-services.patch (text/x-patch, attachment)]

Information forwarded to bug-guix <at> gnu.org:
bug#38172; Package guix. (Thu, 09 Jan 2020 20:49:01 GMT) Full text and rfc822 format available.

Message #17 received at 38172 <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>, raingloom <at> riseup.net
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>, 38172 <at> debbugs.gnu.org
Subject: Re: bug#38172: WebkitGTK-based browsers: System volume suddenly maxed
 out when playing audio or video
Date: Thu, 09 Jan 2020 21:48:12 +0100
[Message part 1 (text/plain, inline)]
Leo,

Leo Prikler <leo.prikler <at> student.tugraz.at> writes:

> Hi Guix,
>
> After looking at my older patch (which no longer cleanly applies), I've
> noticed, that pulseaudio doesn't even read the files from /etc.  This
> is troublesome in multiple ways.  For one, pulseaudio causes >500
> rebuilds (with >900 dependent packages) and is therefore staging
> material, for the other, hardcoding /etc in such a way breaks
> pulseaudio without the service.
>
> So far, I've only tested containers via `guix environment --container`, 
> but from what I can gather with strace, the config file is indeed read
> and hence flat-volumes are eliminated.  Other ways of making pulseaudio
> accept /etc are very welcome.  Looking at Nix, they configure
> pulseaudio with "--sysconfdir=/etc", but then override sysconfdir and
> pulseconfdir during install.  I'm not quite sure which solution is
> "better", but neither is going to read the config shipped with the
> package.
>
> Note: before this can be applied on staging,
> a66ee82a05d8ff1ef7c5ff9ac7723cb32fc4e22a needs to be applied.

Thank you for these patches.  Overall it LGTM.

[...]

> From bf4708923d14356c87daec69209b30aa0427d64f Mon Sep 17 00:00:00 2001
> From: Leo Prikler <leo.prikler <at> student.tugraz.at>
> Date: Wed, 8 Jan 2020 19:50:51 +0100
> Subject: [PATCH 1/3] services: Add pulseaudio-configuration.
>
> * gnu/services/sound (<pulseaudio-configuration>): New record.
> (pulseaudio-etc): New procedure.
> (pulseaudio-service-type): Update accordingly.

[...]

> +(define-record-type* <pulseaudio-configuration>
> +  pulseaudio-configuration make-pulseaudio-configuration
> +  pulseaudio-configuration?
> +  (package pulseaudio-package (default pulseaudio))
> +  (client-conf pulseaudio-client-conf (default '()))
> +  (daemon-conf pulseaudio-daemon-conf (default '((flat-volumes no))))

I have a preference for making this field empty initially to have a 1:1
compatibility with the current PA client and daemon configuration
(i.e. nothing).  Then a follow-up patch can add this new configuration,
perhaps with an explaining comment.

> +  (default-script pulseaudio-default-script (default #f))
> +  (system-script pulseaudio-system-script (default #f)))
> +
>  (define (pulseaudio-environment config)
>    ;; Define this variable in the global environment such that
>    ;; pulseaudio swh-plugins works.
>    `(("LADSPA_PATH"
>       . ,(file-append swh-plugins "/lib/ladspa"))))
>  
> +(define (pulseaudio-conf-entry arg)
> +  (match arg
> +    ((key value)
> +     (format #f "~a = ~s~%" key value))
> +    ((? string? _)
> +     (string-append arg "\n"))))
> +
> +(define pulseaudio-etc
> +  (match-lambda
> +    (($ <pulseaudio-configuration> package client-conf daemon-conf
> +                                   default-script system-script)
> +     (let ((default.pa (if default-script
> +                           (apply mixed-text-file "default.pa"
> +                                  default-script)
> +                           (file-append package "/etc/pulse/default.pa"))))
> +       `(("pulse"
> +          ,(file-union
> +            "pulse"
> +            `(("client.conf"
> +               ,(apply mixed-text-file "client.conf"
> +                       (map pulseaudio-conf-entry client-conf)))
> +              ("daemon.conf"
> +               ,(apply mixed-text-file "daemon.conf"
> +                       "default-script-file = " default.pa "\n"
> +                       (map pulseaudio-conf-entry daemon-conf)))
> +              ("default.pa" ,default.pa)
> +              ("system.pa"
> +               ,(if system-script
> +                    (apply mixed-text-file "system.pa"
> +                           system-script)
> +                    (file-append package "/etc/pulse/system.pa")))))))))))
> +

Does it make sense to have default-script and system-script default to
(file-append pulseaudio "...") and avoid the conditional altogether?

[...]

> From 843d3968db990b5b7ff3f618db5847f83b999cb8 Mon Sep 17 00:00:00 2001
> From: Leo Prikler <leo.prikler <at> student.tugraz.at>
> Date: Thu, 9 Jan 2020 01:24:09 +0100
> Subject: [PATCH 2/3] gnu: pulseaudio: Honor /etc.
>
> * gnu/packages/pulseaudio.scm (pulseaudio) [phases]:
> Set PA_DEFAULT_CONFIG_DIR to "/etc/pulse".

This means pulseaudio will start looking in /etc/pulse for configuration
files on foreign distributions too, right?

I wonder if there is better way to give it configuration files.  Perhaps
by patching the D-Bus service files?  Not a blocker for this series, but
something to consider in case /etc/pulse causes trouble.

[...]

> +                 (add-after 'configure 'hardcode-default-config-dir
> +                   (lambda _
> +                     (substitute* "config.h"
> +                       (("(#define PA_DEFAULT_CONFIG_DIR).*$" all prefix)
> +                        (string-append prefix " \"/etc/pulse\"")))))

End on #t.

[...]

> From e24016f9a44a113847dd937ac47ab4bdb960236d Mon Sep 17 00:00:00 2001
> From: Leo Prikler <leo.prikler <at> student.tugraz.at>
> Date: Thu, 9 Jan 2020 01:29:13 +0100
> Subject: [PATCH 3/3] services: Add pulseaudio to %desktop-services.
>
> * gnu/services/desktop.scm (%desktop-services): Add pulseaudio service.

This will pull in "swh-plugins" which was the original intention behind
pulseaudio-service before this patch series.  Before adding it to
%desktop-services, I would prefer if the pulseaudio environment
configuration could be made modular, so that there are no configuration
differences for end users, i.e. they'd have to actively enable the
LADSPA plugin.

I'm not sure what the best approach would be though.  Ideas, Oleg?

As a final note, can you also update doc/guix.texi accordingly?

TIA,
Marius
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#38172; Package guix. (Thu, 09 Jan 2020 22:50:02 GMT) Full text and rfc822 format available.

Message #20 received at 38172 <at> debbugs.gnu.org (full text, mbox):

From: Leo Prikler <leo.prikler <at> student.tugraz.at>
To: Marius Bakke <mbakke <at> fastmail.com>, raingloom <at> riseup.net
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>, 39053 <at> debbugs.gnu.org,
 38172 <at> debbugs.gnu.org
Subject: Re: bug#38172: WebkitGTK-based browsers: System volume suddenly
 maxed out when playing audio or video
Date: Thu, 09 Jan 2020 23:49:17 +0100
Am Donnerstag, den 09.01.2020, 21:48 +0100 schrieb Marius Bakke:
> 
> I have a preference for making this field empty initially to have a
> 1:1
> compatibility with the current PA client and daemon configuration
> (i.e. nothing).  Then a follow-up patch can add this new
> configuration,
> perhaps with an explaining comment.
Fair enough.  This would mean I'd have to split 0001 into two, but
okay.

> Does it make sense to have default-script and system-script default
> to
> (file-append pulseaudio "...") and avoid the conditional altogether?
The idea behind it was to have the script itself in the code rather
than asking users to construct a mixed-text-file, but I'm fine either
way.

> This means pulseaudio will start looking in /etc/pulse for
> configuration
> files on foreign distributions too, right?
> 
> I wonder if there is better way to give it configuration
> files.  Perhaps
> by patching the D-Bus service files?  Not a blocker for this series,
> but
> something to consider in case /etc/pulse causes trouble.
This is already addressed by the renewed series I sent to guix-patches. 
I know you already found that, but I'd like to repeat it for those who
thus far have only read this thread.

> End on #t.
As above, but thanks for the hint, I missed the warning it seems.

> [...]
> 
> > From e24016f9a44a113847dd937ac47ab4bdb960236d Mon Sep 17 00:00:00
> > 2001
> > From: Leo Prikler <leo.prikler <at> student.tugraz.at>
> > Date: Thu, 9 Jan 2020 01:29:13 +0100
> > Subject: [PATCH 3/3] services: Add pulseaudio to %desktop-services.
> > 
> > * gnu/services/desktop.scm (%desktop-services): Add pulseaudio
> > service.
> 
> This will pull in "swh-plugins" which was the original intention
> behind
> pulseaudio-service before this patch series.  Before adding it to
> %desktop-services, I would prefer if the pulseaudio environment
> configuration could be made modular, so that there are no
> configuration
> differences for end users, i.e. they'd have to actively enable the
> LADSPA plugin.
I think adding a field ladspa-plugins, which accepts a list of packages
and adds their "lib/ladspa" would be the right approach here, but I
also feel, that this perhaps deserves its own service unrelated to
pulseaudio.  WDYT?
Either way, I agree on the "having to actively enable" part. 

> As a final note, can you also update doc/guix.texi accordingly?
I will once I've figured out how to best handle these fields.

Regards,
Leo





Information forwarded to bug-guix <at> gnu.org:
bug#38172; Package guix. (Sat, 11 Jan 2020 16:49:01 GMT) Full text and rfc822 format available.

Message #23 received at 38172 <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>, raingloom <at> riseup.net
Cc: Oleg Pykhalov <go.wigust <at> gmail.com>, 39053 <at> debbugs.gnu.org,
 38172 <at> debbugs.gnu.org
Subject: Re: bug#38172: WebkitGTK-based browsers: System volume suddenly maxed
 out when playing audio or video
Date: Sat, 11 Jan 2020 17:48:01 +0100
[Message part 1 (text/plain, inline)]
Leo Prikler <leo.prikler <at> student.tugraz.at> writes:

> Am Donnerstag, den 09.01.2020, 21:48 +0100 schrieb Marius Bakke:
>> 
>> I have a preference for making this field empty initially to have a
>> 1:1
>> compatibility with the current PA client and daemon configuration
>> (i.e. nothing).  Then a follow-up patch can add this new
>> configuration,
>> perhaps with an explaining comment.
> Fair enough.  This would mean I'd have to split 0001 into two, but
> okay.

Excellent.  :-)

>> Does it make sense to have default-script and system-script default
>> to
>> (file-append pulseaudio "...") and avoid the conditional altogether?
> The idea behind it was to have the script itself in the code rather
> than asking users to construct a mixed-text-file, but I'm fine either
> way.

Right.  I just have a preference for the default being "up-front",
instead of magic hiding behind an #f.  :-)

There's also LOCAL-FILE and PLAIN-FILE, which are more "obvious" than
MIXED-TEXT-FILE.

It could be useful to support plain strings for users who don't wish to
much about with G-expressions though, hopefully users will send a bug
report if they find it limiting.
[signature.asc (application/pgp-signature, inline)]

Reply sent to Marius Bakke <mbakke <at> fastmail.com>:
You have taken responsibility. (Sat, 11 Jan 2020 17:24:01 GMT) Full text and rfc822 format available.

Notification sent to raingloom <raingloom <at> riseup.net>:
bug acknowledged by developer. (Sat, 11 Jan 2020 17:24:01 GMT) Full text and rfc822 format available.

Message #28 received at 38172-done <at> debbugs.gnu.org (full text, mbox):

From: Marius Bakke <mbakke <at> fastmail.com>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>, 39053-done <at> debbugs.gnu.org
Cc: 38172-done <at> debbugs.gnu.org
Subject: Re: [bug#39053] [PATCH] Add pulseaudio configuration and fix volume
 bugs
Date: Sat, 11 Jan 2020 18:23:26 +0100
[Message part 1 (text/plain, inline)]
Leo Prikler <leo.prikler <at> student.tugraz.at> writes:

> This series of patches adds a configuration type for pulseaudio and also fixes
> a bug, where various applications would inadvertently max out the system volume
> (see e.g. #38172).

Thanks!  I've pushed the patches with mentioned tweaks in
2c7511fb6..71e33e32f.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#38172; Package guix. (Sat, 11 Jan 2020 18:38:02 GMT) Full text and rfc822 format available.

Message #31 received at 38172-done <at> debbugs.gnu.org (full text, mbox):

From: Leo Prikler <leo.prikler <at> student.tugraz.at>
To: Marius Bakke <mbakke <at> fastmail.com>, 39053-done <at> debbugs.gnu.org
Cc: 38172-done <at> debbugs.gnu.org
Subject: Re: [bug#39053] [PATCH] Add pulseaudio configuration and fix volume
 bugs
Date: Sat, 11 Jan 2020 19:37:54 +0100
Am Samstag, den 11.01.2020, 18:23 +0100 schrieb Marius Bakke:
> Leo Prikler <leo.prikler <at> student.tugraz.at> writes:
> 
> > This series of patches adds a configuration type for pulseaudio and
> > also fixes
> > a bug, where various applications would inadvertently max out the
> > system volume
> > (see e.g. #38172).
> 
> Thanks!  I've pushed the patches with mentioned tweaks in
> 2c7511fb6..71e33e32f.
Thanks!  Also, I'm sorry about accidentally opening like 10 bugs due to
my misconfiguration there.  I only noticed after the fact, that merely
CC'ing the original bug does nothing, when the mail is still sent to
guix-patches as well.  I've learned my lesson and will be more careful
in the future.

I do still have some open questions, though.
> > +In addition to the above, @code{default-script-file} will be set to
> > the
> > +value of @code{script-file}.  By default, @var{flat-volumes} is
> > set
> > to
> > +``no'', so as to avoid bugs related to this feature.
> > 
> The first sentence of this paragraph is obsolete, no?  The second is
> rather vague, so I opted to remove the whole thing.  Let me know if
> you
> think something should be added!
I'm not quite sure about the first sentence.  While everyone can read
the code and the output files produced from it, I think we should
document, that we actually always insert this line into
@file{daemon.conf}.
For instance, if you don't supply your own @file{default.pa}, the first
line of @file{daemon.conf} will be
--8<---------------cut here---------------start------------->8---
default-script-file = /gnu/store/<hash>-pulseaudio-
<version>/etc/pulse/default.pa
--8<---------------cut here---------------end--------------->8---
What are your thoughts on this?

> I added a (default: ...) on these two and removed the related
> sentences.
I was hesitant to do that due to the line limits.  Do those not count
for documentation or are such exceptions allowed?

Thanks again for your help and also thanks for your feedback.

Regards,
Leo





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 09 Feb 2020 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 49 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.