Commit 7d191b64 authored by Igor Kovalenko's avatar Igor Kovalenko Committed by PulseAudio Marge Bot
Browse files

bluetooth: mSBC: ignore all-zero packets

This is a workaround for hardware/driver which inserts all-zero packets in what
otherwise looks like a valid mSBC stream.

Part-of: <!507>
parent 6c0c9cf8
......@@ -182,6 +182,16 @@ static size_t encode_buffer(void *codec_info, uint32_t timestamp, const uint8_t
return MSBC_PACKET_SIZE;
}
static inline bool is_all_zero(const uint8_t *ptr, size_t len) {
size_t i;
for (i = 0; i < len; ++i)
if (ptr[i] != 0)
return false;
return true;
}
/*
* We build a msbc frame up in the sbc_info buffer until we have a whole one
*/
......@@ -191,6 +201,12 @@ static struct msbc_frame *msbc_find_frame(struct sbc_info *si, ssize_t *len,
int i;
uint8_t *p = si->input_buffer;
/* skip input if it has all zero bytes
* this could happen with older kernels inserting all-zero blocks
* inside otherwise valid mSBC stream */
if (*len > 0 && is_all_zero(buf, *len))
*len = 0;
for (i = 0; i < *len; i++) {
union msbc_h2_id1 id1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment