From 04eb7096193ff7a0a10d5451edac986e7e86d46e Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sun, 5 Mar 2023 17:45:31 +0200 Subject: [PATCH] bluez5: don't set unnecessary socket options In media-sink, there's no need to set RCVBUF. In media-source, we don't need to set NONBLOCK, as reads are done with DONTWAIT. Don't set SNDBUF as it's not needed there. Don't set RCVBUF, but use the (big) kernel default value: decode-buffer will handle any overruns. Small values of RCVBUF might cause problems if kernel is sending packets in a burst faster than we wake up. --- spa/plugins/bluez5/media-sink.c | 4 ---- spa/plugins/bluez5/media-source.c | 13 ------------- 2 files changed, 17 deletions(-) diff --git a/spa/plugins/bluez5/media-sink.c b/spa/plugins/bluez5/media-sink.c index 56149a210..7a9531298 100644 --- a/spa/plugins/bluez5/media-sink.c +++ b/spa/plugins/bluez5/media-sink.c @@ -977,10 +977,6 @@ static int do_start(struct impl *this) } this->fd_buffer_size = val; - val = FILL_FRAMES * this->transport->read_mtu; - if (setsockopt(this->transport->fd, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val)) < 0) - spa_log_warn(this->log, "%p: SO_RCVBUF %m", this); - val = 6; if (setsockopt(this->transport->fd, SOL_SOCKET, SO_PRIORITY, &val, sizeof(val)) < 0) spa_log_warn(this->log, "SO_PRIORITY failed: %m"); diff --git a/spa/plugins/bluez5/media-source.c b/spa/plugins/bluez5/media-source.c index daf8b8911..e2d2ee1ae 100644 --- a/spa/plugins/bluez5/media-source.c +++ b/spa/plugins/bluez5/media-source.c @@ -48,7 +48,6 @@ struct props { char clock_name[64]; }; -#define FILL_FRAMES 2 #define MAX_BUFFERS 32 struct buffer { @@ -677,18 +676,6 @@ static int transport_start(struct impl *this) if (this->fd < 0) return -errno; - val = fcntl(this->fd, F_GETFL); - if (fcntl(this->fd, F_SETFL, val | O_NONBLOCK) < 0) - spa_log_warn(this->log, "%p: fcntl %u %m", this, val | O_NONBLOCK); - - val = FILL_FRAMES * this->transport->write_mtu; - if (setsockopt(this->fd, SOL_SOCKET, SO_SNDBUF, &val, sizeof(val)) < 0) - spa_log_warn(this->log, "%p: SO_SNDBUF %m", this); - - val = FILL_FRAMES * this->transport->read_mtu; - if (setsockopt(this->fd, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val)) < 0) - spa_log_warn(this->log, "%p: SO_RCVBUF %m", this); - val = 6; if (setsockopt(this->fd, SOL_SOCKET, SO_PRIORITY, &val, sizeof(val)) < 0) spa_log_warn(this->log, "SO_PRIORITY failed: %m");