guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#31297] [PATCH] gnu: Add sound service.


From: Ludovic Courtès
Subject: [bug#31297] [PATCH] gnu: Add sound service.
Date: Mon, 30 Apr 2018 22:55:31 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Hello,

Oleg Pykhalov <address@hidden> skribis:

> * gnu/services/sound.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add this.
> * doc/guix.texi (Sound Services): New chapter.

[...]

> address@hidden Sound Services
> address@hidden Sound Services
> +
> +The @code{(gnu services alsa)} module provides an
> address@hidden service to generate an ALSA
> address@hidden/etc/asound.conf} configuration file.

Is this file required to get PulseAudio support?  I realize I have
~/.asoundrc that’s similar to what this new service does, so it may be
that I simply forgot that things wouldn’t work well without it.

> address@hidden {Scheme Variable} alsa-service-type
> +This is the type for the @uref{https://alsa-project.org/, alsa},

s/alsa/ALSA/


> +(define-record-type* <alsa-configuration>
> +  alsa-configuration make-alsa-configuration alsa-configuration?
> +  (pulseaudio?   alsa-configuration-pulseaudio? ;boolean
> +                 (default #t))
> +  (extra-options alsa-configuration-extra-options ;string
> +                 (default #f)))

s/#f/""/ since it’s a string.

> +(define (alsa-config-file config)
> +  "Return the ALSA configuration file corresponding to CONFIG."
> +  (computed-file
> +   "asound.conf"
> +   #~(call-with-output-file #$output
> +       (lambda (port)
> +         (display "# Generated by 'alsa-service'.\n\n" port)
> +         (when #$(alsa-configuration-pulseaudio? config)
> +           (display "# Use PulseAudio by default
> +pcm.!default {
> +  type pulse
> +  fallback \"sysdefault\"
> +  hint {
> +    show on
> +    description \"Default ALSA Output (currently PulseAudio Sound Server)\"
> +  }
> +}
> +
> +ctl.!default {
> +  type pulse
> +  fallback \"sysdefault\"
> +}
> +"
> +                    port))
> +         (let ((extra-options #$(alsa-configuration-extra-options config)))
> +           (when extra-options (display extra-options port)))))))

I think you could instead write:

  (if (alsa-configuration-pulseaudio? config)
      (plain-file "asound.conf" (string-append "# Generated by…" extra-options))
      (plain-file "asound.conf" extra-options))

> +(define (alsa-activation config)
> +  "Return the activation GEXP for CONFIG."
> +  (with-imported-modules '((guix build utils))
> +    #~(begin
> +        (use-modules (guix build utils))
> +        (copy-file #$(alsa-config-file config) "/etc/asound.conf"))))

Please extend ‘etc-service-type’ instead.

> +(define alsa-service-type
> +  (service-type
> +   (name 'alsa)
> +   (extensions
> +    (list (service-extension activation-service-type alsa-activation)))
> +   (default-value (alsa-configuration))
> +   (description "Configure the alsa.")))

“Configure low-level Linux sound support, ALSA.”

Thanks,
Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]