Skip to contentSkip to conversation

android/hal-audio-sbc: Fix use of incorrect number of frames per packet

PATCH New Luiz Augusto von Dentz 1 participant 1 message Jun 1, 2014 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 android/hal-audio-sbc: Fix use of incorrect number of frames per packet

From: Luiz Augusto von Dentz <[email protected]>

Number of frames should always be limited to the maximun that can be set in the payload header.

---
 android/hal-audio-sbc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
android/hal-audio-sbc.c +4 -1
index ad20f51..0c31035 100644
@@ -241,6 +241,9 @@ static void sbc_codec_calculate(struct sbc_data *sbc_data)
 	out_frame_len = sbc_get_frame_length(&sbc_data->enc);
 	num_frames = sbc_data->payload_len / out_frame_len;
 
+	if (num_frames > MAX_FRAMES_IN_PAYLOAD)
+		num_frames = MAX_FRAMES_IN_PAYLOAD;
+
 	sbc_data->in_frame_len = in_frame_len;
 	sbc_data->in_buf_size = num_frames * in_frame_len;
 
@@ -346,7 +349,7 @@ static ssize_t sbc_encode_mediapacket(void *codec_data, const uint8_t *buffer,
 
 	while (len - consumed >= sbc_data->in_frame_len &&
 			mp_data_len - encoded >= sbc_data->out_frame_len &&
-			frame_count < MAX_FRAMES_IN_PAYLOAD) {
+			frame_count < sbc_data->frames_per_packet) {
 		ssize_t read;
 		ssize_t written = 0;
 
Signature · 1 line
1.9.0