From d2452e1340038539bfbe3948fe61fe8a7b214f85 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Wed, 29 Jul 2020 12:19:33 +0200
Subject: [PATCH 1/2] acp-device: remove sources when destroyed
Or we end up polling wrong fds in an infinite loop.
---
spa/plugins/alsa/alsa-acp-device.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/spa/plugins/alsa/alsa-acp-device.c b/spa/plugins/alsa/alsa-acp-device.c
index 757cd450..12812e54 100644
--- a/spa/plugins/alsa/alsa-acp-device.c
+++ b/spa/plugins/alsa/alsa-acp-device.c
@@ -99,13 +99,20 @@ static void handle_acp_poll(struct spa_source *source)
this->sources[i].rmask = 0;
}
-static int setup_sources(struct impl *this)
+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)
+{
+ int i;
+
+ remove_sources(this);
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)
{
+ struct impl *this = (struct impl *) handle;
+ remove_sources(this);
return 0;
}
--
2.26.2