[pulseaudio-discuss] [PATCH v2 1/2] Modular API for Bluetooth A2DP codec

Pali Rohár pali.rohar at gmail.com
Sat Apr 20 11:52:21 UTC 2019


On Monday 17 September 2018 15:02:18 Tanu Kaskinen wrote:
> > > > +    sbc_info->min_bitpool = config->min_bitpool;
> > > > +    sbc_info->max_bitpool = config->max_bitpool;
> > > > +
> > > > +    /* Set minimum bitpool for source to get the maximum possible block_size */
> > > > +    sbc_info->sbc.bitpool = is_a2dp_sink ? sbc_info->max_bitpool : sbc_info->min_bitpool;
> > > 
> > > Do you understand the logic here?
> > 
> > I have not looked deeply at this code. So I'm not fully sure. I just
> > moved existing code into new file.
> 
> Ok, so this remains a mystery to all of us.

Now I figured out, why that logic is there. Is is because of how block
size in a2dp_prepare_decoder_buffer() function is calculated. Thanks for
your email about while loops, checking processed sizes in faststream
decoder function; this helped me.

It is mess. I'm going to cleanup this code. But it would need some
changes in codec API...

That minimal bitpool value is there really needed and I will add comment
with detailed explanation to code.

Bitpool is controlled by sender so for source by other side -- not
pulseaudio. Frame length depends on bitpool value and buffer size which
is calculated from MTU is inversely proportional to frame length.

To prevent decoding failures due to small buffer, we set bitpool value
for source to the smallest value, so a2dp_prepare_decoder_buffer()
calculates and allocates the largest possible buffer size.

sbc_info->sbc.bitpool is not used by SBC decoder itself. Moreover after
decoding each SBC frame, libsbc decoder updates this value to bitpool of
decoded SBC frame.

-- 
Pali Rohár
pali.rohar at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20190420/05884c21/attachment-0001.sig>


More information about the pulseaudio-discuss mailing list