bluez5: account for codec internal delay in latency values

Encoders and some decoders have additional internal latency that needs
to be accounted for.

This mostly matters for AAC (~40ms), as the other BT codecs have much
lower delays (~5ms).
This commit is contained in:
Pauli Virtanen 2024-02-23 21:04:47 +02:00 committed by Wim Taymans
parent 1b3b577b8f
commit 2d30ab94c2
10 changed files with 151 additions and 10 deletions

View file

@ -551,6 +551,25 @@ static int codec_encode(void *data,
return src_used;
}
static void codec_get_delay(void *data, uint32_t *encoder, uint32_t *decoder)
{
struct impl *this = data;
if (encoder) {
switch (this->frequency) {
case 96000:
case 88200:
*encoder = 256;
break;
default:
*encoder = 128;
break;
}
}
if (decoder)
*decoder = 0;
}
const struct media_codec a2dp_codec_ldac = {
.id = SPA_BLUETOOTH_AUDIO_CODEC_LDAC,
.codec_id = A2DP_CODEC_VENDOR,
@ -577,6 +596,7 @@ const struct media_codec a2dp_codec_ldac = {
.encode = codec_encode,
.reduce_bitpool = codec_reduce_bitpool,
.increase_bitpool = codec_increase_bitpool,
.get_delay = codec_get_delay,
};
MEDIA_CODEC_EXPORT_DEF(