gnu: gnu: Make alsa find its plugins by setting ALSA_PLUGIN_DIR.

* gnu/packages/patches/alsa-lib-add-environment-variable.patch: New
file.
* gnu/packages/linux.scm (alsa-lib)[source]: Use it.
[native-search-paths]: Add ALSA_PLUGIN_DIR.
* gnu/local.mk (dist_patch_DATA): Add it.
This commit is contained in:
Julien Lepiller 2018-05-25 19:33:31 +02:00
parent 1640f16e78
commit 2101cc3fb6
No known key found for this signature in database
GPG Key ID: 43111F4520086A0C
3 changed files with 120 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# GNU Guix --- Functional package management for GNU
GNU Guix --- Functional package management for GNU
# Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Andreas Enge <andreas@enge.fr>
# Copyright © 2016 Mathieu Lirzin <mthl@gnu.org>
@ -560,6 +560,7 @@ dist_patch_DATA = \
%D%/packages/patches/aegis-test-fixup-1.patch \
%D%/packages/patches/aegis-test-fixup-2.patch \
%D%/packages/patches/agg-am_c_prototype.patch \
%D%/packages/patches/alsa-lib-add-environment-variable.patch \
%D%/packages/patches/amule-crypto-6.patch \
%D%/packages/patches/ansible-wrap-program-hack.patch \
%D%/packages/patches/antiword-CVE-2014-8123.patch \

View File

@ -974,8 +974,15 @@ intercept and print the system calls executed by the program.")
version ".tar.bz2"))
(sha256
(base32
"096pwrnhj36yndldvs2pj4r871zhcgisks0is78f1jkjn9sd4b2z"))))
"096pwrnhj36yndldvs2pj4r871zhcgisks0is78f1jkjn9sd4b2z"))
(patches (search-patches "alsa-lib-add-environment-variable.patch"))))
(build-system gnu-build-system)
(native-search-paths
(list (search-path-specification
(variable "ALSA_PLUGIN_DIR")
(file-type 'regular)
(separator #f) ;single entry
(files '("lib/alsa-lib")))))
(home-page "https://www.alsa-project.org/")
(synopsis "The Advanced Linux Sound Architecture libraries")
(description

View File

@ -0,0 +1,110 @@
From 1822fb453128a1b5de93b4c590cd272d6488a077 Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Fri, 25 May 2018 19:26:58 +0200
Subject: [PATCH] Add support for a ALSA_PLUGIN_DIR environment variable.
If it is not set, default to previous behavior.
---
src/control/control.c | 6 +++++-
src/dlmisc.c | 9 +++++++--
src/pcm/pcm.c | 9 +++++++--
src/pcm/pcm_rate.c | 13 +++++++++----
4 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/src/control/control.c b/src/control/control.c
index 11f7815..9dba7dd 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -1331,7 +1331,11 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
build_in++;
}
if (*build_in == NULL) {
- buf1 = malloc(strlen(str) + sizeof(ALSA_PLUGIN_DIR) + 32);
+ char* plugdir = ALSA_PLUGIN_DIR;
+ char* envplugdir = getenv("ALSA_PLUGIN_DIR");
+ if(envplugdir != NULL)
+ plugdir = envplugdir;
+ buf1 = malloc(strlen(str) + strlen(plugdir) + 32);
if (buf1 == NULL) {
err = -ENOMEM;
goto _err;
diff --git a/src/dlmisc.c b/src/dlmisc.c
index 3757d33..92aa864 100644
--- a/src/dlmisc.c
+++ b/src/dlmisc.c
@@ -82,9 +82,14 @@ void *snd_dlopen(const char *name, int mode, char *errbuf, size_t errbuflen)
char *filename = NULL;
if (name && name[0] != '/') {
- filename = alloca(sizeof(ALSA_PLUGIN_DIR) + 1 + strlen(name) + 1);
+ char* plugdir = ALSA_PLUGIN_DIR;
+ char* envplugdir = getenv("ALSA_PLUGIN_DIR");
+ if(envplugdir != NULL)
+ plugdir = envplugdir;
+
+ filename = malloc(strlen(plugdir) + 1 + strlen(name) + 1);
if (filename) {
- strcpy(filename, ALSA_PLUGIN_DIR);
+ strcpy(filename, plugdir);
strcat(filename, "/");
strcat(filename, name);
handle = dlopen(filename, mode);
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 11aec80..590e8b6 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -2496,13 +2496,18 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
build_in++;
}
if (*build_in == NULL) {
- buf1 = malloc(strlen(str) + sizeof(ALSA_PLUGIN_DIR) + 32);
+ char* plugdir = ALSA_PLUGIN_DIR;
+ char* envplugdir = getenv("ALSA_PLUGIN_DIR");
+ if(envplugdir != NULL)
+ plugdir = envplugdir;
+ buf1 = malloc(strlen(str) + strlen(plugdir) + 32);
+
if (buf1 == NULL) {
err = -ENOMEM;
goto _err;
}
lib = buf1;
- sprintf(buf1, "%s/libasound_module_pcm_%s.so", ALSA_PLUGIN_DIR, str);
+ sprintf(buf1, "%s/libasound_module_pcm_%s.so", plugdir, str);
}
}
#ifndef PIC
diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c
index 4e0c7ca..8694a38 100644
--- a/src/pcm/pcm_rate.c
+++ b/src/pcm/pcm_rate.c
@@ -1260,7 +1260,8 @@ static const char *const default_rate_plugins[] = {
static int rate_open_func(snd_pcm_rate_t *rate, const char *type, const snd_config_t *converter_conf, int verbose)
{
- char open_name[64], open_conf_name[64], lib_name[128], *lib = NULL;
+ char open_name[64], open_conf_name[64], *lib = NULL;
+ char *buf1;
snd_pcm_rate_open_func_t open_func;
snd_pcm_rate_open_conf_func_t open_conf_func;
int err;
@@ -1268,9 +1269,13 @@ static int rate_open_func(snd_pcm_rate_t *rate, const char *type, const snd_conf
snprintf(open_name, sizeof(open_name), "_snd_pcm_rate_%s_open", type);
snprintf(open_conf_name, sizeof(open_conf_name), "_snd_pcm_rate_%s_open_conf", type);
if (!is_builtin_plugin(type)) {
- snprintf(lib_name, sizeof(lib_name),
- "%s/libasound_module_rate_%s.so", ALSA_PLUGIN_DIR, type);
- lib = lib_name;
+ char* plugdir = ALSA_PLUGIN_DIR;
+ char* envplugdir = getenv("ALSA_PLUGIN_DIR");
+ if(envplugdir != NULL)
+ plugdir = envplugdir;
+ buf1 = malloc(strlen(type) + strlen(plugdir) + 32);
+ sprintf(buf1, "%s/libasound_module_rate_%s.so", plugdir, type);
+ lib = buf1;
}
rate->rate_min = SND_PCM_PLUGIN_RATE_MIN;
--
2.17.0