unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
blob 7ca6b7960a19d3325b8f08f018cd561ff25ef375 5527 bytes (raw)
name: gnu/packages/patches/alsa-lib.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
 
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 74d1d1a..17ffb12 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -2042,6 +2042,19 @@ static const char *const build_in_pcms[] = {
 	NULL
 };
 
+
+// helper funcion used below
+int file_exists(const char * filename)
+{
+	FILE * file;
+	if (file = fopen(filename, "r"))
+	{
+		fclose(file);
+		return 1;
+	}
+	return 0;
+}
+
 static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
 			     snd_config_t *pcm_root, snd_config_t *pcm_conf,
 			     snd_pcm_stream_t stream, int mode)
@@ -2141,8 +2154,38 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
 				err = -ENOMEM;
 				goto _err;
 			}
-			lib = buf1;
 			sprintf(buf1, "%s/libasound_module_pcm_%s.so", ALSA_PLUGIN_DIR, str);
+			if (!file_exists(buf1)){
+				// try to locate plugin in one of ALSA_PLUGIN_DIRS which is colon separated list of paths
+				char * pdirs = getenv("ALSA_PLUGIN_DIRS");
+
+				if (pdirs){ // env var set?
+					char * saveptr;
+					while (1) {
+						char * dir_tok = strtok_r(pdirs, "::::", &saveptr); // "::::" to work around bug in glibc and -O2 ? ":" seems to cause a segfault
+						if (dir_tok == NULL)
+                            break;
+						char * so_file = malloc(strlen(str) + strlen(dir_tok) + 32);
+						if (so_file == NULL) {
+							err = -ENOMEM;
+							goto _err;
+						}
+
+						sprintf(so_file, "%s/libasound_module_pcm_%s.so", dir_tok, str);
+
+						if (file_exists(so_file)){
+
+							free(buf1);
+							buf1 = so_file;
+							break;
+						} else {
+							free (so_file);
+						}
+						pdirs = NULL;
+					}
+				}
+			}
+			lib = buf1;
 		}
 	}
 #ifndef PIC


diff --git a/src/control/control.c b/src/control/control.c
index c090797..137fe57 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -854,8 +854,38 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
 				err = -ENOMEM;
 				goto _err;
 			}
+			sprintf(buf1, "%s/libasound_module_pcm_%s.so", ALSA_PLUGIN_DIR, str);
+			if (!file_exists(buf1)){
+				// try to locate plugin in one of ALSA_PLUGIN_DIRS which is colon separated list of paths
+				char * pdirs = getenv("ALSA_PLUGIN_DIRS");
+
+				if (pdirs){ // env var set?
+					char * saveptr;
+					while (1) {
+						char * dir_tok = strtok_r(pdirs, "::::", &saveptr); // "::::" to work around bug in glibc and -O2 ? ":" seems to cause a segfault
+						if (dir_tok == NULL)
+                            break;
+						char * so_file = malloc(strlen(str) + strlen(dir_tok) + 32);
+						if (so_file == NULL) {
+							err = -ENOMEM;
+							goto _err;
+						}
+
+						sprintf(so_file, "%s/libasound_module_ctl_%s.so", dir_tok, str);
+
+						if (file_exists(so_file)){
+
+							free(buf1);
+							buf1 = so_file;
+							break;
+						} else {
+							free (so_file);
+						}
+						pdirs = NULL;
+					}
+				}
+			}
 			lib = buf1;
-			sprintf(buf1, "%s/libasound_module_ctl_%s.so", ALSA_PLUGIN_DIR, str);
 		}
 	}
 #ifndef PIC
diff --git a/src/dlmisc.c b/src/dlmisc.c
index 8c8f3ff7..274d4b84 100644
--- a/src/dlmisc.c
+++ b/src/dlmisc.c
@@ -82,19 +82,52 @@ 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);
-		if (filename) {
-			strcpy(filename, ALSA_PLUGIN_DIR);
-			strcat(filename, "/");
-			strcat(filename, name);
-			handle = dlopen(filename, mode);
-			if (!handle) {
-				/* if the filename exists and cannot be opened */
-				/* return immediately */
-				if (access(filename, X_OK) == 0)
-					goto errpath;
+                // 'name' is the full library.so name, e.g. libasound_module_conf_pulse.so
+		fprintf(stderr, "XXX name is %s\n", name);
+		char * plugindirs = getenv("ALSA_PLUGIN_DIRS");
+		fprintf(stderr, "XXX plugindirs are %s\n" ,plugindirs);
+		if (plugindirs) {
+			char * saveptr;
+			while (1) {
+				// See comment in src/control/control.c about "::::"
+				char * dir_tok = strtok_r(plugindirs, "::::", &saveptr);
+				if (dir_tok == NULL)
+					break;
+				fprintf(stderr, "XXX dir token is %s\n" ,dir_tok);
+				char * so_file = malloc(strlen(name) + strlen(dir_tok) + 32);
+				sprintf(so_file, "%s/%s" ,dir_tok, name);
+				// TODO Check if so_file == NULL here
+				if (file_exists(so_file)) {
+					fprintf(stderr, "XXX Found the library %s\n" ,so_file);
+					handle = dlopen(filename, mode);
+					if (!handle) {
+						/* if the filename exists and cannot be opened */
+						/* return immediately */
+						if (access(filename, X_OK) == 0)
+							goto errpath;
+					}
+					break;
+				} else {
+					fprintf(stderr, "XXX Did not find the library %s\n" ,so_file);
+					break;
+				}
 			}
 		}
+// Cut here:
+//		filename = alloca(sizeof(ALSA_PLUGIN_DIR) + 1 + strlen(name) + 1);
+//		if (filename) {
+//			strcpy(filename, ALSA_PLUGIN_DIR);
+//			strcat(filename, "/");
+//			strcat(filename, name);
+//			handle = dlopen(filename, mode);
+//			if (!handle) {
+//				/* if the filename exists and cannot be opened */
+//				/* return immediately */
+//				if (access(filename, X_OK) == 0)
+//					goto errpath;
+//			}
+//		}
+// ... to here.
 	}
 	if (!handle) {
 		handle = dlopen(name, mode);
@@ -104,6 +137,7 @@ void *snd_dlopen(const char *name, int mode, char *errbuf, size_t errbuflen)
 	return handle;
 errpath:
 	if (errbuf)
+		fprintf(stderr, "XXX couldn't find your thing!\n");
 		snprintf(errbuf, errbuflen, "%s: %s", filename, dlerror());
 #endif
 	return NULL;

debug log:

solving 7ca6b7960a ...
found 7ca6b7960a in https://yhetil.org/guix-bugs/20200508224518.GA3682@jasmine.lan/
found 3cee02aa0c in https://yhetil.org/guix-bugs/20200508224518.GA3682@jasmine.lan/

applying [1/2] https://yhetil.org/guix-bugs/20200508224518.GA3682@jasmine.lan/
diff --git a/gnu/packages/patches/alsa-lib.patch b/gnu/packages/patches/alsa-lib.patch
new file mode 100644
index 0000000000..3cee02aa0c


applying [2/2] https://yhetil.org/guix-bugs/20200508224518.GA3682@jasmine.lan/
diff --git a/gnu/packages/patches/alsa-lib.patch b/gnu/packages/patches/alsa-lib.patch
index 3cee02aa0c..7ca6b7960a 100644

2:12: space before tab in indent.
 	NULL
2:14: trailing whitespace.
 
2:29: space before tab in indent.
 			     snd_config_t *pcm_root, snd_config_t *pcm_conf,
2:30: space before tab in indent.
 			     snd_pcm_stream_t stream, int mode)
2:32: space before tab in indent.
 				err = -ENOMEM;
Checking patch gnu/packages/patches/alsa-lib.patch...
Applied patch gnu/packages/patches/alsa-lib.patch cleanly.
Checking patch gnu/packages/patches/alsa-lib.patch...
Applied patch gnu/packages/patches/alsa-lib.patch cleanly.
warning: squelched 23 whitespace errors
warning: 28 lines add whitespace errors.

index at:
100644 7ca6b7960a19d3325b8f08f018cd561ff25ef375	gnu/packages/patches/alsa-lib.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).