a2dp: improve codec specific transport socket send buffer size setting

This commit is contained in:
Huang-Huang 2021-01-31 09:01:40 +08:00
parent 60aef11072
commit c778bd734c
No known key found for this signature in database
GPG key ID: 33C3271387A13D1B
5 changed files with 11 additions and 11 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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]);

View file

@ -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);