mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-12 13:30:10 -05:00
module-alsa-card: handle udev PULSE_MODARGS
Allow adding module arguments using udev PULSE_MODARGS environment variable and fail module loading if there is a problem with PULSE_MODARGS This helps setting e.g. 'tsched=0' for specific devices without a need to create full load module entry in default.pa. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/436>
This commit is contained in:
parent
19e34d8d5b
commit
d15b31d751
3 changed files with 77 additions and 0 deletions
|
|
@ -272,6 +272,15 @@ int pa_modargs_append(pa_modargs *ma, const char *args, const char* const* valid
|
|||
return parse(ma, args, valid_keys, true);
|
||||
}
|
||||
|
||||
int pa_modargs_remove_key(pa_modargs *ma, const char *key) {
|
||||
if (pa_hashmap_remove_and_free(ma->unescaped, key) == 0) {
|
||||
pa_hashmap_remove_and_free(ma->raw, key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void pa_modargs_free(pa_modargs*ma) {
|
||||
pa_assert(ma);
|
||||
|
||||
|
|
@ -544,3 +553,20 @@ const char *pa_modargs_iterate(pa_modargs *ma, void **state) {
|
|||
|
||||
return e->key;
|
||||
}
|
||||
|
||||
int pa_modargs_merge_missing(pa_modargs *dst, pa_modargs *src, const char* const valid_keys[]) {
|
||||
void *state;
|
||||
const char *key, *value;
|
||||
int ret = 0;
|
||||
|
||||
for (state = NULL, key = pa_modargs_iterate(src, &state); key; key = pa_modargs_iterate(src, &state)) {
|
||||
value = pa_modargs_get_value(src, key, NULL);
|
||||
if (value && add_key_value(dst, pa_xstrdup(key), pa_xstrdup(value), valid_keys, true) < 0) {
|
||||
pa_log_warn("Failed to add module argument '%s=%s'", key, value);
|
||||
ret = -1;
|
||||
/* continue to gather all errors */
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,4 +95,11 @@ int pa_modargs_get_proplist(pa_modargs *ma, const char *name, pa_proplist *p, pa
|
|||
* have any particular order. */
|
||||
const char *pa_modargs_iterate(pa_modargs *ma, void **state);
|
||||
|
||||
/* Remove entry by key. Returns 0 if successful, -1 otherwise */
|
||||
int pa_modargs_remove_key(pa_modargs *ma, const char *key);
|
||||
|
||||
/* Add all key/value pairs from src that are is not already present in dst, to dst.
|
||||
* Returns 0 if there were no errors, -1 otherwise. */
|
||||
int pa_modargs_merge_missing(pa_modargs *dst, pa_modargs *src, const char* const valid_keys[]);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue