mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
ucm: Create only one jack object per kcontrol
Previously the UCM code created one jack object per device name (which is not the same thing as creating one jack object per device, because the UCM device namespace is scoped on per-verb basis, so devices in different verbs may have the same name). I think it's conceptually cleaner to create one jack object per alsa kcontrol. I plan to do similar refactoring on the traditional mixer code later.
This commit is contained in:
parent
c9557e6969
commit
d2bed5332a
3 changed files with 27 additions and 20 deletions
|
|
@ -107,7 +107,7 @@ struct description_map {
|
|||
const char *description;
|
||||
};
|
||||
|
||||
pa_alsa_jack *pa_alsa_jack_new(pa_alsa_path *path, const char *name, const char *alsa_name) {
|
||||
pa_alsa_jack *pa_alsa_jack_new(pa_alsa_path *path, const char *name) {
|
||||
pa_alsa_jack *jack;
|
||||
|
||||
pa_assert(name);
|
||||
|
|
@ -115,12 +115,7 @@ pa_alsa_jack *pa_alsa_jack_new(pa_alsa_path *path, const char *name, const char
|
|||
jack = pa_xnew0(pa_alsa_jack, 1);
|
||||
jack->path = path;
|
||||
jack->name = pa_xstrdup(name);
|
||||
|
||||
if (alsa_name)
|
||||
jack->alsa_name = pa_xstrdup(alsa_name);
|
||||
else
|
||||
jack->alsa_name = pa_sprintf_malloc("%s Jack", name);
|
||||
|
||||
jack->alsa_name = pa_sprintf_malloc("%s Jack", name);
|
||||
jack->state_unplugged = PA_AVAILABLE_NO;
|
||||
jack->state_plugged = PA_AVAILABLE_YES;
|
||||
jack->ucm_devices = pa_dynarray_new(NULL);
|
||||
|
|
@ -1857,7 +1852,7 @@ static pa_alsa_jack* jack_get(pa_alsa_path *p, const char *section) {
|
|||
if (pa_streq(j->name, section))
|
||||
goto finish;
|
||||
|
||||
j = pa_alsa_jack_new(p, section, NULL);
|
||||
j = pa_alsa_jack_new(p, section);
|
||||
PA_LLIST_INSERT_AFTER(pa_alsa_jack, p->jacks, p->last_jack, j);
|
||||
|
||||
finish:
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ struct pa_alsa_jack {
|
|||
pa_dynarray *ucm_devices; /* pa_alsa_ucm_device */
|
||||
};
|
||||
|
||||
pa_alsa_jack *pa_alsa_jack_new(pa_alsa_path *path, const char *name, const char *alsa_name);
|
||||
pa_alsa_jack *pa_alsa_jack_new(pa_alsa_path *path, const char *name);
|
||||
void pa_alsa_jack_free(pa_alsa_jack *jack);
|
||||
void pa_alsa_jack_set_has_control(pa_alsa_jack *jack, bool has_control);
|
||||
void pa_alsa_jack_set_plugged_in(pa_alsa_jack *jack, bool plugged_in);
|
||||
|
|
|
|||
|
|
@ -1292,27 +1292,39 @@ static pa_alsa_jack* ucm_get_jack(pa_alsa_ucm_config *ucm, pa_alsa_ucm_device *d
|
|||
pa_alsa_jack *j;
|
||||
const char *device_name;
|
||||
const char *jack_control;
|
||||
char *alsa_name;
|
||||
char *name;
|
||||
|
||||
pa_assert(ucm);
|
||||
pa_assert(device);
|
||||
|
||||
device_name = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_NAME);
|
||||
|
||||
PA_LLIST_FOREACH(j, ucm->jacks)
|
||||
if (pa_streq(j->name, device_name))
|
||||
return j;
|
||||
|
||||
jack_control = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_JACK_CONTROL);
|
||||
if (jack_control)
|
||||
alsa_name = pa_xstrdup(jack_control);
|
||||
else
|
||||
alsa_name = pa_sprintf_malloc("%s Jack", device_name);
|
||||
if (jack_control) {
|
||||
if (!pa_endswith(jack_control, " Jack")) {
|
||||
pa_log("[%s] Invalid JackControl value: \"%s\"", device_name, jack_control);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
j = pa_alsa_jack_new(NULL, device_name, alsa_name);
|
||||
pa_xfree(alsa_name);
|
||||
/* pa_alsa_jack_new() expects a jack name without " Jack" at the
|
||||
* end, so drop the trailing " Jack". */
|
||||
name = pa_xstrndup(jack_control, strlen(jack_control) - 5);
|
||||
} else {
|
||||
/* The jack control hasn't been explicitly configured - try a jack name
|
||||
* that is the same as the device name. */
|
||||
name = pa_xstrdup(device_name);
|
||||
}
|
||||
|
||||
PA_LLIST_FOREACH(j, ucm->jacks)
|
||||
if (pa_streq(j->name, name))
|
||||
goto finish;
|
||||
|
||||
j = pa_alsa_jack_new(NULL, name);
|
||||
PA_LLIST_PREPEND(pa_alsa_jack, ucm->jacks, j);
|
||||
|
||||
finish:
|
||||
pa_xfree(name);
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue