mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-01 22:58:47 -04:00
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.
This commit is contained in:
parent
ca6057316d
commit
a88b1d5cd4
5 changed files with 30 additions and 11 deletions
|
|
@ -2338,7 +2338,14 @@ static int path_verify(pa_alsa_path *p) {
|
||||||
return 0;
|
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;
|
pa_alsa_path *p;
|
||||||
char *fn;
|
char *fn;
|
||||||
int r;
|
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[1].data = &p->description;
|
||||||
items[2].data = &p->name;
|
items[2].data = &p->name;
|
||||||
|
|
||||||
fn = pa_maybe_prefix_path(fname,
|
if (!paths_dir)
|
||||||
pa_run_from_build_tree() ? PA_BUILDDIR "/modules/alsa/mixer/paths/" :
|
paths_dir = get_default_paths_dir();
|
||||||
PA_ALSA_PATHS_DIR);
|
|
||||||
|
fn = pa_maybe_prefix_path(fname, paths_dir);
|
||||||
|
|
||||||
r = pa_config_parse(fn, NULL, items, p);
|
r = pa_config_parse(fn, NULL, items, p);
|
||||||
pa_xfree(fn);
|
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_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;
|
pa_alsa_path_set *ps;
|
||||||
char **pn = NULL, **en = NULL, **ie;
|
char **pn = NULL, **en = NULL, **ie;
|
||||||
pa_alsa_decibel_fix *db_fix;
|
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);
|
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;
|
p->path_set = ps;
|
||||||
PA_LLIST_INSERT_AFTER(pa_alsa_path, ps->paths, ps->last_path, p);
|
PA_LLIST_INSERT_AFTER(pa_alsa_path, ps->paths, ps->last_path, p);
|
||||||
ps->last_path = p;
|
ps->last_path = p;
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,7 @@ void pa_alsa_option_dump(pa_alsa_option *o);
|
||||||
|
|
||||||
void pa_alsa_element_dump(pa_alsa_element *e);
|
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);
|
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);
|
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);
|
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_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);
|
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_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_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);
|
void pa_alsa_path_set_set_callback(pa_alsa_path_set *ps, snd_mixer_t *m, snd_mixer_elem_callback_t cb, void *userdata);
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ struct userdata {
|
||||||
|
|
||||||
snd_pcm_t *pcm_handle;
|
snd_pcm_t *pcm_handle;
|
||||||
|
|
||||||
|
char *paths_dir;
|
||||||
pa_alsa_fdlist *mixer_fdl;
|
pa_alsa_fdlist *mixer_fdl;
|
||||||
pa_alsa_mixer_pdata *mixer_pd;
|
pa_alsa_mixer_pdata *mixer_pd;
|
||||||
snd_mixer_t *mixer_handle;
|
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);
|
pa_alsa_path_dump(u->mixer_path);
|
||||||
} else {
|
} 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;
|
goto fail;
|
||||||
|
|
||||||
pa_alsa_path_set_probe(u->mixer_path_set, u->mixer_handle, ignore_dB);
|
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",
|
ma, "device_id",
|
||||||
pa_modargs_get_value(ma, "device", DEFAULT_DEVICE));
|
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)
|
if (reserve_init(u, dev_id) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|
@ -2381,6 +2384,7 @@ static void userdata_free(struct userdata *u) {
|
||||||
|
|
||||||
pa_xfree(u->device_name);
|
pa_xfree(u->device_name);
|
||||||
pa_xfree(u->control_device);
|
pa_xfree(u->control_device);
|
||||||
|
pa_xfree(u->paths_dir);
|
||||||
pa_xfree(u);
|
pa_xfree(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ struct userdata {
|
||||||
|
|
||||||
snd_pcm_t *pcm_handle;
|
snd_pcm_t *pcm_handle;
|
||||||
|
|
||||||
|
char *paths_dir;
|
||||||
pa_alsa_fdlist *mixer_fdl;
|
pa_alsa_fdlist *mixer_fdl;
|
||||||
pa_alsa_mixer_pdata *mixer_pd;
|
pa_alsa_mixer_pdata *mixer_pd;
|
||||||
snd_mixer_t *mixer_handle;
|
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);
|
pa_alsa_path_dump(u->mixer_path);
|
||||||
} else {
|
} 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;
|
goto fail;
|
||||||
|
|
||||||
pa_alsa_path_set_probe(u->mixer_path_set, u->mixer_handle, ignore_dB);
|
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",
|
ma, "device_id",
|
||||||
pa_modargs_get_value(ma, "device", DEFAULT_DEVICE));
|
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)
|
if (reserve_init(u, dev_id) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|
@ -2041,6 +2044,7 @@ static void userdata_free(struct userdata *u) {
|
||||||
|
|
||||||
pa_xfree(u->device_name);
|
pa_xfree(u->device_name);
|
||||||
pa_xfree(u->control_device);
|
pa_xfree(u->control_device);
|
||||||
|
pa_xfree(u->paths_dir);
|
||||||
pa_xfree(u);
|
pa_xfree(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,9 @@ PA_MODULE_USAGE(
|
||||||
"profile=<profile name> "
|
"profile=<profile name> "
|
||||||
"ignore_dB=<ignore dB information from the device?> "
|
"ignore_dB=<ignore dB information from the device?> "
|
||||||
"deferred_volume=<Synchronize software and hardware volume changes to avoid momentary jumps?> "
|
"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[] = {
|
static const char* const valid_modargs[] = {
|
||||||
"name",
|
"name",
|
||||||
|
|
@ -90,6 +92,7 @@ static const char* const valid_modargs[] = {
|
||||||
"ignore_dB",
|
"ignore_dB",
|
||||||
"deferred_volume",
|
"deferred_volume",
|
||||||
"profile_set",
|
"profile_set",
|
||||||
|
"paths_dir",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue