diff --git a/spa/plugins/bluez5/a2dp-codec-aptx.c b/spa/plugins/bluez5/a2dp-codec-aptx.c index 21fbf9bb3..c7c5bd497 100644 --- a/spa/plugins/bluez5/a2dp-codec-aptx.c +++ b/spa/plugins/bluez5/a2dp-codec-aptx.c @@ -341,8 +341,6 @@ const struct a2dp_codec a2dp_codec_aptx = { .codec_id = APTX_CODEC_ID }, .name = "aptx", .description = "aptX", - .send_fill_frames = 2, - .recv_fill_frames = 2, .fill_caps = codec_fill_caps, .select_config = codec_select_config, .enum_config = codec_enum_config, @@ -366,8 +364,6 @@ const struct a2dp_codec a2dp_codec_aptx_hd = { .codec_id = APTX_HD_CODEC_ID }, .name = "aptx_hd", .description = "aptX HD", - .send_fill_frames = 2, - .recv_fill_frames = 2, .fill_caps = codec_fill_caps, .select_config = codec_select_config, .enum_config = codec_enum_config, diff --git a/spa/plugins/bluez5/a2dp-codec-ldac.c b/spa/plugins/bluez5/a2dp-codec-ldac.c index b5b77c96d..ab1b5e8d4 100644 --- a/spa/plugins/bluez5/a2dp-codec-ldac.c +++ b/spa/plugins/bluez5/a2dp-codec-ldac.c @@ -48,6 +48,8 @@ #define LDAC_ABR_THRESHOLD_DANGEROUSTREND 4 #define LDAC_ABR_THRESHOLD_SAFETY_FOR_HQSQ 3 +#define LDAC_ABR_SOCK_BUFFER_SIZE (LDAC_ABR_THRESHOLD_CRITICAL * LDAC_ABR_MAX_PACKET_NBYTES) + struct impl { HANDLE_LDAC_BT ldac; @@ -487,7 +489,9 @@ const struct a2dp_codec a2dp_codec_ldac = { .codec_id = LDAC_CODEC_ID }, .name = "ldac", .description = "LDAC", - .send_fill_frames = 4, +#ifdef ENABLE_LDAC_ABR + .send_buf_size = LDAC_ABR_SOCK_BUFFER_SIZE, +#endif .fill_caps = codec_fill_caps, .select_config = codec_select_config, .enum_config = codec_enum_config, diff --git a/spa/plugins/bluez5/a2dp-codec-sbc.c b/spa/plugins/bluez5/a2dp-codec-sbc.c index ad12ac48a..9cce8e083 100644 --- a/spa/plugins/bluez5/a2dp-codec-sbc.c +++ b/spa/plugins/bluez5/a2dp-codec-sbc.c @@ -571,8 +571,6 @@ const struct a2dp_codec a2dp_codec_sbc = { .codec_id = A2DP_CODEC_SBC, .name = "sbc", .description = "SBC", - .send_fill_frames = 2, - .recv_fill_frames = 2, .fill_caps = codec_fill_caps, .select_config = codec_select_config, .enum_config = codec_enum_config, diff --git a/spa/plugins/bluez5/a2dp-codecs.h b/spa/plugins/bluez5/a2dp-codecs.h index af2d6d8ee..fc57b8836 100644 --- a/spa/plugins/bluez5/a2dp-codecs.h +++ b/spa/plugins/bluez5/a2dp-codecs.h @@ -332,8 +332,7 @@ struct a2dp_codec { const char *description; const struct spa_dict *info; - const int send_fill_frames; - const int recv_fill_frames; + const size_t send_buf_size; int (*fill_caps) (const struct a2dp_codec *codec, uint32_t flags, uint8_t caps[A2DP_MAX_CAPS_SIZE]); diff --git a/spa/plugins/bluez5/a2dp-sink.c b/spa/plugins/bluez5/a2dp-sink.c index 4c735d4a9..4eb3b9932 100644 --- a/spa/plugins/bluez5/a2dp-sink.c +++ b/spa/plugins/bluez5/a2dp-sink.c @@ -686,7 +686,10 @@ static int do_start(struct impl *this) spa_log_debug(this->log, NAME " %p: block_size %d num_blocks:%d", this, this->block_size, this->num_blocks); - val = SPA_MAX(this->codec->send_fill_frames, FILL_FRAMES) * this->transport->write_mtu; + val = this->codec->send_buf_size > 0 + /* The kernel doubles the SO_SNDBUF option value set by setsockopt(). */ + ? this->codec->send_buf_size / 2 + this->codec->send_buf_size % 2 + : FILL_FRAMES * this->transport->write_mtu; if (setsockopt(this->transport->fd, SOL_SOCKET, SO_SNDBUF, &val, sizeof(val)) < 0) spa_log_warn(this->log, NAME " %p: SO_SNDBUF %m", this); @@ -699,7 +702,7 @@ static int do_start(struct impl *this) } this->fd_buffer_size = val; - val = SPA_MAX(this->codec->recv_fill_frames, FILL_FRAMES) * this->transport->read_mtu; + 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, NAME " %p: SO_RCVBUF %m", this);