From c0fc29494f00a51a2dba0f232ba99850dffb08a4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 20 Oct 2022 21:52:49 +0200 Subject: [PATCH] bluez5: stop before freeing things Make sure all timers are stopped before we clear our state. See #2764 --- spa/plugins/bluez5/media-sink.c | 3 +-- spa/plugins/bluez5/media-source.c | 4 ++-- spa/plugins/bluez5/sco-sink.c | 2 ++ spa/plugins/bluez5/sco-source.c | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/spa/plugins/bluez5/media-sink.c b/spa/plugins/bluez5/media-sink.c index d07f66788..7e6e3c437 100644 --- a/spa/plugins/bluez5/media-sink.c +++ b/spa/plugins/bluez5/media-sink.c @@ -1645,8 +1645,7 @@ static int impl_clear(struct spa_handle *handle) { struct impl *this = (struct impl *) handle; - if (this->codec_data) - this->codec->deinit(this->codec_data); + do_stop(this); if (this->codec_props && this->codec->clear_props) this->codec->clear_props(this->codec_props); if (this->transport) diff --git a/spa/plugins/bluez5/media-source.c b/spa/plugins/bluez5/media-source.c index c03d767b1..b1387da49 100644 --- a/spa/plugins/bluez5/media-source.c +++ b/spa/plugins/bluez5/media-source.c @@ -1452,8 +1452,8 @@ static int impl_clear(struct spa_handle *handle) { struct impl *this = (struct impl *) handle; struct port *port = &this->port; - if (this->codec_data) - this->codec->deinit(this->codec_data); + + do_stop(this); if (this->codec_props && this->codec->clear_props) this->codec->clear_props(this->codec_props); if (this->transport) diff --git a/spa/plugins/bluez5/sco-sink.c b/spa/plugins/bluez5/sco-sink.c index a80abfca3..8958b1b87 100644 --- a/spa/plugins/bluez5/sco-sink.c +++ b/spa/plugins/bluez5/sco-sink.c @@ -1347,6 +1347,8 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void static int impl_clear(struct spa_handle *handle) { struct impl *this = (struct impl *) handle; + + do_stop(this); if (this->transport) spa_hook_remove(&this->transport_listener); spa_system_close(this->data_system, this->timerfd); diff --git a/spa/plugins/bluez5/sco-source.c b/spa/plugins/bluez5/sco-source.c index 52a1d27cc..81470d267 100644 --- a/spa/plugins/bluez5/sco-source.c +++ b/spa/plugins/bluez5/sco-source.c @@ -1391,6 +1391,8 @@ static int impl_get_interface(struct spa_handle *handle, const char *type, void static int impl_clear(struct spa_handle *handle) { struct impl *this = (struct impl *) handle; + + do_stop(this); if (this->transport) spa_hook_remove(&this->transport_listener); spa_system_close(this->data_system, this->timerfd);