acp-device: remove sources when destroyed

Or we end up polling wrong fds in an infinite loop.
This commit is contained in:
Wim Taymans 2020-07-29 12:19:33 +02:00
parent e32a7a8d65
commit d2452e1340

View file

@ -99,13 +99,20 @@ static void handle_acp_poll(struct spa_source *source)
this->sources[i].rmask = 0; this->sources[i].rmask = 0;
} }
static void remove_sources(struct impl *this)
{
int i;
for (i = 0; i < this->n_pfds; i++) {
spa_loop_remove_source(this->loop, &this->sources[i]);
}
this->n_pfds = 0;
}
static int setup_sources(struct impl *this) static int setup_sources(struct impl *this)
{ {
int i; int i;
for (i = 0; i < this->n_pfds; i++) { remove_sources(this);
spa_loop_remove_source(this->loop, &this->sources[i]);
}
this->n_pfds = acp_card_poll_descriptors(this->card, this->pfds, MAX_POLL); this->n_pfds = acp_card_poll_descriptors(this->card, this->pfds, MAX_POLL);
@ -774,6 +781,8 @@ static SPA_PRINTF_FUNC(6,0) void impl_acp_log_func(void *data,
static int impl_clear(struct spa_handle *handle) static int impl_clear(struct spa_handle *handle)
{ {
struct impl *this = (struct impl *) handle;
remove_sources(this);
return 0; return 0;
} }