From 7f6339e3071e90b3716dff8fc9136c98d0b320d2 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 14 Dec 2020 13:17:48 +0100 Subject: [PATCH] bluez5: Don't deref the transport to get the fd Use the configured fd in the source for reading and writing because the transport might be disconnected and cleared from the main thread at any time. --- spa/plugins/bluez5/a2dp-sink.c | 2 +- spa/plugins/bluez5/a2dp-source.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index b26ee4fc4..67d375bb0 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -343,7 +343,7 @@ static int send_buffer(struct impl *this) spa_log_trace(this->log, NAME " %p: send %d %u %u %u", this, this->frame_count, this->seqnum, this->timestamp, this->buffer_used); - written = send(this->transport->fd, this->buffer, this->buffer_used, MSG_DONTWAIT | MSG_NOSIGNAL); + written = send(this->flush_source.fd, this->buffer, this->buffer_used, MSG_DONTWAIT | MSG_NOSIGNAL); reset_buffer(this); spa_log_debug(this->log, NAME " %p: send %d: %m", this, written); diff --git a/spa/plugins/bluez5/a2dp-source.c b/spa/plugins/bluez5/a2dp-source.c index 51dadb332..471fd96cd 100644 --- a/spa/plugins/bluez5/a2dp-source.c +++ b/spa/plugins/bluez5/a2dp-source.c @@ -321,7 +321,7 @@ static int32_t read_data(struct impl *this) { again: /* read data from socket */ - size_read = read(this->transport->fd, this->buffer_read, b_size); + size_read = read(this->source.fd, this->buffer_read, b_size); if (size_read == 0) return 0;