summaryrefslogtreecommitdiffstats
path: root/audio/esound/files/patch-ad
blob: 68018a173ede1f6a76fa5e93839b570966c005d0 (plain)
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
--- esdlib.c.orig	2008-11-18 15:35:19.000000000 -0500
+++ esdlib.c	2008-11-20 14:32:59.000000000 -0500
@@ -21,6 +21,8 @@
 #include <errno.h>
 #include <sys/wait.h>
 #include <poll.h>
+#include <pwd.h>
+#include <limits.h>
 
 #include <sys/un.h>
 
@@ -928,7 +930,7 @@ int esd_open_sound( const char *rhost )
 		    putenv(preload2);
 		}
 	    cmd = malloc(strlen(SERVERDIR"/esd  -spawnfd 9999999999") + strlen(esd_spawn_options));
-	    sprintf(cmd, "%s/esd %s -spawnfd %d", SERVERDIR, esd_spawn_options, esd_pipe[1]);
+	    sprintf(cmd, "exec esd %s -spawnfd %d", esd_spawn_options?esd_spawn_options:"", esd_pipe[1]);
 
 	    if(!fork()) {
 		/* child of child process.  Minimal so startup overhead is
@@ -1747,3 +1749,34 @@ int esd_close( int esd )
     return close( esd );
 }
 
+char *
+esd_unix_socket_dir(void) {
+       static char *sockdir = NULL, sockdirbuf[PATH_MAX];
+       struct passwd *pw;
+
+       if (sockdir != NULL)
+               return (sockdir);
+       pw = getpwuid(getuid());
+       if (pw == NULL || pw->pw_dir == NULL) {
+               fprintf(stderr, "esd: could not find home directory\n");
+               exit(1);
+       }
+       snprintf(sockdirbuf, sizeof(sockdirbuf), "%s/.esd", pw->pw_dir);
+       endpwent();
+       sockdir = sockdirbuf;
+       return (sockdir);
+}
+
+char *
+esd_unix_socket_name(void) {
+       static char *sockname = NULL, socknamebuf[PATH_MAX];
+
+       if (sockname != NULL)
+               return (sockname);
+       snprintf(socknamebuf, sizeof(socknamebuf), "%s/socket",
+           esd_unix_socket_dir());
+       sockname = socknamebuf;
+       return (sockname);
+ }
+
+
OpenPOWER on IntegriCloud