[pulseaudio-discuss] [PATCH] Add env vars for PA_ALSA_PATHS_DIR and PA_ALSA_PROFILE_SETS_DIR

Albert Astals Cid albert.astals at canonical.com
Wed Nov 23 16:10:31 UTC 2016


Helps making pulseaudio relocatable
---
 src/modules/alsa/alsa-mixer.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 3dbf6b1..92eaabe 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -2507,8 +2507,15 @@ static int path_verify(pa_alsa_path *p) {
 static const char *get_default_paths_dir(void) {
     if (pa_run_from_build_tree())
         return PA_SRCDIR "/modules/alsa/mixer/paths/";
-    else
-        return PA_ALSA_PATHS_DIR;
+    else {
+        static const char *paths_dir = NULL;
+        if (!paths_dir) {
+            paths_dir = getenv("PA_ALSA_PATHS_DIR");
+            if (!paths_dir)
+                paths_dir = PA_ALSA_PATHS_DIR;
+        }
+        return paths_dir;
+    }
 }

 pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char
*fname, pa_alsa_direction_t direction) {
@@ -4333,6 +4340,20 @@ void
pa_alsa_decibel_fix_dump(pa_alsa_decibel_fix *db_fix) {
     pa_xfree(db_values);
 }

+static const char *alsa_profile_sets_dir() {
+    if (pa_run_from_build_tree())
+        return PA_SRCDIR "/modules/alsa/mixer/profile-sets/";
+    else {
+        static const char *profile_sets_dir = NULL;
+        if (!profile_sets_dir) {
+            profile_sets_dir = getenv("PA_ALSA_PROFILE_SETS_DIR");
+            if (!profile_sets_dir)
+                profile_sets_dir = PA_ALSA_PROFILE_SETS_DIR;
+        }
+        return profile_sets_dir;
+    }
+}
+
 pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const
pa_channel_map *bonus) {
     pa_alsa_profile_set *ps;
     pa_alsa_profile *p;
@@ -4383,9 +4404,7 @@ pa_alsa_profile_set*
pa_alsa_profile_set_new(const char *fname, const pa_channel
     if (!fname)
         fname = "default.conf";

-    fn = pa_maybe_prefix_path(fname,
-                              pa_run_from_build_tree() ? PA_SRCDIR
"/modules/alsa/mixer/profile-sets/" :
-                              PA_ALSA_PROFILE_SETS_DIR);
+    fn = pa_maybe_prefix_path(fname, alsa_profile_sets_dir());

     r = pa_config_parse(fn, NULL, items, NULL, false, ps);
     pa_xfree(fn);
-- 
2.10.2


More information about the pulseaudio-discuss mailing list