summaryrefslogtreecommitdiff
path: root/pipewire-pulseaudio
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2020-08-21 15:35:21 +0200
committerWim Taymans <wtaymans@redhat.com>2020-08-21 15:35:21 +0200
commitf3c06372ef5dabb63e4b550a1bf60b629c085cbd (patch)
tree3308b964e847877ab67f26a6bac03625c94701db /pipewire-pulseaudio
parent39513fb681b30709ce269c5008947c2fe039d70e (diff)
pulse: implement more directories
Diffstat (limited to 'pipewire-pulseaudio')
-rw-r--r--pipewire-pulseaudio/src/util.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/pipewire-pulseaudio/src/util.c b/pipewire-pulseaudio/src/util.c
index b457ccbb..4fe8c5d2 100644
--- a/pipewire-pulseaudio/src/util.c
+++ b/pipewire-pulseaudio/src/util.c
@@ -18,6 +18,8 @@
*/
#include <time.h>
+#include <unistd.h>
+#include <pwd.h>
#include <pipewire/log.h>
#include <pipewire/pipewire.h>
@@ -48,8 +50,36 @@ char *pa_get_fqdn(char *s, size_t l)
SPA_EXPORT
char *pa_get_home_dir(char *s, size_t l)
{
- pw_log_warn("Not Implemented");
- return NULL;
+ const char *home;
+ home = getenv("HOME");
+ if (home == NULL)
+ home = getenv("USERPROFILE");
+ if (home == NULL) {
+ struct passwd pwd, *result = NULL;
+ char buffer[4096];
+ if (getpwuid_r(getuid(), &pwd, buffer, sizeof(buffer), &result) == 0)
+ home = result ? result->pw_dir : NULL;
+ }
+ if (home) {
+ strncpy(s, home, l);
+ s[l] = 0;
+ }
+ return home ? s : NULL;
+}
+
+SPA_EXPORT
+char *pa_get_runtime_dir(void)
+{
+ const char *runtime;
+ runtime = getenv("PULSE_RUNTIME_PATH");
+ if (runtime == NULL)
+ runtime = getenv("XDG_RUNTIME_DIR");
+ if (runtime == NULL) {
+ char buffer[4096];
+ runtime = pa_get_home_dir(buffer, sizeof(buffer));
+ }
+ return runtime ? strdup(runtime) : NULL;
+
}
SPA_EXPORT