mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Moved the detach code to the more appropriate place.
This commit is contained in:
parent
5e2b04c141
commit
cba5c929ec
2 changed files with 7 additions and 6 deletions
|
|
@ -284,6 +284,7 @@ int snd_mixer_elem_add(snd_mixer_elem_t *elem, snd_mixer_class_t *class)
|
|||
int snd_mixer_elem_remove(snd_mixer_elem_t *elem)
|
||||
{
|
||||
snd_mixer_t *mixer = elem->class->mixer;
|
||||
bag_iterator_t i, n;
|
||||
int err, idx, dir;
|
||||
unsigned int m;
|
||||
assert(elem);
|
||||
|
|
@ -291,6 +292,12 @@ int snd_mixer_elem_remove(snd_mixer_elem_t *elem)
|
|||
idx = _snd_mixer_find_elem(mixer, elem, &dir);
|
||||
if (dir != 0)
|
||||
return -EINVAL;
|
||||
__again:
|
||||
bag_for_each(i, n, &elem->helems) {
|
||||
snd_hctl_elem_t *helem = bag_iterator_entry(i);
|
||||
snd_mixer_elem_detach(elem, helem);
|
||||
goto __again; /* FIXME: optimize */
|
||||
}
|
||||
err = snd_mixer_elem_throw_event(elem, SND_CTL_EVENT_REMOVE);
|
||||
list_del(&elem->list);
|
||||
if (elem->private_free)
|
||||
|
|
|
|||
|
|
@ -425,15 +425,9 @@ static int selem_write(snd_mixer_elem_t *elem,
|
|||
|
||||
static void selem_free(snd_mixer_elem_t *elem)
|
||||
{
|
||||
int k;
|
||||
|
||||
selem_t *s;
|
||||
assert(elem->type == SND_MIXER_ELEM_SIMPLE);
|
||||
s = elem->private_data;
|
||||
for (k = 0; k <= CTL_LAST; k++) {
|
||||
if (s->ctls[k].elem)
|
||||
snd_mixer_elem_detach(elem, s->ctls[k].elem);
|
||||
}
|
||||
elem->private_data = NULL;
|
||||
free(s);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue