all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#38172: fixing dangerous PulseAudio defaults and giving it a record type
@ 2019-11-12  1:39 Leo Prikler
  2019-11-11 21:09 ` raingloom
  0 siblings, 1 reply; 9+ messages in thread
From: Leo Prikler @ 2019-11-12  1:39 UTC (permalink / raw)
  To: raingloom; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1139 bytes --]

Being the one who suggested record types, I came up with a quick and
dirty solution.  I have no idea, whether this works yet -- I only ran
guix system build to check whether files are actually put in /etc.  I
don't know, whether PulseAudio will actually read this file or rather
use the one in its own package.

This solution mimics ALSA's "extra-options" field, which allows direct
writing of ALSA "options".  I've decided, that strings best be
concatenated with newlines, and lists with two entries are key-value
pairs.  This structure allows for an easy writing of the two most used
constructs in such files; free-form comments and assignments.

The above applies to both client.conf and daemon.conf.  Ideally, I'd
like to replace them with their own records, but that's for another
day.  default.pa and system.pa are actually scripts, so I just use
mixed-text-file to concatenate user input.   Since an empty script is
probably not useful, they're symlinked to the package files by default.

Let me know if that patch works for you.  Also let me know if my design
choices are weird to you, I'm open to other approaches.

Regards,

Leo

[-- Attachment #2: 0001-services-Add-PulseAudio-service.patch --]
[-- Type: text/x-patch, Size: 3094 bytes --]

From d48594a3e7e02aef0c5ff9fff719c1d0fb45207e Mon Sep 17 00:00:00 2001
From: Leo Prikler <leo.prikler@student.tugraz.at>
Date: Tue, 12 Nov 2019 02:08:40 +0100
Subject: [PATCH] services: Add PulseAudio service

* gnu/services/sound.scm: (<pulseaudio-configuration>): New record type.
(pulseaudio-service-type): New service type.
---
 gnu/services/sound.scm | 58 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/gnu/services/sound.scm b/gnu/services/sound.scm
index f2dd24402f..2aedc03c75 100644
--- a/gnu/services/sound.scm
+++ b/gnu/services/sound.scm
@@ -30,7 +30,9 @@
   #:use-module (gnu packages pulseaudio)
   #:use-module (ice-9 match)
   #:export (alsa-configuration
-            alsa-service-type))
+            alsa-service-type
+            pulseaudio-configuration
+            pulseaudio-service-type))
 
 ;;; Commentary:
 ;;;
@@ -97,4 +99,58 @@ ctl.!default {
    (default-value (alsa-configuration))
    (description "Configure low-level Linux sound support, ALSA.")))
 
+\f
+;;;
+;;; PulseAudio
+;;;
+
+(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))))
+  (default-script pulseaudio-default-script (default #f))
+  (system-script pulseaudio-system-script (default #f)))
+
+(define (pulseaudio-conf-entry arg)
+  (match arg
+    ((key value)
+     (format #f "~a = ~a~%" key value))
+    ((? string? _)
+     (string-append arg "\n"))))
+
+(define pulseaudio-etc-service
+  (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 default-script
+                    (apply mixed-text-file "system.pa"
+                           system-script)
+                    (file-append package "/etc/pulse/system.pa")))))))))))
+
+(define pulseaudio-service-type
+  (service-type
+   (name 'pulseaudio)
+   (extensions
+    (list (service-extension etc-service-type pulseaudio-etc-service)))
+   (default-value (pulseaudio-configuration))
+   (description "Configure PulseAudio.")))
+
 ;;; sound.scm ends here
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread
* WebkitGTK-based browsers: System volume suddenly maxed out when playing audio or video
@ 2020-01-06 18:02 Alek Zikon
  2020-01-07  6:07 ` bug#38172: " raingloom
  0 siblings, 1 reply; 9+ messages in thread
From: Alek Zikon @ 2020-01-06 18:02 UTC (permalink / raw)
  To: help-guix@gnu.org

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-01-11 16:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-12  1:39 bug#38172: fixing dangerous PulseAudio defaults and giving it a record type Leo Prikler
2019-11-11 21:09 ` raingloom
2019-11-12 11:00   ` Leo Prikler
2020-01-09  1:22   ` bug#38172: WebkitGTK-based browsers: System volume suddenly maxed out when playing audio or video Leo Prikler
2020-01-09 20:48     ` Marius Bakke
2020-01-09 22:49       ` Leo Prikler
2020-01-09 22:49         ` [bug#39053] " Leo Prikler
2020-01-11 16:48         ` Marius Bakke
  -- strict thread matches above, loose matches on Subject: below --
2020-01-06 18:02 Alek Zikon
2020-01-07  6:07 ` bug#38172: " raingloom

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.