diff --git a/spa/plugins/bluez5/media-sink.c b/spa/plugins/bluez5/media-sink.c index 84f3f24f1..70ce7b930 100644 --- a/spa/plugins/bluez5/media-sink.c +++ b/spa/plugins/bluez5/media-sink.c @@ -2674,7 +2674,7 @@ impl_init(const struct spa_handle_factory *factory, if ((res = spa_system_timerfd_create(this->data_system, CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK)) < 0) - return res; + goto error_remove_listener; this->timerfd = res; if ((res = spa_system_timerfd_create(this->data_system, @@ -2702,6 +2702,10 @@ error_close_flush_timerfd: spa_system_close(this->data_system, this->flush_timerfd); error_close_timerfd: spa_system_close(this->data_system, this->timerfd); +error_remove_listener: + spa_hook_remove(&this->transport_listener); + if (this->codec_props && this->codec->clear_props) + this->codec->clear_props(this->codec_props); return res; } diff --git a/spa/plugins/bluez5/media-source.c b/spa/plugins/bluez5/media-source.c index 0aa79a544..a730254e2 100644 --- a/spa/plugins/bluez5/media-source.c +++ b/spa/plugins/bluez5/media-source.c @@ -2134,6 +2134,7 @@ impl_init(const struct spa_handle_factory *factory, struct impl *this; struct port *port; const char *str; + int res; spa_return_val_if_fail(factory != NULL, -EINVAL); spa_return_val_if_fail(handle != NULL, -EINVAL); @@ -2268,10 +2269,10 @@ impl_init(const struct spa_handle_factory *factory, spa_bt_transport_add_listener(this->transport, &this->transport_listener, &transport_events, this); - this->timerfd = spa_system_timerfd_create(this->data_system, - CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); - if (this->timerfd < 0) - return this->timerfd; + if ((res = spa_system_timerfd_create(this->data_system, + CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK)) < 0) + goto error_remove_listener; + this->timerfd = res; this->node_latency = 512; @@ -2280,6 +2281,12 @@ impl_init(const struct spa_handle_factory *factory, this->fd = -1; return 0; + +error_remove_listener: + spa_hook_remove(&this->transport_listener); + if (this->codec_props && this->codec->clear_props) + this->codec->clear_props(this->codec_props); + return res; } static const struct spa_interface_info impl_interfaces[] = {