summaryrefslogtreecommitdiff
path: root/android/hal-audio-sbc.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-06-01 18:01:33 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2014-06-03 16:26:33 +0300
commit2d5f743734bd55fcac47b8d5ff8537767cba068f (patch)
treed23b6be8160d425228806fd8a030c3ba6e4fa948 /android/hal-audio-sbc.c
parent8b62dc61549577667db3dad0fff02dd7f5f9b350 (diff)
downloadbluez-2d5f743734bd55fcac47b8d5ff8537767cba068f.tar.gz
android/hal-audio-sbc: Fix use of incorrect number of frames per packet
Number of frames should always be limited to the maximun that can be set in the payload header.
Diffstat (limited to 'android/hal-audio-sbc.c')
-rw-r--r--android/hal-audio-sbc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/android/hal-audio-sbc.c b/android/hal-audio-sbc.c
index ad20f51b8..0c310350a 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;