[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] alsa-mixer: Respect XDG base directory spec when loading profile sets
PulseAudio Marge Bot (@pulseaudio-merge-bot)
gitlab at gitlab.freedesktop.org
Sat Aug 12 16:21:37 UTC 2023
PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio
Commits:
095ad5f4 by SimonP at 2023-08-12T16:03:30+00:00
alsa-mixer: Respect XDG base directory spec when loading profile sets
Try $XDG_DATA_HOME, then $XDG_DATA_DIRS, and finally fall back to old behaviour.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/311>
- - - - -
3 changed files:
- meson.build
- src/modules/alsa/alsa-mixer.c
- src/tests/alsa-mixer-path-test.c
Changes:
=====================================
meson.build
=====================================
@@ -168,8 +168,7 @@ cdata.set_quoted('PA_SYSTEM_USER', get_option('system_user'))
cdata.set_quoted('PA_SYSTEM_GROUP', get_option('system_group'))
cdata.set_quoted('PA_ACCESS_GROUP', get_option('access_group'))
cdata.set_quoted('PA_CFLAGS', 'Not yet supported on meson')
-cdata.set_quoted('PA_ALSA_PATHS_DIR', join_paths(alsadatadir, 'paths'))
-cdata.set_quoted('PA_ALSA_PROFILE_SETS_DIR', join_paths(alsadatadir, 'profile-sets'))
+cdata.set_quoted('PA_ALSA_DATA_DIR', alsadatadir)
cdata.set_quoted('DESKTOPFILEDIR', join_paths(datadir, 'applications'))
cdata.set_quoted('PULSE_LOCALEDIR', localedir)
cdata.set_quoted('GETTEXT_PACKAGE', 'pulseaudio')
=====================================
src/modules/alsa/alsa-mixer.c
=====================================
@@ -2851,41 +2851,44 @@ static int path_verify(pa_alsa_path *p) {
return 0;
}
-static char *get_path_config_path(const char *paths_dir, const char *fname) {
- char *path_config_path;
+static char *get_data_path(const char *data_dir, const char *data_type, const char *fname) {
+ char *result;
char *dir;
char *data_home;
pa_dynarray *data_dirs;
- if (paths_dir) {
- path_config_path = pa_maybe_prefix_path(fname, paths_dir);
- if (access(path_config_path, R_OK) == 0)
- return path_config_path;
+ if (data_dir) {
+ result = pa_maybe_prefix_path(fname, data_dir);
+ if (access(result, R_OK) == 0)
+ return result;
else
- pa_xfree(path_config_path);
+ pa_xfree(result);
}
#ifdef HAVE_RUNNING_FROM_BUILD_TREE
if (pa_run_from_build_tree()) {
- path_config_path = pa_maybe_prefix_path(fname, PA_SRCDIR "/modules/alsa/mixer/paths/");
- if (access(path_config_path, R_OK) == 0)
- return path_config_path;
+ dir = pa_sprintf_malloc(PA_SRCDIR "/modules/alsa/mixer/%s/", data_type);
+ result = pa_maybe_prefix_path(fname, dir);
+ pa_xfree(dir);
+
+ if (access(result, R_OK) == 0)
+ return result;
else
- pa_xfree(path_config_path);
+ pa_xfree(result);
}
#endif
if (pa_get_data_home_dir(&data_home) == 0) {
- dir = pa_sprintf_malloc("%s" PA_PATH_SEP "alsa-mixer" PA_PATH_SEP "paths", data_home);
+ dir = pa_sprintf_malloc("%s" PA_PATH_SEP "alsa-mixer" PA_PATH_SEP "%s", data_home, data_type);
pa_xfree(data_home);
- path_config_path = pa_maybe_prefix_path(fname, dir);
+ result = pa_maybe_prefix_path(fname, dir);
pa_xfree(dir);
- if (access(path_config_path, R_OK) == 0)
- return path_config_path;
+ if (access(result, R_OK) == 0)
+ return result;
else
- pa_xfree(path_config_path);
+ pa_xfree(result);
}
if (pa_get_data_dirs(&data_dirs) == 0) {
@@ -2893,24 +2896,27 @@ static char *get_path_config_path(const char *paths_dir, const char *fname) {
const char *n;
PA_DYNARRAY_FOREACH(n, data_dirs, idx) {
- dir = pa_sprintf_malloc("%s" PA_PATH_SEP "alsa-mixer" PA_PATH_SEP "paths", n);
- path_config_path = pa_maybe_prefix_path(fname, dir);
+ dir = pa_sprintf_malloc("%s" PA_PATH_SEP "alsa-mixer" PA_PATH_SEP "%s", n, data_type);
+ result = pa_maybe_prefix_path(fname, dir);
pa_xfree(dir);
- if (access(path_config_path, R_OK) == 0) {
+ if (access(result, R_OK) == 0) {
pa_dynarray_free(data_dirs);
- return path_config_path;
+ return result;
}
else {
- pa_xfree(path_config_path);
+ pa_xfree(result);
}
}
pa_dynarray_free(data_dirs);
}
- path_config_path = pa_maybe_prefix_path(fname, PA_ALSA_PATHS_DIR);
- return path_config_path;
+ dir = pa_sprintf_malloc(PA_ALSA_DATA_DIR PA_PATH_SEP "%s", data_type);
+ result = pa_maybe_prefix_path(fname, dir);
+ pa_xfree(dir);
+
+ return result;
}
pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa_direction_t direction) {
@@ -2977,7 +2983,7 @@ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa
items[2].data = &p->description;
items[3].data = &mute_during_activation;
- fn = get_path_config_path(paths_dir, fname);
+ fn = get_data_path(paths_dir, "paths", fname);
pa_log_info("Loading path config: %s", fn);
@@ -4971,11 +4977,9 @@ 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,
-#ifdef HAVE_RUNNING_FROM_BUILD_TREE
- pa_run_from_build_tree() ? PA_SRCDIR "/modules/alsa/mixer/profile-sets/" :
-#endif
- PA_ALSA_PROFILE_SETS_DIR);
+ fn = get_data_path(NULL, "profile-sets", fname);
+
+ pa_log_info("Loading profile set: %s", fn);
r = pa_config_parse(fn, NULL, items, NULL, false, ps);
pa_xfree(fn);
=====================================
src/tests/alsa-mixer-path-test.c
=====================================
@@ -21,7 +21,7 @@ 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;
+ return PA_ALSA_DATA_DIR PA_PATH_SEP "paths/";
}
static pa_strlist *load_makefile() {
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/095ad5f4f81b3eead307058b24feb707e345384e
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/095ad5f4f81b3eead307058b24feb707e345384e
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20230812/aa356dc3/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list