const char *description;
};
+pa_alsa_jack *pa_alsa_jack_new(pa_alsa_path *path, const char *name, const char *alsa_name) {
+ pa_alsa_jack *jack;
+
+ pa_assert(name);
+
+ 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->state_unplugged = PA_AVAILABLE_NO;
+ jack->state_plugged = PA_AVAILABLE_YES;
+
+ return jack;
+}
+
+void pa_alsa_jack_free(pa_alsa_jack *jack) {
+ pa_assert(jack);
+
+ pa_xfree(jack->alsa_name);
+ pa_xfree(jack->name);
+ pa_xfree(jack);
+}
+
static const char *lookup_description(const char *key, const struct description_map dm[], unsigned n) {
unsigned i;
pa_xfree(db_fix);
}
-static void jack_free(pa_alsa_jack *j) {
- pa_assert(j);
-
- pa_xfree(j->alsa_name);
- pa_xfree(j->name);
- pa_xfree(j);
-}
-
static void element_free(pa_alsa_element *e) {
pa_alsa_option *o;
pa_assert(e);
while ((j = p->jacks)) {
PA_LLIST_REMOVE(pa_alsa_jack, p->jacks, j);
- jack_free(j);
+ pa_alsa_jack_free(j);
}
while ((e = p->elements)) {
if (pa_streq(j->name, section))
goto finish;
- j = pa_xnew0(pa_alsa_jack, 1);
- j->state_unplugged = PA_AVAILABLE_NO;
- j->state_plugged = PA_AVAILABLE_YES;
- j->path = p;
- j->name = pa_xstrdup(section);
- j->alsa_name = pa_sprintf_malloc("%s Jack", section);
+ j = pa_alsa_jack_new(p, section, NULL);
PA_LLIST_INSERT_AFTER(pa_alsa_jack, p->jacks, p->last_jack, j);
finish:
pa_alsa_required_t required_absent;
};
+pa_alsa_jack *pa_alsa_jack_new(pa_alsa_path *path, const char *name, const char *alsa_name);
+void pa_alsa_jack_free(pa_alsa_jack *jack);
+
/* A path wraps a series of elements into a single entity which can be
* used to control it as if it had a single volume slider, a single
* mute switch and a single list of selectable options. */
const char *device_name;
char *name;
const char *jack_control;
+ char *alsa_name;
pa_assert(ucm);
pa_assert(device);
if (pa_streq(j->name, name))
goto out;
- j = pa_xnew0(pa_alsa_jack, 1);
- j->state_unplugged = PA_AVAILABLE_NO;
- j->state_plugged = PA_AVAILABLE_YES;
- j->name = pa_xstrdup(name);
-
jack_control = pa_proplist_gets(device->proplist, PA_ALSA_PROP_UCM_JACK_CONTROL);
if (jack_control)
- j->alsa_name = pa_xstrdup(jack_control);
+ alsa_name = pa_xstrdup(jack_control);
else
- j->alsa_name = pa_sprintf_malloc("%s Jack", device_name);
+ alsa_name = pa_sprintf_malloc("%s Jack", device_name);
+ j = pa_alsa_jack_new(NULL, name, alsa_name);
+ pa_xfree(alsa_name);
PA_LLIST_PREPEND(pa_alsa_jack, ucm->jacks, j);
out:
}
PA_LLIST_FOREACH_SAFE(ji, jn, ucm->jacks) {
PA_LLIST_REMOVE(pa_alsa_jack, ucm->jacks, ji);
- pa_xfree(ji->alsa_name);
- pa_xfree(ji->name);
- pa_xfree(ji);
+ pa_alsa_jack_free(ji);
}
if (ucm->ucm_mgr) {
snd_use_case_mgr_close(ucm->ucm_mgr);