From 9653d748a3551cd66a29263cea29c6b707a013e7 Mon Sep 17 00:00:00 2001 From: Huang-Huang Bao Date: Sat, 19 Dec 2020 20:25:49 +0800 Subject: [PATCH] a2dp: fix a2dp encoding under sampling rate of 88200, 96000 Signed-off-by: Huang-Huang Bao --- spa/plugins/bluez5/a2dp-codec-ldac.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spa/plugins/bluez5/a2dp-codec-ldac.c b/spa/plugins/bluez5/a2dp-codec-ldac.c index 6c7c6f152..acb0b3cb5 100644 --- a/spa/plugins/bluez5/a2dp-codec-ldac.c +++ b/spa/plugins/bluez5/a2dp-codec-ldac.c @@ -65,6 +65,7 @@ struct impl { int codesize; int frame_length; int frame_count; + int frame_count_factor; }; enum { @@ -297,7 +298,7 @@ static int codec_increase_bitpool(void *data) static int codec_get_num_blocks(void *data) { struct impl *this = data; - return this->frame_count; + return this->frame_count * this->frame_count_factor; } static int codec_get_block_size(void *data) @@ -358,10 +359,13 @@ static void *codec_init(const struct a2dp_codec *codec, uint32_t flags, case LDACBT_SAMPLING_FREQ_044100: case LDACBT_SAMPLING_FREQ_048000: this->codesize *= 128; + this->frame_count_factor = 1; break; case LDACBT_SAMPLING_FREQ_088200: case LDACBT_SAMPLING_FREQ_096000: - this->codesize *= 256; + /* ldac ecoder has a constant encoding lsu: LDACBT_ENC_LSU=128 */ + this->codesize *= 128; + this->frame_count_factor = 2; break; default: res = -EINVAL;