[pulseaudio-commits] src/modules
Arun Raghavan
arun at kemper.freedesktop.org
Mon Oct 17 01:09:50 PDT 2011
src/modules/alsa/alsa-mixer.c | 20 ++++++++++++++------
src/modules/alsa/alsa-mixer.h | 4 ++--
src/modules/alsa/alsa-sink.c | 6 +++++-
src/modules/alsa/alsa-source.c | 6 +++++-
src/modules/alsa/module-alsa-card.c | 5 ++++-
5 files changed, 30 insertions(+), 11 deletions(-)
New commits:
commit a88b1d5cd42e83fa28a587ab02721d4ed91a3414
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Thu Oct 6 23:09:15 2011 +0300
alsa: New modarg "paths_dir" for module-alsa-card
The new module argument can be used to provide a custom
directory for loading alsa path configuration files. This is
useful for testing: no need to be root to create test
configuration files.
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index b6cf085..151eef5 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -2338,7 +2338,14 @@ static int path_verify(pa_alsa_path *p) {
return 0;
}
-pa_alsa_path* pa_alsa_path_new(const char *fname, pa_alsa_direction_t direction) {
+static const char *get_default_paths_dir(void) {
+ if (pa_run_from_build_tree())
+ return PA_BUILDDIR "/modules/alsa/mixer/paths/";
+ else
+ return PA_ALSA_PATHS_DIR;
+}
+
+pa_alsa_path* pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa_direction_t direction) {
pa_alsa_path *p;
char *fn;
int r;
@@ -2381,9 +2388,10 @@ pa_alsa_path* pa_alsa_path_new(const char *fname, pa_alsa_direction_t direction)
items[1].data = &p->description;
items[2].data = &p->name;
- fn = pa_maybe_prefix_path(fname,
- pa_run_from_build_tree() ? PA_BUILDDIR "/modules/alsa/mixer/paths/" :
- PA_ALSA_PATHS_DIR);
+ if (!paths_dir)
+ paths_dir = get_default_paths_dir();
+
+ fn = pa_maybe_prefix_path(fname, paths_dir);
r = pa_config_parse(fn, NULL, items, p);
pa_xfree(fn);
@@ -2768,7 +2776,7 @@ void pa_alsa_path_set_set_callback(pa_alsa_path_set *ps, snd_mixer_t *m, snd_mix
pa_alsa_path_set_callback(p, m, cb, userdata);
}
-pa_alsa_path_set *pa_alsa_path_set_new(pa_alsa_mapping *m, pa_alsa_direction_t direction) {
+pa_alsa_path_set *pa_alsa_path_set_new(pa_alsa_mapping *m, pa_alsa_direction_t direction, const char *paths_dir) {
pa_alsa_path_set *ps;
char **pn = NULL, **en = NULL, **ie;
pa_alsa_decibel_fix *db_fix;
@@ -2809,7 +2817,7 @@ pa_alsa_path_set *pa_alsa_path_set_new(pa_alsa_mapping *m, pa_alsa_direction_t d
fn = pa_sprintf_malloc("%s.conf", *in);
- if ((p = pa_alsa_path_new(fn, direction))) {
+ if ((p = pa_alsa_path_new(paths_dir, fn, direction))) {
p->path_set = ps;
PA_LLIST_INSERT_AFTER(pa_alsa_path, ps->paths, ps->last_path, p);
ps->last_path = p;
diff --git a/src/modules/alsa/alsa-mixer.h b/src/modules/alsa/alsa-mixer.h
index c9d968a..92ddac5 100644
--- a/src/modules/alsa/alsa-mixer.h
+++ b/src/modules/alsa/alsa-mixer.h
@@ -208,7 +208,7 @@ void pa_alsa_option_dump(pa_alsa_option *o);
void pa_alsa_element_dump(pa_alsa_element *e);
-pa_alsa_path *pa_alsa_path_new(const char *fname, pa_alsa_direction_t direction);
+pa_alsa_path *pa_alsa_path_new(const char *paths_dir, const char *fname, pa_alsa_direction_t direction);
pa_alsa_path *pa_alsa_path_synthesize(const char *element, pa_alsa_direction_t direction);
int pa_alsa_path_probe(pa_alsa_path *p, snd_mixer_t *m, pa_bool_t ignore_dB);
void pa_alsa_path_dump(pa_alsa_path *p);
@@ -220,7 +220,7 @@ int pa_alsa_path_select(pa_alsa_path *p, snd_mixer_t *m);
void pa_alsa_path_set_callback(pa_alsa_path *p, snd_mixer_t *m, snd_mixer_elem_callback_t cb, void *userdata);
void pa_alsa_path_free(pa_alsa_path *p);
-pa_alsa_path_set *pa_alsa_path_set_new(pa_alsa_mapping *m, pa_alsa_direction_t direction);
+pa_alsa_path_set *pa_alsa_path_set_new(pa_alsa_mapping *m, pa_alsa_direction_t direction, const char *paths_dir);
void pa_alsa_path_set_probe(pa_alsa_path_set *s, snd_mixer_t *m, pa_bool_t ignore_dB);
void pa_alsa_path_set_dump(pa_alsa_path_set *s);
void pa_alsa_path_set_set_callback(pa_alsa_path_set *ps, snd_mixer_t *m, snd_mixer_elem_callback_t cb, void *userdata);
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 3a95251..bcc6e51 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -100,6 +100,7 @@ struct userdata {
snd_pcm_t *pcm_handle;
+ char *paths_dir;
pa_alsa_fdlist *mixer_fdl;
pa_alsa_mixer_pdata *mixer_pd;
snd_mixer_t *mixer_handle;
@@ -1863,7 +1864,7 @@ static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char
pa_alsa_path_dump(u->mixer_path);
} else {
- if (!(u->mixer_path_set = pa_alsa_path_set_new(mapping, PA_ALSA_DIRECTION_OUTPUT)))
+ if (!(u->mixer_path_set = pa_alsa_path_set_new(mapping, PA_ALSA_DIRECTION_OUTPUT, u->paths_dir)))
goto fail;
pa_alsa_path_set_probe(u->mixer_path_set, u->mixer_handle, ignore_dB);
@@ -2069,6 +2070,8 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
ma, "device_id",
pa_modargs_get_value(ma, "device", DEFAULT_DEVICE));
+ u->paths_dir = pa_xstrdup(pa_modargs_get_value(ma, "paths_dir", NULL));
+
if (reserve_init(u, dev_id) < 0)
goto fail;
@@ -2381,6 +2384,7 @@ static void userdata_free(struct userdata *u) {
pa_xfree(u->device_name);
pa_xfree(u->control_device);
+ pa_xfree(u->paths_dir);
pa_xfree(u);
}
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 46b89a7..0766e11 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -90,6 +90,7 @@ struct userdata {
snd_pcm_t *pcm_handle;
+ char *paths_dir;
pa_alsa_fdlist *mixer_fdl;
pa_alsa_mixer_pdata *mixer_pd;
snd_mixer_t *mixer_handle;
@@ -1563,7 +1564,7 @@ static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char
pa_alsa_path_dump(u->mixer_path);
} else {
- if (!(u->mixer_path_set = pa_alsa_path_set_new(mapping, PA_ALSA_DIRECTION_INPUT)))
+ if (!(u->mixer_path_set = pa_alsa_path_set_new(mapping, PA_ALSA_DIRECTION_INPUT, u->paths_dir)))
goto fail;
pa_alsa_path_set_probe(u->mixer_path_set, u->mixer_handle, ignore_dB);
@@ -1761,6 +1762,8 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
ma, "device_id",
pa_modargs_get_value(ma, "device", DEFAULT_DEVICE));
+ u->paths_dir = pa_xstrdup(pa_modargs_get_value(ma, "paths_dir", NULL));
+
if (reserve_init(u, dev_id) < 0)
goto fail;
@@ -2041,6 +2044,7 @@ static void userdata_free(struct userdata *u) {
pa_xfree(u->device_name);
pa_xfree(u->control_device);
+ pa_xfree(u->paths_dir);
pa_xfree(u);
}
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index 6d1a5e1..c3e8824 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -66,7 +66,9 @@ PA_MODULE_USAGE(
"profile=<profile name> "
"ignore_dB=<ignore dB information from the device?> "
"deferred_volume=<Synchronize software and hardware volume changes to avoid momentary jumps?> "
- "profile_set=<profile set configuration file> ");
+ "profile_set=<profile set configuration file> "
+ "paths_dir=<directory containing the path configuration files> "
+);
static const char* const valid_modargs[] = {
"name",
@@ -90,6 +92,7 @@ static const char* const valid_modargs[] = {
"ignore_dB",
"deferred_volume",
"profile_set",
+ "paths_dir",
NULL
};
More information about the pulseaudio-commits
mailing list