mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa: Fix ctl device cleanup order
Reorder removing sources, closing the ctl device, and freeing memory, so that there's no chance of races causing a crash.
This commit is contained in:
parent
ea412a5628
commit
caf7eb33e4
1 changed files with 7 additions and 7 deletions
|
|
@ -838,6 +838,13 @@ int spa_alsa_clear(struct state *state)
|
|||
free(state->tag[1]);
|
||||
|
||||
if (state->ctl) {
|
||||
for (int i = 0; i < state->ctl_n_fds; i++) {
|
||||
spa_loop_remove_source(state->data_loop, &state->ctl_sources[i]);
|
||||
}
|
||||
|
||||
snd_ctl_close(state->ctl);
|
||||
state->ctl = NULL;
|
||||
|
||||
for (unsigned int i = 0; i < state->num_bind_ctls; i++) {
|
||||
if (state->bound_ctls[i].info) {
|
||||
snd_ctl_elem_info_free(state->bound_ctls[i].info);
|
||||
|
|
@ -848,13 +855,6 @@ int spa_alsa_clear(struct state *state)
|
|||
state->bound_ctls[i].value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < state->ctl_n_fds; i++) {
|
||||
spa_loop_remove_source(state->data_loop, &state->ctl_sources[i]);
|
||||
}
|
||||
|
||||
snd_ctl_close(state->ctl);
|
||||
state->ctl = NULL;
|
||||
}
|
||||
|
||||
return err;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue