diff options
author | Tanu Kaskinen <tanu.kaskinen@linux.intel.com> | 2015-05-22 21:51:54 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-24 07:19:22 +0100 |
commit | 862ce8aec8c2a5554f53ac6efd3bbb990a919da0 (patch) | |
tree | c7b76ca15de895f872913564846aa8796f146cba /meta/recipes-multimedia | |
parent | 5246fc09a7bf9e5c2e619d2c8db0294998d37001 (diff) | |
download | poky-862ce8aec8c2a5554f53ac6efd3bbb990a919da0.tar.gz |
pulseaudio: conf-parser: add support for .d directories
Sato images should set allow-autospawn-for-root=true in
/etc/pulse/client.conf, but in non-Sato images that option should be
disabled by default. I first tried to have two packages that ship
different versions of the client.conf file, but it turned out to be
tricky to ensure that the package manager always chooses the package
that provides the default version when the Sato package is not
explicitly requested. This patch allows the Sato specific
configuration to be installed in /etc/pulse/client.conf.d without
replacing the default version of client.conf, which makes packaging
much simpler.
(From OE-Core rev: 17b20dfe8a1a90fd831dd225e80deb6a1d21b08a)
Signed-off-by: Tanu Kaskinen <tanu.kaskinen@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-multimedia')
-rw-r--r-- | meta/recipes-multimedia/pulseaudio/pulseaudio/0001-conf-parser-add-support-for-.d-directories.patch | 196 | ||||
-rw-r--r-- | meta/recipes-multimedia/pulseaudio/pulseaudio_6.0.bb | 1 |
2 files changed, 197 insertions, 0 deletions
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio/0001-conf-parser-add-support-for-.d-directories.patch b/meta/recipes-multimedia/pulseaudio/pulseaudio/0001-conf-parser-add-support-for-.d-directories.patch new file mode 100644 index 0000000000..a9f1b2acf3 --- /dev/null +++ b/meta/recipes-multimedia/pulseaudio/pulseaudio/0001-conf-parser-add-support-for-.d-directories.patch | |||
@@ -0,0 +1,196 @@ | |||
1 | From 8cb643bbf0a287d67794e680d26f49c503f31053 Mon Sep 17 00:00:00 2001 | ||
2 | From: Tanu Kaskinen <tanu.kaskinen@linux.intel.com> | ||
3 | Date: Thu, 21 May 2015 21:00:59 +0300 | ||
4 | Subject: [PATCH] conf-parser: add support for .d directories | ||
5 | |||
6 | This allows a configuration scheme where prior to loading | ||
7 | configuration from "somefile", the parser first loads configuration | ||
8 | from files in directory "somefile.d". This feature is currently | ||
9 | enabled only for client.conf and daemon.conf. | ||
10 | |||
11 | This makes it easier to create configuration packages in distributions | ||
12 | when there's need to have different configuration in different setups. | ||
13 | For example, the graphical Sato environment in OpenEmbedded-core needs | ||
14 | to set allow-autospawn-for-root=true in client.conf, but the default | ||
15 | configuration in OpenEmbedded-core should not set that option. With | ||
16 | this patch, I can create a Sato-specific package that simply installs | ||
17 | 50-sato.conf in /etc/pulse/client.conf.d without conflicting with the | ||
18 | main client.conf file coming from a different package. | ||
19 | |||
20 | Upstream-Status: Submitted [http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/23592] | ||
21 | |||
22 | Signed-off-by: Tanu Kaskinen <tanu.kaskinen@linux.intel.com> | ||
23 | --- | ||
24 | src/daemon/daemon-conf.c | 2 +- | ||
25 | src/modules/alsa/alsa-mixer.c | 4 ++-- | ||
26 | src/modules/module-augment-properties.c | 2 +- | ||
27 | src/pulse/client-conf.c | 2 +- | ||
28 | src/pulsecore/conf-parser.c | 42 +++++++++++++++++++++++++++++++-- | ||
29 | src/pulsecore/conf-parser.h | 8 ++++++- | ||
30 | 6 files changed, 52 insertions(+), 8 deletions(-) | ||
31 | |||
32 | diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c | ||
33 | index 21a8edb..1332fc6 100644 | ||
34 | --- a/src/daemon/daemon-conf.c | ||
35 | +++ b/src/daemon/daemon-conf.c | ||
36 | @@ -617,7 +617,7 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) { | ||
37 | ci.default_channel_map_set = ci.default_sample_spec_set = false; | ||
38 | ci.conf = c; | ||
39 | |||
40 | - r = f ? pa_config_parse(c->config_file, f, table, NULL, NULL) : 0; | ||
41 | + r = f ? pa_config_parse(c->config_file, f, table, NULL, true, NULL) : 0; | ||
42 | |||
43 | if (r >= 0) { | ||
44 | |||
45 | diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c | ||
46 | index 2314612..988b4fe 100644 | ||
47 | --- a/src/modules/alsa/alsa-mixer.c | ||
48 | +++ b/src/modules/alsa/alsa-mixer.c | ||
49 | @@ -2483,7 +2483,7 @@ pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa | ||
50 | |||
51 | fn = pa_maybe_prefix_path(fname, paths_dir); | ||
52 | |||
53 | - r = pa_config_parse(fn, NULL, items, p->proplist, p); | ||
54 | + r = pa_config_parse(fn, NULL, items, p->proplist, false, p); | ||
55 | pa_xfree(fn); | ||
56 | |||
57 | if (r < 0) | ||
58 | @@ -4288,7 +4288,7 @@ pa_alsa_profile_set* pa_alsa_profile_set_new(const char *fname, const pa_channel | ||
59 | pa_run_from_build_tree() ? PA_SRCDIR "/modules/alsa/mixer/profile-sets/" : | ||
60 | PA_ALSA_PROFILE_SETS_DIR); | ||
61 | |||
62 | - r = pa_config_parse(fn, NULL, items, NULL, ps); | ||
63 | + r = pa_config_parse(fn, NULL, items, NULL, false, ps); | ||
64 | pa_xfree(fn); | ||
65 | |||
66 | if (r < 0) | ||
67 | diff --git a/src/modules/module-augment-properties.c b/src/modules/module-augment-properties.c | ||
68 | index 42b6fd9..541f0e7 100644 | ||
69 | --- a/src/modules/module-augment-properties.c | ||
70 | +++ b/src/modules/module-augment-properties.c | ||
71 | @@ -204,7 +204,7 @@ static void update_rule(struct rule *r) { | ||
72 | table[0].data = &r->application_name; | ||
73 | table[1].data = &r->icon_name; | ||
74 | |||
75 | - if (pa_config_parse(fn, NULL, table, NULL, r) < 0) | ||
76 | + if (pa_config_parse(fn, NULL, table, NULL, false, r) < 0) | ||
77 | pa_log_warn("Failed to parse .desktop file %s.", fn); | ||
78 | |||
79 | pa_xfree(fn); | ||
80 | diff --git a/src/pulse/client-conf.c b/src/pulse/client-conf.c | ||
81 | index 83331f8..3c3384d 100644 | ||
82 | --- a/src/pulse/client-conf.c | ||
83 | +++ b/src/pulse/client-conf.c | ||
84 | @@ -149,7 +149,7 @@ void pa_client_conf_load(pa_client_conf *c, bool load_from_x11, bool load_from_e | ||
85 | |||
86 | f = pa_open_config_file(DEFAULT_CLIENT_CONFIG_FILE, DEFAULT_CLIENT_CONFIG_FILE_USER, ENV_CLIENT_CONFIG_FILE, &fn); | ||
87 | if (f) { | ||
88 | - pa_config_parse(fn, f, table, NULL, NULL); | ||
89 | + pa_config_parse(fn, f, table, NULL, true, NULL); | ||
90 | pa_xfree(fn); | ||
91 | fclose(f); | ||
92 | } | ||
93 | diff --git a/src/pulsecore/conf-parser.c b/src/pulsecore/conf-parser.c | ||
94 | index 2dcd45a..d473232 100644 | ||
95 | --- a/src/pulsecore/conf-parser.c | ||
96 | +++ b/src/pulsecore/conf-parser.c | ||
97 | @@ -21,6 +21,7 @@ | ||
98 | #include <config.h> | ||
99 | #endif | ||
100 | |||
101 | +#include <dirent.h> | ||
102 | #include <string.h> | ||
103 | #include <stdio.h> | ||
104 | #include <errno.h> | ||
105 | @@ -103,7 +104,7 @@ static int parse_line(pa_config_parser_state *state) { | ||
106 | } | ||
107 | } | ||
108 | |||
109 | - r = pa_config_parse(fn, NULL, state->item_table, state->proplist, state->userdata); | ||
110 | + r = pa_config_parse(fn, NULL, state->item_table, state->proplist, false, state->userdata); | ||
111 | pa_xfree(path); | ||
112 | return r; | ||
113 | } | ||
114 | @@ -152,8 +153,13 @@ static int parse_line(pa_config_parser_state *state) { | ||
115 | return normal_assignment(state); | ||
116 | } | ||
117 | |||
118 | +static int conf_filter(const struct dirent *entry) { | ||
119 | + return pa_endswith(entry->d_name, ".conf"); | ||
120 | +} | ||
121 | + | ||
122 | /* Go through the file and parse each line */ | ||
123 | -int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, pa_proplist *proplist, void *userdata) { | ||
124 | +int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, pa_proplist *proplist, bool use_dot_d, | ||
125 | + void *userdata) { | ||
126 | int r = -1; | ||
127 | bool do_close = !f; | ||
128 | pa_config_parser_state state; | ||
129 | @@ -163,6 +169,38 @@ int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, pa_p | ||
130 | |||
131 | pa_zero(state); | ||
132 | |||
133 | + if (use_dot_d) { | ||
134 | + char *dir_name; | ||
135 | + int n; | ||
136 | + struct dirent **entries = NULL; | ||
137 | + | ||
138 | + dir_name = pa_sprintf_malloc("%s.d", filename); | ||
139 | + | ||
140 | + n = scandir(dir_name, &entries, conf_filter, alphasort); | ||
141 | + if (n >= 0) { | ||
142 | + int i; | ||
143 | + | ||
144 | + for (i = 0; i < n; i++) { | ||
145 | + char *filename2; | ||
146 | + | ||
147 | + filename2 = pa_sprintf_malloc("%s" PA_PATH_SEP "%s", dir_name, entries[i]->d_name); | ||
148 | + pa_config_parse(filename2, NULL, t, proplist, false, userdata); | ||
149 | + pa_xfree(filename2); | ||
150 | + | ||
151 | + free(entries[i]); | ||
152 | + } | ||
153 | + | ||
154 | + free(entries); | ||
155 | + } else { | ||
156 | + if (errno == ENOENT) | ||
157 | + pa_log_debug("scandir(\"%s\") failed: %s", dir_name, pa_cstrerror(errno)); | ||
158 | + else | ||
159 | + pa_log_warn("scandir(\"%s\") failed: %s", dir_name, pa_cstrerror(errno)); | ||
160 | + } | ||
161 | + | ||
162 | + pa_xfree(dir_name); | ||
163 | + } | ||
164 | + | ||
165 | if (!f && !(f = pa_fopen_cloexec(filename, "r"))) { | ||
166 | if (errno == ENOENT) { | ||
167 | pa_log_debug("Failed to open configuration file '%s': %s", filename, pa_cstrerror(errno)); | ||
168 | diff --git a/src/pulsecore/conf-parser.h b/src/pulsecore/conf-parser.h | ||
169 | index dbb6f5c..cc20d7d 100644 | ||
170 | --- a/src/pulsecore/conf-parser.h | ||
171 | +++ b/src/pulsecore/conf-parser.h | ||
172 | @@ -59,6 +59,11 @@ struct pa_config_parser_state { | ||
173 | * pa_config_items in *t that is terminated by an item where lvalue is | ||
174 | * NULL. | ||
175 | * | ||
176 | + * If use_dot_d is true, then before parsing the file named by the filename | ||
177 | + * argument, the function will parse all files ending with ".conf" in | ||
178 | + * alphabetical order from a directory whose name is filename + ".d", if such | ||
179 | + * directory exists. | ||
180 | + * | ||
181 | * Some configuration files may contain a Properties section, which | ||
182 | * is a bit special. Normally all accepted lvalues must be predefined | ||
183 | * in the pa_config_item table, but in the Properties section the | ||
184 | @@ -68,7 +73,8 @@ struct pa_config_parser_state { | ||
185 | * properties, and those properties will be merged into the given | ||
186 | * proplist. If proplist is NULL, then sections named "Properties" | ||
187 | * are not allowed at all in the configuration file. */ | ||
188 | -int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, pa_proplist *proplist, void *userdata); | ||
189 | +int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, pa_proplist *proplist, bool use_dot_d, | ||
190 | + void *userdata); | ||
191 | |||
192 | /* Generic parsers for integers, size_t, booleans and strings */ | ||
193 | int pa_config_parse_int(pa_config_parser_state *state); | ||
194 | -- | ||
195 | 1.9.3 | ||
196 | |||
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio_6.0.bb b/meta/recipes-multimedia/pulseaudio/pulseaudio_6.0.bb index 465b224641..10969bd0c6 100644 --- a/meta/recipes-multimedia/pulseaudio/pulseaudio_6.0.bb +++ b/meta/recipes-multimedia/pulseaudio/pulseaudio_6.0.bb | |||
@@ -3,6 +3,7 @@ require pulseaudio.inc | |||
3 | SRC_URI = "http://freedesktop.org/software/pulseaudio/releases/${BP}.tar.xz \ | 3 | SRC_URI = "http://freedesktop.org/software/pulseaudio/releases/${BP}.tar.xz \ |
4 | file://0001-padsp-Make-it-compile-on-musl.patch \ | 4 | file://0001-padsp-Make-it-compile-on-musl.patch \ |
5 | file://0001-client-conf-Add-allow-autospawn-for-root.patch \ | 5 | file://0001-client-conf-Add-allow-autospawn-for-root.patch \ |
6 | file://0001-conf-parser-add-support-for-.d-directories.patch \ | ||
6 | file://volatiles.04_pulse \ | 7 | file://volatiles.04_pulse \ |
7 | " | 8 | " |
8 | SRC_URI[md5sum] = "b691e83b7434c678dffacfa3a027750e" | 9 | SRC_URI[md5sum] = "b691e83b7434c678dffacfa3a027750e" |