linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ] android/hal-audio-sbc: Fix use of incorrect number of frames per packet
@ 2014-06-01 15:26 Luiz Augusto von Dentz
  0 siblings, 0 replies; only message in thread
From: Luiz Augusto von Dentz @ 2014-06-01 15:26 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

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(-)

diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c
index ad20f51..0c31035 100644
--- a/android/hal-audio-sbc.c
+++ b/android/hal-audio-sbc.c
@@ -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;
 
-- 
1.9.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2014-06-01 15:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-01 15:26 [PATCH BlueZ] android/hal-audio-sbc: Fix use of incorrect number of frames per packet Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).