all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 9d122079ee5e22ffbaff9272408369e9d410c570 4066 bytes (raw)
name: gnu/packages/patches/alsa-lib-add-environment-variable.patch 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
 
From 51523b7d546ade002b0bc999b2e01f9593e8576d Mon Sep 17 00:00:00 2001
From: Julien Lepiller <julien@lepiller.eu>
Date: Fri, 22 Jun 2018 13:50:45 +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 |  8 ++++++--
 src/dlmisc.c          |  9 +++++++--
 src/pcm/pcm.c         |  9 +++++++--
 src/pcm/pcm_rate.c    | 13 +++++++++----
 4 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/src/control/control.c b/src/control/control.c
index 11f7815..920b1af 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -1331,13 +1331,17 @@ 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;
 			}
 			lib = buf1;
-			sprintf(buf1, "%s/libasound_module_ctl_%s.so", ALSA_PLUGIN_DIR, str);
+			sprintf(buf1, "%s/libasound_module_ctl_%s.so", plugdir, str);
 		}
 	}
 #ifndef PIC
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.14.4


debug log:

solving 9d122079e ...
found 9d122079e in https://yhetil.org/guix/c71cf82da0aa0f2e91a8ac616eea5013@lepiller.eu/
found a468a7fc4 in https://git.savannah.gnu.org/cgit/guix.git
preparing index
index prepared:
100644 a468a7fc4f75ca3d0960d8d5e4be275a9c6671b2	gnu/packages/patches/alsa-lib-add-environment-variable.patch

applying [1/1] https://yhetil.org/guix/c71cf82da0aa0f2e91a8ac616eea5013@lepiller.eu/
diff --git a/gnu/packages/patches/alsa-lib-add-environment-variable.patch b/gnu/packages/patches/alsa-lib-add-environment-variable.patch
index a468a7fc4..9d122079e 100644

1:37: space before tab in indent.
 			}
1:38: space before tab in indent.
 			lib = buf1;
1:41: space before tab in indent.
 		}
1:42: space before tab in indent.
 	}
Checking patch gnu/packages/patches/alsa-lib-add-environment-variable.patch...
Applied patch gnu/packages/patches/alsa-lib-add-environment-variable.patch cleanly.
warning: 4 lines add whitespace errors.

index at:
100644 9d122079ee5e22ffbaff9272408369e9d410c570	gnu/packages/patches/alsa-lib-add-environment-variable.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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.