bluetooth: Fix usage of MTU, buffer sizes and return values of encode/decode methods
authorPali Rohár <pali.rohar@gmail.com>
Sun, 21 Jul 2019 15:07:00 +0000 (17:07 +0200)
committerTanu Kaskinen <tanuk@iki.fi>
Wed, 24 Jul 2019 14:29:45 +0000 (17:29 +0300)
commit018b38ec39072ef0087db0063b4655b2bd943c14
treed2de5939f141702ee1a4d6d4540518eddccf5039
parent3929798a53c6fbc83b3d54d801c1c07cee4c78f5
bluetooth: Fix usage of MTU, buffer sizes and return values of encode/decode methods

Add explanation why minimal bitpool value is used in SBC codec as initial
bitpool value for A2DP source.

Set buffer size for reading/writing from/to A2DP socket to exact link MTU
value. This would ensure that A2DP codec does not produce larger packet as
maximal possible size which can be sent.

Because A2DP socket is of SOCK_SEQPACKET type, it is guaranteed that
we do not read two packets via one read/recvmsg call.

Properly check for all return values of encode/encode methods of A2DP codec
functions. They may fail at different levels. Also encode or decode API
method may return zero length buffer (e.g. because of algorithmic delay of
codec), so do not fail in this case.
src/modules/bluetooth/a2dp-codec-api.h
src/modules/bluetooth/a2dp-codec-sbc.c
src/modules/bluetooth/module-bluez5-device.c