From 02a4758043866db6a3f01c554f85f8c2459e8e67 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Mon, 7 Nov 2022 18:12:42 +0300 Subject: [PATCH] bluez5: aac, lc3plus: report bitpool changes Behavior similar to SBC. This makes return value useful for media-sink logger. --- spa/plugins/bluez5/a2dp-codec-aac.c | 2 +- spa/plugins/bluez5/a2dp-codec-lc3plus.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/spa/plugins/bluez5/a2dp-codec-aac.c b/spa/plugins/bluez5/a2dp-codec-aac.c index 4820214ee..46a87407b 100644 --- a/spa/plugins/bluez5/a2dp-codec-aac.c +++ b/spa/plugins/bluez5/a2dp-codec-aac.c @@ -610,7 +610,7 @@ static int codec_change_bitrate(struct impl *this, int new_bitrate) if (res != AACENC_OK) return -EINVAL; - return 0; + return this->cur_bitrate; } static int codec_reduce_bitpool(void *data) diff --git a/spa/plugins/bluez5/a2dp-codec-lc3plus.c b/spa/plugins/bluez5/a2dp-codec-lc3plus.c index d8e1d284e..289662442 100644 --- a/spa/plugins/bluez5/a2dp-codec-lc3plus.c +++ b/spa/plugins/bluez5/a2dp-codec-lc3plus.c @@ -747,15 +747,17 @@ static SPA_UNUSED int codec_decode(void *data, static int codec_reduce_bitpool(void *data) { struct impl *this = data; - this->e.next_bitrate = this->bitrate * 3 / 4; - return 0; + this->e.next_bitrate = SPA_CLAMP(this->bitrate * 3 / 4, + BITRATE_MIN * this->channels, BITRATE_MAX * this->channels); + return this->e.next_bitrate; } static int codec_increase_bitpool(void *data) { struct impl *this = data; - this->e.next_bitrate = this->bitrate * 5 / 4; - return 0; + this->e.next_bitrate = SPA_CLAMP(this->bitrate * 5 / 4, + BITRATE_MIN * this->channels, BITRATE_MAX * this->channels); + return this->e.next_bitrate; } const struct media_codec a2dp_codec_lc3plus_hr = {